Streamline Invoice Processing with AI Builder and Power Automate
Automatically extract invoice details from email attachments, evaluate confidence, and manage exceptions with minimal human effort.
Manual invoice data entry is slow, error‑prone, and costly. Power Automate, paired with AI Builder’s pre‑built invoice extraction model, can capture key fields—invoice number, vendor, date, amount—straight from PDFs or image files. Even better, you can let the flow decide when a human should review: if any extracted value has a low confidence score, the record is automatically flagged for manual verification.
In this article you’ll build a flow that picks up invoice attachments from a dedicated mailbox, extracts the data, writes it to a SharePoint list, and routes only the uncertain ones to an approver. The same pattern works if invoices arrive in a SharePoint library, OneDrive, or a Teams channel.
You need an environment with AI Builder capabilities (a standalone license or a Premium Power Automate plan) and sufficient SharePoint Online permissions to create lists and run flows.
The Scenario
Your company uses a shared mailbox (invoices@contoso.com) for receiving supplier invoices. Each invoice arrives as a PDF attachment. The flow:
- Watches the mailbox for new messages that contain a PDF attachment.
- Extracts the invoice file content.
- Sends the content to AI Builder, which returns structured fields such as Invoice ID, Vendor Name, Invoice Date, and Invoice Total—each with a confidence score between 0 and 1.
- Calculates whether the lowest confidence among the core fields falls below 0.75.
- Creates a record in a SharePoint list with the extracted data and a status of “Approved” (all scores ≥ 0.75) or “Pending Review” (any score < 0.75).
- Optionally emails an accountant when a review is needed.
Step 1: Create a SharePoint List for Invoice Records
Create a new list called Invoices Log with these columns:
| Column Name | Type |
|---|---|
| InvoiceId | Single line of text |
| VendorName | Single line of text |
| InvoiceDate | Date and Time |
| TotalAmount | Currency |
| Confidence | Number (decimal; can store overall min) |
| Status | Choice: Approved, Pending Review |
You can add extra fields (e.g., PurchaseOrder, Currency) later by pulling them from the AI Builder output.
Step 2: Build the Power Automate Flow
2.1 Set Up the Trigger
Choose the When a new email arrives (V3) connector from Office 365 Outlook. Point it to your shared mailbox and, optionally, add a subject filter like “Invoice” to reduce noise.
2.2 Process Only Invoice Attachments
Surround the rest of the flow with an Apply to each over the Attachments dynamic content. Inside the loop, add a Condition to check the attachment extension. The condition expression:
@endsWith(items('Apply_to_each')?['name'], '.pdf')For the If yes branch, include a Get attachment content action. Set the attachment identifier to items('Apply_to_each')?['id'] and the message identifier to the output of the trigger.
2.3 Extract Invoice Details
Add the Extract information from invoices action (AI Builder category). In the Invoice File field, insert the file content from the previous step.
AI Builder accepts images (JPG, PNG) as well as PDF files. The model returns more than thirty possible fields; you can use the ones that matter most to your process.
2.4 Evaluate Confidence Scores
Create a Compose action that builds an array of the four most critical confidence scores. Use the dynamic content from the AI Builder step or write the expression directly:
[
@float(outputs('Extract_information_from_invoices')?['body/predictionOutput/result/fields/invoiceId/confidence']),
@float(outputs('Extract_information_from_invoices')?['body/predictionOutput/result/fields/vendorName/confidence']),
@float(outputs('Extract_information_from_invoices')?['body/predictionOutput/result/fields/invoiceDate/confidence']),
@float(outputs('Extract_information_from_invoices')?['body/predictionOutput/result/fields/invoiceTotal/confidence'])
]Add a Filter array action. Set From to the output of the Compose, and the Condition to:
@item() < 0.75
Now add a Condition action that checks whether the filtered array is empty:
@length(outputs('Filter_array'))- If greater than 0 → at least one field has low confidence. Set a String variable (initialised earlier) to “Pending Review”.
- Otherwise → set the same variable to “Approved”.
2.5 Create the SharePoint Record
After the condition branches merge, insert a Create item action (SharePoint connector). Map the columns to the AI Builder outputs and the variable you just set:
| List Field | Value Source |
|---|---|
| InvoiceId | output of AI Builder → invoiceId |
| VendorName | output of AI Builder → vendorName |
| InvoiceDate | output of AI Builder → invoiceDate |
| TotalAmount | output of AI Builder → invoiceTotal |
| Confidence | output of the array compose (optionally the min) |
| Status | the variable set in the previous step |
You can optionally store the overall lowest confidence in the Confidence column by adding a Compose that calculates it:
@min(outputs('Compose_array'))Then use that compose’s output in the column.
2.6 (Optional) Notify the Approver
Still inside the “Pending Review” branch, add a Send an email (V2) action. Compose a message listing the invoice fields that fell below threshold (you can build a comma‑separated string with a Select and a Join, if you need to identify exactly which fields are suspect).
Step 3: Test the Flow
Send a test invoice PDF to the monitored mailbox. The flow should fire, create a record, and set the status based on the document quality. Try an invoice with blurry numbers or skewed angles—the confidence scores will drop and the item should get flagged for review.
Common Mistakes and Troubleshooting
- Wrong output path – The dynamic content picker in Power Automate shows the correct paths. If you write expressions manually and they fail, insert the field from the picker and copy its expression.
- Empty confidence scores – AI Builder might fail to extract a field on very poor images. In that case the confidence can be
null. Add error handling (e.g., use a Compose that defaults to 0 with acoalesceor a condition). - Multiple attachments – The outer loop runs for every attachment. If an invoice spans several files, you may need to collect them or process only the first PDF.
Final Recommendation
AI Builder’s pre‑built invoice model is a powerful way to cut hours of manual work. Start with a small pilot on real invoices to tune your confidence threshold (0.75 worked well in our tests, but your documents may differ). Once stable, extend the flow to write directly to an accounting system via Power Automate Desktop or a custom connector.
Remember that the model is continually improving: check the official output reference for newly added fields as they become available.
References
- Original source article: Extract Invoice Details With Power Automate And AI Builder (by Matthew Devaney)
- AI Builder Prebuilt Invoice Model: Microsoft Learn
- Power Automate Documentation: Create flows with AI Builder
Use a custom classifier built with Azure AI Document Intelligence to automatically tag uploaded legal documents with their contract type and confidence score.
Core principles for resilient, maintainable, and efficient cloud flows, distilled from real-world implementations.
Build flows that gracefully handle failures and automatically notify you with run details.