Invoice Processing from Email
Scans incoming emails for invoices (PDF attachments with 'invoice' in subject), extracts key details, logs them to a SharePoint list, and routes high-value invoices for approval before payment.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow automates the front-end of accounts-payable invoice intake. When a new email arrives in a shared mailbox with invoice in the subject and at least one attachment, the flow filters down to PDF attachments, saves them to a date-foldered OneDrive location, extracts vendor / invoice number / amount / due-date from the email body, logs a row to a SharePoint Invoice Tracker list, and conditionally routes high-value invoices to a Finance approver before notifying the Accounts Payable team. Lower-value invoices are auto-approved so the AP team only sees an FYI.
Use Case
Finance and AP teams spend a disproportionate amount of time triaging invoice emails — opening each one, downloading the PDF, copying header fields into a tracker, and chasing approvals for anything that looks large. This flow centralizes the triage: a single mailbox becomes the intake, every PDF is archived in a predictable monthly folder, every invoice is logged with a consistent schema, and the only invoices that require a human decision are the ones above the configured approval threshold. The result is faster intake, an audit trail, and less manual data entry.
The flow is ideal for teams that:
- Finance / Accounts Payable teams that receive invoices by email and want a tracker without changing how vendors send them
- Organizations standardizing invoice intake before rolling out a full AP automation platform
- Teams that need an approval gate for high-value invoices but want low-value ones to flow through automatically
- Anyone wanting a date-foldered OneDrive archive of incoming invoice PDFs
Flow Architecture
When a new email arrives (V3)
Outlook 365 — When a new email arrives (V3)Fires when an email arrives in the monitored mailbox with `invoice` in the subject and at least one attachment. Subject Filter is `invoice`, Include Attachments and Only With Attachments are both Yes.
Apply to each attachment
Control — Apply to eachLoops over every attachment on the trigger email so each one can be evaluated and processed independently.
If attachment is a PDF
If conditionFilters out non-PDF attachments using `endsWith(items('Apply_to_each')?['name'], '.pdf')` so only invoice PDFs are saved and logged.
- Create file — OneDrive — Saves the attachment to `/Invoices/@{formatDateTime(utcNow(), 'yyyy-MM')}/` using the attachment name and content bytes. The monthly subfolder keeps the archive easy to browse.
- Compose — Extract invoice details — Parses vendor name (from sender), invoice number (regex or AI Builder), amount, and due date from the email body into a single Compose output for downstream steps.
- Create item — SharePoint Invoice Tracker — Logs Vendor, Invoice #, Amount, Due Date, Status (`Received`), and the OneDrive file path into the Invoice Tracker list so finance has a single source of truth.
- Condition — Amount > 5000 — Branches on the parsed amount: high-value invoices are routed for approval, lower-value invoices are auto-approved. The threshold should be promoted to an env var.
- Start and wait for an approval (if amount > 5000) — Routes the invoice to the Finance Director for approval. The flow waits for the response before continuing.
- Update item — auto-approve (if amount <= 5000) — Updates the SharePoint row Status to `Approved` without human intervention.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_InvoiceSubjectKeyword | String | invoice | Subject substring the trigger filters on. Lower-case. |
| flowlibs_InvoiceArchiveRoot | String | /Invoices | OneDrive root path under which monthly invoice subfolders are created. |
| flowlibs_InvoiceTrackerListName | String | Invoice Tracker | Display name of the SharePoint list that logs each invoice row. |
| flowlibs_InvoiceTrackerSiteUrl | String | <configure> | Full SharePoint site URL hosting the Invoice Tracker list (e.g. https://your-tenant.sharepoint.com/sites/Finance). |
| flowlibs_HighValueThreshold | Number | 5000 | Invoices with amount greater than this value are routed for Finance approval. All others auto-approve. |
| flowlibs_FinanceApproverEmail | String | <configure> | UPN of the Finance Director (or distribution list) who approves high-value invoices. |
| flowlibs_APNotifyEmail | String | alerts@yourcompany.com | Mailbox or distribution list notified after each invoice is logged. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Office 365 Outlook | shared_office365 | OnNewEmailV3 (trigger) SendEmailV2 |
| OneDrive for Business | shared_onedriveforbusiness | CreateFile |
| SharePoint | shared_sharepointonline | PostItem PatchFileItem |
| Approvals | shared_approvals | StartAndWaitForAnApproval |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Promote thresholds and recipients to env vars
- Move the subject keyword, OneDrive archive root, SharePoint list name, high-value threshold, approver email, and AP notification email to the environment variables shipped with the solution so the flow can be retargeted per environment without editing actions.
- Use AI Builder for field extraction
- Replace the Compose-based regex extraction with an AI Builder Invoice Processing model for more reliable vendor / invoice-number / amount / due-date extraction, especially when invoice formats vary across vendors.
- Add duplicate detection
- Before creating the SharePoint item, query the Invoice Tracker list by invoice number and short-circuit (or flag) duplicates so the same invoice is not logged twice when vendors re-send.
- Weekly outstanding-invoice summary
- Add a sibling scheduled flow that runs weekly, queries the Invoice Tracker for items still in Received or Approved status, and emails a digest to Finance.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01PDF attachment check
Used inside the Apply to each loop to keep only PDF attachments for further processing.
EXPR.02Monthly archive folder
Builds the year-month subfolder (e.g. `2026-05`) under the OneDrive archive root so invoices are grouped by month.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.