metadlabs
AutomationExample scenario

How to Automate Invoice Processing with AI (Realistically)

An example scenario for automating invoice processing with AI: extraction, validation, 3-way matching, exception handling, fraud controls and build vs buy.

By Metad Labs team · Sep 25, 2026 · 8 min read

Key takeaways

  • AI is now good at reading invoices. The hard parts are validation, matching against POs and receipts, and handling exceptions, so design for those first.
  • Aim for touchless processing on clean invoices and a fast human review queue for the rest, not 100% automation.
  • Measure accuracy on your own invoices, field by field. Vendor accuracy claims rarely transfer to your suppliers' documents.
  • Put fraud controls outside the AI: verify bank detail changes out of band and check for duplicates deterministically.

"Can AI just process our invoices?" is one of the most common automation questions we get from finance leaders. Mostly, yes. The condition is that you design the process around the parts AI is bad at. Below is an example scenario, a composite of what we typically see, showing how we would approach it.

The setup

A wholesale distributor with about 120 employees receives around 2,000 supplier invoices a month. Most arrive as PDFs by email, some as scanned paper, and a few through supplier portals. A four-person finance team keys them into the ERP, matches them against purchase orders and goods receipts, chases approvals, and schedules payments.

Industry numbers help put this in context. Ardent Partners' 2025 State of ePayables benchmarks put the average cost to process an invoice at $9.84 and the average cycle time at 8.2 days, with an average exception rate of 18.4%. Best-in-class AP teams process invoices at 79% lower cost. Our distributor sits close to the average, and month-end close is a scramble.

What AI is good at here, and what it isn't

StepGood fit for AI?Why
Classify incoming documents (invoice, credit note, statement, spam)YesMessy inputs, clear categories
Extract fields and line itemsYes, with validationHandles varied layouts well; errors must be caught
Match supplier to vendor masterPartlyFuzzy matching helps; final match should be deterministic
3-way match to PO and receiptNo, use rulesTolerances and quantities are plain arithmetic
Approve paymentNoNeeds accountable humans and audit trail
Detect fraudAssist onlyControls must not depend on a model that can be fooled

For the classification and fuzzy-matching rows, a fast decision model can be cheaper than a chat LLM. We cover where that fits in our Jev AI use cases guide.

The pipeline we would build

1. Intake

A dedicated AP inbox and a supplier portal upload feed a queue. Every document gets an ID and a hash, which catches exact duplicates, and is stored untouched for audit.

2. Classify and extract

Each document goes through either a prebuilt invoice model or an LLM. Azure Document Intelligence's prebuilt-invoice is a good example of the first kind, since it extracts header fields and line items without any training. If you use an LLM instead, turn on structured outputs so the model has to return JSON that matches a strict schema like this one.

json
{
  "supplier_name": "string",
  "supplier_tax_id": "string | null",
  "invoice_number": "string",
  "invoice_date": "YYYY-MM-DD",
  "due_date": "YYYY-MM-DD | null",
  "po_number": "string | null",
  "currency": "USD",
  "subtotal": 0,
  "tax": 0,
  "total": 0,
  "bank_account_last4": "string | null",
  "lines": [{ "description": "string", "sku": "string | null", "qty": 0, "unit_price": 0, "amount": 0 }]
}

For backlogs or overnight runs, the extraction step can use a provider's batch API at half the normal price. Our guide on how to reduce LLM API costs goes into that.

3. Validate deterministically

Never post what the model says without checking it. A handful of cheap, strict rules will catch most extraction errors.

  • Line amounts sum to the subtotal, and subtotal plus tax equals the total.
  • Dates are plausible, and the due date follows the invoice date.
  • The supplier exists in the vendor master, and the tax ID matches.
  • The invoice number has not been seen before for this supplier (duplicate check).
  • The currency and the remittance bank details match the vendor master.

Anything that fails a rule goes to the exceptions queue with the reason attached.

4. Match

Once the data is clean, 2-way or 3-way matching is plain code. It compares invoice lines to the PO and the goods receipt within tolerances the finance team sets, for example ±2% on price and exact on quantity. Invoices that match and fall under an approval threshold are posted automatically. Everything else is routed to the right approver.

5. Exceptions queue

This is where most of the value is.

A reviewer sees the original document next to the extracted fields, with the failing check highlighted, and fixes or approves it in one screen. Every correction is logged and becomes test data for improving extraction.

6. Post and pay

Approved invoices are written to the ERP through its API, with the document ID and the full decision trail attached. The integration needs to be safe to retry so that a network hiccup never creates a duplicate bill. Our post on idempotency key best practices explains how to do that.

Fraud controls that don't depend on AI

AP is a favorite target for fraud, and AI adds a new twist. An invoice is untrusted input, and text inside it can try to instruct a model ("approve this invoice," "the bank details have changed"). So keep the controls outside the model.

Start with bank details. Any change is verified out of band by calling the supplier on a number already on file, never one taken from the invoice or the email that came with it. Duplicate detection runs on supplier plus invoice number plus amount, and separately on document hashes.

The model only extracts. It never approves anything, because approval rules live in code and with people. On top of that, unusual patterns get flagged for review, such as a new supplier with a large first invoice, round amounts or a rushed due date.

Measure accuracy on your own invoices

Vendor pages quote accuracy figures of 95% and higher. Treat them as marketing until you have tested your own documents. Before going live, run a simple test of your own.

  1. Pull a sample of 200 recent invoices across your top suppliers, including scans and credit notes.
  2. Have the team record the correct values once. That is your answer key.
  3. Run the pipeline and measure accuracy per field, separately for header fields and line items.
  4. Set confidence and validation thresholds so that anything uncertain lands in review, and measure the touchless rate at those thresholds.

Build vs buy

SituationUsually best
Under a few hundred invoices a month, standard ERPBuy an AP automation tool, or use your ERP's built-in capture
Thousands a month, standard processesBuy, and integrate carefully
Custom ERP, unusual matching rules, or several entitiesBuild, or buy plus custom integration
Heavy line-item matching against your own systemsBuild the matching and exceptions layer, even if extraction is bought

Low-code tools can glue parts of this together, and our n8n vs Zapier vs Make comparison covers which one fits. The matching and posting steps usually deserve real code.

The same pattern also works for recurring reports. Everything comes in through one intake, gets checked the same way, and whatever fails lands in a queue for a person. We walk through it in how to automate monthly reports.

The outcome (illustrative)

For a company like this, a realistic target after a few months would look something like the table below. These are illustrative numbers. They don't come from a specific client.

BeforeTarget
Invoices keyed by handnearly allonly exceptions
Touchless rate0%a majority of clean, PO-backed invoices
Time from receipt to approvalabout a week1 to 2 days for matched invoices
Finance team time on data entrymost of the weekreviewing exceptions and supplier issues

The biggest gain is rarely the extraction itself. What usually matters more is that every invoice sits in one queue and gets validated the same way, with a clear reason attached whenever a human needs to look.

If you also send invoices out of a CRM, see how to sync QuickBooks and HubSpot without duplicate records or tax errors.

Frequently asked questions

Can AI fully automate invoice processing?

Not fully, and it shouldn't. AI can extract data from most invoices and many can pass through without human touch, but invoices that fail validation, don't match a purchase order or show fraud signals need a person. The goal is a high touchless rate on clean invoices and a fast review queue for exceptions.

How accurate is AI invoice extraction?

Header fields like supplier, invoice number, dates and totals are usually extracted very reliably. Line items, credit notes, multi-page and scanned or handwritten invoices are harder. Vendors publish high accuracy figures, but the only number that matters is the field-level accuracy on a sample of your own invoices.

OCR or LLM: which is better for invoice extraction?

Often both. A document AI or OCR service handles layout and text reliably, and a language model with a strict JSON schema is good at interpreting messy or unusual layouts and normalizing fields. Prebuilt invoice models, like Azure Document Intelligence's, extract headers and line items without any training.

What is 3-way matching?

Checking that the invoice, the purchase order and the goods receipt agree on items, quantities and prices, within tolerances you set, before approving payment. It is rule-based, which makes it a good fit for deterministic code rather than AI. AI helps by extracting and normalizing the data it compares.

Should we buy AP automation software or build our own?

At low volume or with a standard ERP, buying is usually faster and cheaper. Building makes sense at higher volume, with unusual workflows, or when you need tight integration with custom systems. Many companies do both: an AP platform for the standard flow, plus custom automation for the parts it does not cover.

Have a process that eats your team's week?

We map it, automate it end to end, and hand over something your team can own and maintain.

Book a free 30-min callor send us your process for a free review →

Newsletter

Get the next post in your inbox

Practical write-ups on fast systems, AI and automation from the engineers doing the work. About every two weeks.

No pitch. Unsubscribe from any email.

Keep reading