Pull invoice details out of emails and PDFs, with a human check on anything risky
Starts when an invoice arrives by email or as a PDF. Ends with clean invoices approved and anything risky waiting in a review queue for a person.
Bring the step you are stuck on: 30 minutes, a straight answer and the next step. If you would rather have it built, a reply within 5 working days.
The route
7 steps: 4 rule steps, 1 AI step and 1 person step
Copy, share, discuss
- Copy
Available once this workflow passes its checks.
- Share
todkett.com/automations/finance/invoice-data-extraction/
- Discuss
Opens when the first workflow passes its checks. No GitHub account? Ask about this by form.
How the library, the tracks and the talk work: the community page.
At a glance
- Starts when
- New emails with invoice attachments, or a manual run with sample documents.
- Input
- Invoice documents arrive from an inbox or a test batch.
- Output
- Clean invoices approved and anything risky waiting in a review queue for a person.
- AI
- Uses AIField extraction only, at temperature 0 with a fixed schema.
- Rule checks
- 8 checks around the AI
- Tools
- Gmail or a document inbox, OpenRouter, n8n data tables
- Last stress test
- No recorded run yet
01Steps
The steps
7 steps: 4 rule steps, 1 AI step and 1 person step. There is no finance team, so invoices get typed in on Sunday. Vendor, number, dates and totals are retyped from every invoice, and duplicates or wrong totals slip into the books.
01Trigger
Invoices arrive
Invoice documents arrive from an inbox or a test batch.
02Rule step
Fingerprint, drop duplicates
Fingerprint each document; drop duplicates and anything already processed.
03AI step
AI extracts the fields
AI extracts vendor, number, dates, currency, subtotal, tax and total into a fixed format.
04Rule step
Check math, text and dates
Rules check the math, that the total and invoice number appear in the document, the dates and the confidence.
05Rule step
Flag hidden instructions
Flag documents that contain instructions aimed at AI.
06Rule step
Approve or queue
Approve clean invoices; queue the rest with the reason.
07Person step
A person reviews the queue
A person reviews every invoice in the queue.
EndOutput
Approved or waiting in review
Clean invoices approved and anything risky waiting in a review queue for a person.
Approved invoices
02Where AI is used
Where AI is used, and what stays with you
AI reads, judges or drafts. Fixed rules check, decide and route. A person approves anything that goes out.
AI step
Step 03Field extraction only, at temperature 0 with a fixed schema.
Invoices vary too much for templates. Every decision after extraction is code.
What the model reads
- The text of each new invoice, once: duplicates are skipped by fingerprint first.
- A fixed list of fields to fill in, at temperature 0.
What it never sees or decides
- Whether an invoice is approved: rules check the math, the text and the dates.
- Its own pass mark: code asks for a confidence of at least 0.8.
- Money: nothing is paid.
Model calls: 1 model call per invoice. Duplicates are skipped before the AI step, so they cost nothing.
Fixed rules
They check, decide and route. 4 rule steps.
- 02Fingerprint, drop duplicates
- 04Check math, text and dates
- 05Flag hidden instructions
- 06Approve or queue
A person
- 07A person reviews every invoice in the queue.
03Checks
Checks around the AI
What runs before the model, and what checks its answer after, in plain words. Build these into your version too.
- 01A SHA-256 fingerprint skips documents already processed, so the model is never paid twice.
- 02Required fields must be present.
- 03Subtotal plus tax must equal the total within 0.5%.
- 04The total and the invoice number must appear in the document text.
- 05The invoice date must be no more than 2 years old and no more than 30 days in the future.
- 06Model confidence must be at least 0.8.
- 07A pattern check flags prompt-injection attempts.
- 08The result count must match the document count, or the run stops.
04The 8 checks
Stress test
The 8 checks we run on every workflow, and you can run too. A check marked Not needed says why.
- Status
- Not yet0 of 8 that apply have a recorded pass
- Last run
- No recorded run yet
- Model review
- Still open
Checks marked Not yet are still open. 4 of them were seen in the workflow design on 23 Oct 2026; a check shows Passed only once its test run is recorded.
ST2Prompt attack
Status: Not yet
Seen in the workflow design on 23 Oct 2026. The recorded test run is still open.
ST3Run twice
Status: Not yet
Seen in the workflow design on 23 Oct 2026. The recorded test run is still open.
ST7Human sign-off
Status: Not yet
Seen in the workflow design on 23 Oct 2026. The recorded test run is still open.
ST8Rules around the AI
Status: Not yet
Seen in the workflow design on 23 Oct 2026. The recorded test run is still open.
0 passed · 0 not needed · 8 not yet
What we testWe show what we tested, never the test data. The example below is made up.
05Test replay
How to test it
Before you trust a workflow, try to break it. The sample record runs the route step by step. Each break test below gets its own replay once its recorded run exists.
- Record
- INV-1043
- Data
- Sample run, made-up data
01Invoices arrive
In Fernway's billing inbox with four others
Done02Fingerprint, drop duplicates
New fingerprint: not a duplicate
Done03AI extracts the fields
Vendor, number, dates, currency and totals extracted
Done04Check math, text and dates
Subtotal plus tax equals the total; total and number found
Done05Flag hidden instructions
No instructions aimed at AI
Done06Approve or queue
Every check passed: approved
Done07A person reviews the queue
Clean invoice: not queued for review
SkippedEndApproved or waiting in review
Approved for the next step; nothing paid
Approved invoicesArrived
INV-1043 reached the last station: Approved invoices. Approved for the next step; nothing paid.
Sample run on made-up data. No stress-test run is recorded yet, so this plays the example, not a test. Nothing runs live.
The break tests for this workflow
- ST3Not yet
Same input sent twice
Seen in the workflow design. No recorded run to replay yet.
- ST2Not yet
Instructions hidden in the input
Seen in the workflow design. No recorded run to replay yet.
- ST4Not yet
A connected service fails
No recorded run to replay yet.
- ST8Not yet
The AI returns a broken answer
Seen in the workflow design. No recorded run to replay yet.
06Example
The example, in and out
Made-up data, written to show the steps; no recorded run stands behind it yet. Fernway is a made-up small software company, and its address ends in .example, so it cannot belong to a real business.
InputExample
Example on made-up data: 5 made-up invoices sent to Fernway's billing inbox, one of them sent twice.
OutputExample
The duplicate is skipped before AI by its fingerprint. One clean invoice is approved: the subtotal plus tax equals the total, and the total and invoice number appear in the text. Three go to a person: one is missing its total, one has totals that do not add up, and one holds instructions aimed at AI.
Test run result
Test run with 5 sample documents: 1 duplicate skipped before AI, 1 auto-approved, 3 sent to review.
A test run on sample documents.
07Limits
When not to automate this
- It never pays an invoice. It reads and checks them.
- Document types other than invoices need their own checks before they go through it.
- With a few invoices a month, typing them in is cheaper than the build.
08What you need
What you need to run it
| Tool | Access |
|---|---|
| Gmail or a document inbox | Read new emails with invoice attachments |
| OpenRouter | One API key with a credit limit, for the extraction step |
| n8n data tables | Store fingerprints, results and the review queue |
- Where it runs
- In n8n, self-hosted or n8n cloud.
- Model calls
- 1 model call per invoice. Duplicates are skipped before the AI step, so they cost nothing.
- Running costs
- Yours, paid to each service directly. Scope in writing first. A quote before any build. No prices on the site yet.
How to adapt it
Changes we have made or tested on this workflow.
- 01Swap the sample documents for a Gmail label or a document inbox, the production trigger.
What changed
- ContentFirst version, written from the 23 Oct 2026 catalog.
09FAQ
Questions people ask about it
Does it pay invoices?
No. It reads and checks them. Clean invoices are approved for the next step, and everything else waits for a person.
How does it avoid processing the same invoice twice?
Each document gets a SHA-256 fingerprint. A document already processed is skipped before any model call.
What checks run after the AI step?
Required fields; subtotal plus tax must equal the total within 0.5%; the total and invoice number must appear in the document; the date must be no more than 2 years old or 30 days ahead; and the model's confidence must be at least 0.8.
What if an invoice contains instructions aimed at AI?
A pattern check flags it and sends it to a person. In the test run, the document with an injection attempt went to review.
10Related
Where to go next
Use cases
Sales
Turn a deal request into a branded proposal PDF and CRM dealAI in one step only: reading pasted deal notes (chat version only)
8 steps
Operations
Turn raw weekly exports into a clean KPI workbook with fact-checked insightsAI in one step only: writing the weekly notes
7 steps
Free tools
Can you automate it?
Stuck on your version of this workflow?
Bring the step that does not work. In 30 minutes you get a straight answer and the next step. If you would rather have it built, tell us your tools and the rules you already follow. Scope in writing first. A quote before any build. No prices on the site yet.