Skip to content
Visual explainer 3h 30m to learn 5 steps

Extract and reconcile invoice fields with an n8n workflow

Extract fields from synthetic invoices or forms, reconcile totals and route draft records to a mock review queue.

By Invicly Tech, , in n8n, AI Automation and Voice Agents. About 7 minutes to read.

Topic 14 of 43

In short

Document processing turns messy text, such as an invoice, into named fields like supplier, date and total. n8n's Information Extractor node does the extraction. Your workflow then checks the result with plain arithmetic and sends only draft records to a review queue.

Think of it like this: The model fills in a form from a photocopy. A clerk adds up the lines before anyone signs.

Explained simply

Many businesses receive invoices as PDFs or emails. Someone reads each one and types supplier, date and total into a system. That is slow and error-prone. A model can read the text and fill in those fields for you.

In n8n, the Information Extractor node does this. You tell it the fields you want, such as invoice number, date, line items and total. You can describe them with attributes, a JSON example or a JSON schema. It returns the values as structured data.

Do not trust the answer straight away. The model can misread a digit or skip a line. So your workflow checks the result: add up the line items yourself and compare with the stated total. If they differ, or a field is missing, mark the record as needing attention.

The result goes into a review queue as a draft, for example a row in an n8n data table with a status. A person looks at the drafts and approves them. Nothing reaches your real accounting system until then.

Press Play on a diagram to walk through it one step at a time.

FlowFrom invoice text to a reviewed draft
  1. 1
    Synthetic invoice

    Text from a made-up supplier

  2. 2
    Information Extractor

    Fields defined by a schema

  3. 3
    Reconcile

    Do the lines add up to the total?

  4. 4
    Flag gaps

    Missing or mismatched fields

  5. 5
    Draft in review queue

    A data table row, not a final record

LayersWhat each layer is responsible for
  1. 1
    Model

    Reads text, proposes field values

  2. 2
    Workflow checks

    Types, required fields, arithmetic

  3. 3
    Review queue

    A person confirms or edits

  4. 4
    Downstream system

    Receives only approved records

In depth

Define the fields before you extract

Write down each field with a type, a short description and whether it is required. Supplier name is text and required. Invoice date is a date. Line items are a list with description, quantity and unit price. Total is a number. Clear descriptions help the model, and a schema gives your workflow a shape to check. Use synthetic invoices from made-up companies such as Fabrikam and Contoso so no real data is involved.

  • Name, type and required flag per field
  • Dates in one format, such as 2026-03-05
  • Money as numbers, not text with symbols
  • Currency as a separate field

Reconcile and record what is missing

Reconciliation means checking two sources of the same number agree. Multiply quantity by unit price for each line, add them up, add tax if the invoice shows it, and compare with the total. Use a small tolerance, or work in whole cents, because decimals can differ by tiny amounts. If a required field is empty, write a reason such as missing invoice date. Do not fill in a guess. The reason helps the reviewer and later shows which fields fail most often.

FlowDecision after extraction
  1. Step 1
    Fields present?

    Required ones all filled

  2. Step 2
    Totals agree?

    Lines plus tax equal total

  3. Step 3
    Both yes

    Draft, status ready_for_review

  4. Step 4
    Any no

    Draft, status needs_attention with reasons

Queue drafts, never final records

Write each result to a data table or a database table with a status. The reviewer sees the extracted values next to the source text and can fix them. Only approved rows move on. This pattern is the same one you will use in the approvals module: a proposal first, an action later. Keep the original text and the model output so you can see afterwards where errors came from.

  • Status: ready_for_review or needs_attention
  • Store source text, extracted fields and reasons
  • Reviewer edits create the final version

Learn it in 5 short steps

About 40m each. Track them with a timer in your plan.

  1. 1
    Define the fields to extract~40m
  2. 2
    Run the Information Extractor~40m
  3. 3
    Reconcile line items with totals~40m
  4. 4
    Record missing inputs~40m
  5. 5
    Queue drafts for review~40m

Key points

  • Define the fields first: name, type and whether each is required.
  • Never let the model do the sums. Add up line items in a Code or Edit Fields node and compare to the stated total.
  • Record missing inputs as a clear reason, not an empty value.
  • Write drafts to a review queue, for example an n8n data table, and let a person approve them.

Key terms

Tap a card to flip it. 0/5 known

Examples

javascript
const inv = $input.first().json;
const sum = inv.lines.reduce((t, l) => t + l.qty * l.unitPrice, 0);
const ok = Math.abs(sum - inv.total) < 0.01;
return [{ json: { ...inv, computed: sum, reconciled: ok } }];

Code node: compare line items with the stated total

A synthetic invoice that does not add up

Fabrikam Ltd sends an invoice with two lines: 2 x 10.00 and 1 x 15.00. The stated total is 40.00, but the lines add up to 35.00. The check flags the mismatch, the draft gets needs_attention with reason total mismatch, and the reviewer finds a third line the model missed.

Checking with integer cents

Convert money to whole cents before comparing, so rounding never causes a false alarm.

javascript
const d = $input.first().json;
const cents = n => Math.round(n * 100);
const sum = d.lines.reduce((t, l) => t + l.qty * cents(l.unitPrice), 0);
const reasons = [];
if (!d.invoiceNumber) reasons.push('missing invoice number');
if (sum !== cents(d.total)) reasons.push('total mismatch');
return [{ json: { ...d, status: reasons.length ? 'needs_attention' : 'ready_for_review', reasons } }];

Quick reference

  • Information Extractor: define fields by attributes, JSON example or JSON schema
  • Always compute totals yourself, never trust the model's maths
  • Missing field: record a reason, do not guess a value
  • Compare money in whole cents
  • Drafts go to a review queue first, such as an n8n data table

Common mistakes

  • Letting a missing field default to zero, which hides a gap.
  • Comparing money as floating-point numbers without a tolerance or whole cents.
  • Writing straight to the accounting system instead of a draft queue.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Where should line items be added up?

Question 2

2What should happen if the invoice date is missing?

Question 3

3Why keep the source text with the draft?

Question 4

4Which is the safest destination for model output?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    List the fields for a simple invoice with a type and required flag each.

  2. Exercise 2medium

    Write a Code node that flags a record when the line items do not match the total.

  3. Exercise 3hard

    Build the workflow: Manual Trigger with 5 synthetic invoices, Information Extractor, Code check, then a data table insert with status and reasons. Include one broken invoice.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Can n8n read PDFs?
n8n can extract text from PDF files with the Extract from File node. Scanned PDFs without a text layer need an OCR step first.
What if the model returns a wrong number?
Your checks and the review queue are there for this. Treat every extraction as a proposal.
Can I use real invoices to learn?
Use synthetic ones while you build. Real documents carry privacy and contract duties.

Go deeper

ShareXLinkedInWhatsApp