Excelgoodies logo +31 97 010285556

LEARN THIS HANDS ON

Power Apps & Power Automate

. Live Online FILLING FAST
View all upcoming batches
AI Builder in Power Automate: Automating Invoice Capture and Email Triage for AP Teams

AI Builder in Power Automate: Automating Invoice Capture and Email Triage for AP Teams

Accounts payable teams are still copy‑pasting invoice data from PDFs and sorting vendor emails into the right queues. Even with Power Automate in place, someone usually ends up doing manual triage and data entry. This walkthrough shows how to use AI Builder invoice processing and email classification in Power Automate to remove that manual layer without breaking your downstream finance processes.

Scenario: AP Inbox Chaos and Manual Invoice Entry

You have a shared AP mailbox (e.g. ap@company.com) and a document library for incoming invoices.

The current process:

  • Vendors email invoices as PDF or image attachments
  • AP staff:
    • Download attachments
    • Rename and upload to SharePoint or OneDrive
    • Type header and line data into your ERP or finance system
    • Manually forward or tag emails for exceptions (disputes, reminders, statements)

The goal:

  1. Use AI Builder invoice processing to read key invoice fields and line items automatically.
  2. Use AI Builder classification to route AP emails (invoice, statement, query, reminder) without human triage.
  3. Keep everything inside Power Automate cloud flows, so you can integrate with SharePoint, Dataverse, and your finance/ERP connectors.

I'll stick to one realistic pattern:

  • Invoices land in a SharePoint library (either dropped there or saved from the AP mailbox)
  • A cloud flow extracts invoice data and writes it into Dataverse or another system
  • Another flow classifies AP emails and routes them to the right place

Key Concepts: AI Builder Models You Actually Need

For this scenario you only need two AI Builder capabilities:

  1. Prebuilt Invoice Processing model

    • Extracts header and line‑item data from invoices
    • Supports common formats (PDF and images like JPG/PNG)
    • Returns structured JSON with fields like:
      • Vendor name, invoice number, invoice date, due date
      • Subtotal, tax, total
      • Line item table (description, quantity, unit price, line total)
    • Available as the "Extract information from invoices" action in Power Automate
  2. Custom Classification model

    • For email triage you typically use a custom classification model trained on your own labeled emails.
    • Exposed in Power Automate as "Classify text into categories" (wording may vary slightly in the UI).

Both rely on AI Builder credits and capacity. If your environment runs out of credits, AI Builder actions will fail once capacity is exhausted, so treat them as a paid, capacity‑limited resource.


Designing the Invoice Flow: From SharePoint File to Structured Data

We’ll build a flow that:

  1. Triggers when a new file is added to a SharePoint library
  2. Calls AI Builder invoice processing
  3. Writes the extracted data into Dataverse (or another target)
  4. Logs failures and low‑confidence extractions

1. Trigger on New Invoice Files

Use the standard SharePoint trigger:

  • Trigger: When a file is created (properties only)
  • Parameters:
    • Site Address: your AP site
    • Library Name: Incoming Invoices

Immediately after the trigger, add:

  • Get file content (SharePoint) to retrieve the binary content needed by AI Builder.

2. Call AI Builder Invoice Processing

Add the AI Builder action:

  • Action: Extract information from invoices
  • Inputs:
    • File content: from Get file content

You can optionally set locale and language parameters if your invoices are consistently in one language; if not set, the model uses its default behavior and attempts to detect fields regardless of language.

The output is a JSON object. In a typical flow, you’ll see something like:

  • documents (array of invoices found in the file)
  • For each invoice:
    • fields (header fields)
    • lineItems (table of lines)

The exact property names may vary slightly with updates, but the pattern is consistent: a top‑level collection of documents, each with named fields and a line‑item collection.

3. Map AI Output to Your Data Model

For Dataverse, you’d create:

  • A custom table: ap_invoice
    • Columns: vendor_name, invoice_number, invoice_date, due_date, subtotal, tax, total, currency, source_file_url, confidence_header
  • A related table: ap_invoice_line
    • Columns: ap_invoice (lookup), line_number, description, quantity, unit_price, line_total, confidence_line

In the flow:

  1. Parse the AI Builder JSON using the Parse JSON action if you want strong typing, or use dynamic content directly if you’re comfortable with the raw structure.

  2. Create the header record:

    • Action: Add a new row (Dataverse)
    • Table: ap_invoice
    • Map fields like:
      • vendor_name → Vendor Name from AI output
      • invoice_number → Invoice Number
      • invoice_date → Invoice Date
      • due_date → Due Date
      • subtotal, tax, total → corresponding monetary fields
      • source_file_url → Path from SharePoint
      • confidence_header → an aggregate or minimum of the confidence scores from AI Builder (using the confidence values exposed per field)
  3. Loop line items:

    • Action: Apply to each
      • Input: lineItems from the AI output
    • Inside loop:
      • Add a new row (Dataverse) in ap_invoice_line
      • Map:
        • ap_invoice → the ID from the header record
        • line_number → index from the loop
        • description, quantity, unit_price, line_total from AI output
        • confidence_line → confidence for that line if available

If you’re writing to SQL or another system, use the equivalent insert actions or HTTP calls. The mapping logic stays the same.

4. Handle Low Confidence and Failures

AI Builder returns confidence scores per field and often per line. Use them to control downstream behavior:

  • Add a Condition after invoice processing:
    • If confidence_header < threshold (e.g. 0.8):
      • Flag invoice for manual review:
        • Create a Dataverse record in an ap_invoice_review table
        • Send an email or Teams message to AP with a link to the file
    • Else:
      • Continue with automatic posting or pre‑posting

Also handle outright failures:

  • Wrap the AI Builder action in a Scope
  • Configure run after on a follow‑up action to catch has failed or has timed out
  • Log a record with the file URL and error message for follow‑up

This prevents silent failures where invoices sit in SharePoint without being processed.


Designing the Email Classification Flow: Routing AP Mail Automatically

Now we tackle the AP mailbox. The pattern:

  1. Trigger on new email in the shared AP mailbox
  2. Extract subject and body
  3. Call an AI Builder text classification model
  4. Route the email based on predicted category

1. Trigger on AP Mailbox

In Power Automate:

  • Trigger: When a new email arrives (V3)
  • Parameters:
    • Original mailbox type: Shared mailbox
    • Mailbox address: ap@company.com
    • Folder: Inbox

Optionally filter by:

  • Has Attachments = Yes
  • Or a subject filter if needed

2. Get Text to Classify

Use the trigger outputs directly:

  • Subject
  • Body (HTML)

If your classifier expects plain text, add:

  • Action: Html to text (built‑in or custom) to strip HTML tags from the email body.

3. Classify the Email

Add the AI Builder text classification action.

Depending on the model you’ve set up, you’ll see something like:

  • Action: Classify text into categories (AI Builder)
  • Inputs:
    • Text: subject + body (plain text)

With a custom classification model, you will have defined categories such as:

  • Invoice
  • Statement
  • Vendor Query
  • Payment Reminder

The output typically includes:

  • Predicted category (label)
  • Confidence score per category

Use a Compose or Variable to store the primary predicted label and its confidence.

4. Route Based on Category and Confidence

Add a Switch action on the predicted label:

  • Case Invoice:

    • Move email to Invoices folder
    • Save attachments to Incoming Invoices SharePoint library
    • Optionally trigger the invoice processing flow above if you don’t want to rely solely on the SharePoint trigger
  • Case Statement:

    • Move email to Statements folder
    • Save attachments to a separate library
  • Case Vendor Query:

    • Create a ticket in your service desk system
    • Move email to Vendor Queries
  • Case Payment Reminder:

    • Tag the invoice record in Dataverse
    • Notify the responsible AP analyst

Add a Condition inside each case (or before the Switch) to check confidence:

  • If confidence < threshold:
    • Move email to AP Review folder
    • Add a Dataverse record or Excel row for manual classification

This ensures low‑confidence predictions don’t silently misroute critical vendor communication.


Connecting Email and Invoice Flows Cleanly

You have two options to connect the two flows:

  1. Attachment‑driven processing (recommended when invoices always come via email):

    • The email flow:
      • Saves attachments to SharePoint
      • Adds metadata (e.g. SourceEmailId, PredictedCategory)
    • The invoice flow:
      • Triggers from SharePoint
      • Uses metadata to link to the email and category
  2. Direct invoice processing in the email flow:

    • The email flow:
      • Immediately calls AI Builder invoice processing on each attached invoice
      • Writes results to Dataverse or ERP

The first option keeps flows simpler and lets you reuse the invoice processing logic for invoices that arrive via other channels (uploads, integrations). The second option reduces latency if you need near‑real‑time invoice ingestion from email.

If you choose option 1, make sure:

  • The SharePoint trigger library is the same one the email flow writes to
  • You handle duplicate attachments (vendors re‑sending the same invoice) using:
    • A unique constraint on invoice_number + vendor in Dataverse
    • Or a pre‑insert check in the flow

Practical Limits and Gotchas

A few constraints matter in real AP environments:

  • File size and type

    • AI Builder invoice processing has limits on maximum file size and supported formats. Large scanned PDFs or unusual formats may fail or be partially processed. If you’re near the limit, consider splitting very large documents or rejecting them with a clear message to vendors.
  • Layout variability

    • The prebuilt invoice model is trained on common invoice layouts. Highly custom, multi‑language, or mixed‑content documents can reduce accuracy. If your vendor base is unusual, you may need a custom document processing model trained on your own sample invoices.
  • Capacity and performance

    • AI Builder actions consume credits and have throughput limits. A sudden spike (e.g. end‑of‑month invoice batch) can slow processing or hit capacity. Build monitoring around:
      • Number of processed invoices per day
      • Failures due to capacity
  • Security and data residency

    • AI Builder runs within Microsoft’s infrastructure, but data handling and residency depend on your tenant’s region and configuration. If your AP data is sensitive or regulated, coordinate with your admins to confirm compliance before pushing production volume through AI Builder.
  • Error handling and partial success

    • AI Builder may correctly read header fields but misread line items, or vice versa. Treat header and lines separately in your confidence logic, and allow manual correction of either without blocking the other.

One Concrete Next Step

Pick five recent invoices and ten AP emails, set up a test environment, and wire the two flows described here with AI Builder invoice processing and text classification. Run them end‑to‑end, inspect the confidence scores and misclassifications, and adjust thresholds and routing before you touch production mailboxes or finance tables.

Editor's Note

This article reflects how AP and finance teams are starting to embed AI Builder invoice processing and email classification into Power Automate flows to reduce manual triage and data entry while keeping control of confidence thresholds and downstream posting logic.

Professionals who want to apply these patterns to their own data can explore Excelgoodies' Power Automate Course programme - taught live by instructors, with certification awarded once a real project is running at work.

Insights compiled through ongoing industry research and discussions within the Excelgoodies Analytics Community.

Power Automate

New

Next Batches Now Live

Power BIPower BI
SQLSQL
Power AppsPower Apps
Power AutomatePower Automate
Microsoft FabricMicrosoft Fabrics
AzureAzure Data Engineering
Explore Dates & Reserve Your Spot → Reserve Your Spot →