Thank you for that example. That is very helpful. I will update my prompt and see if that helps. Here is my entire prompt that I am using for this process. The other properties were populating correctly so I didn't include them in my original post. Can a prompt in AI Builder be too long?
Task
Extract and organize key details from invoices with 90% or higher confidence.
Sections Required
Vendor Name (String)
- Extract the name of the company issuing the invoice (typically found in the header or footer of the document, not in the "Accounts Payable" section).
- Remove all special characters except the ampersand (&).
Department Number (String)
- Extract only the numeric portion of the department number.
- Must start with “Department Number” or “Dept. No” or "Department NO". If not present, leave blank.
Invoice Amount (Decimal)
- Extract as a decimal value.
Invoice Date (Date)
- Format as mm/dd/yyyy.
Invoice Number (String)
- If not present, leave blank.
PO Number (String)
- Extract only if explicitly labeled “PO Number” or “Purchase Order Number”.
- Ignore fields labeled Order #, CUS P/O #, Customer PO, GAS P/O #, or any variation of these.
- If the PO Number is fewer than 10 characters, leave blank.
- Do not infer PO Number from unrelated fields.
Contract Number (String)
- May be labeled “Statement of Service” or “Customer PO”.
- If PO Number is present, leave Contract Number blank.
Voucher BU (String)
- Extract only the numeric portion of the Voucher BU.
- May start with "MSC”.
Additional Rules
- PO Number and Contract Number are not the same as Agreement Number.
- If PO Number is present leave Contract Number blank.
- Output must be structured in valid JSON format.
Data Source
<Invoice PDF>
Output Format
Return the extracted data in this JSON structure:
{
"Vendor Name": "",
"Department Number": "",
"Invoice Amount": 0.00,
"Invoice Date": "mm/dd/yyyy",
"Invoice Number": "",
"PO Number": "",
"Contract Number": "",
"Voucher BU": ""
}
I did add a condition to my flow for the PO Number just in case the prompt fails.
{
"type": "If",
"expression": {
"and": [
{
"equals": [
"@not(empty(body('Parse_JSON')?['PO Number']))",
true
]
},
{
"equals": [
"@length(body('Parse_JSON')?['PO Number'])",
10
]
}
]
}
}
This seems to help.