Skip to content
50% OFF your plan for a limited timeUse code
N8Nitro
Back to blog
Guides & Tutorials·9 min read

Automate Invoices with n8n: From Email to Accounting

Turn invoices that land in your inbox into clean, checked records in your spreadsheet or accounting tool, with AI extraction, validation and a human approval step.

Invoices arrive as PDFs in an inbox. Someone opens each one, reads the vendor, the number, the date and the total, types them into a spreadsheet or accounting tool, then files the PDF somewhere. It’s slow, it’s boring, and typos in this kind of data are expensive.

This guide shows how to automate that flow in n8n: read the email, pull out the key fields with AI, check them, ask a person when something looks off, and record the result. You’ll also see where this goes wrong, so you can trust it.

What you’ll build

A workflow that, for every invoice email:

  1. Grabs the PDF attachment.
  2. Extracts the vendor, invoice number, dates, currency, tax and total.
  3. Checks the numbers and looks for duplicates.
  4. Sends anything unusual to a person for approval.
  5. Records the invoice in Google Sheets or your accounting tool.
  6. Files the PDF in a folder with a consistent name.

It doesn’t pay invoices. Payment stays with a human, always.

How it works

Email with     Read the     Extract      Check:          Record in
PDF invoice →  PDF       →  fields    →  totals add up?→ Sheets / QuickBooks / Xero
                            (AI)         duplicate?      + file the PDF in Drive
                                          │
                                          └→ looks wrong or large? → ask a person on Slack/email

Step-by-step build

1. Trigger on new invoice emails

Use the Gmail Trigger (or the generic email trigger for other providers). To keep noise out, filter on something reliable: a label like “Invoices”, a dedicated address such as invoices@yourcompany.com, or “has attachment”.

A dedicated inbox is the cleanest option. Ask vendors to send invoices there and the filter becomes trivial.

2. Get the PDF

Make sure the trigger downloads attachments, then keep only the PDFs. If an email has no PDF, route it to a “needs a look” path instead of silently dropping it.

3. Turn the PDF into text

Add an Extract From File step to read the text from the PDF. This works for digital PDFs (the kind generated by accounting software).

Scanned invoices and photos have no real text inside. For those you need OCR, or an AI model that can read images directly. Decide early which kind you get, because it changes how you build this step.

4. Extract the fields with AI

Send the text to an AI model and ask for a fixed set of fields. Fixed fields are the key: you want the same shape every time so the rest of the workflow can rely on it.

Field Example
Vendor ACME Supplies Ltd
Invoice number INV-2041
Invoice date 2026-10-03
Due date 2026-11-02
Currency USD
Subtotal 1,000.00
Tax 140.00
Total 1,140.00

A prompt you can adapt:

You extract data from invoices. Return ONLY the fields below as JSON.
If a field is missing or unclear, return null. Never guess.
Dates must be YYYY-MM-DD. Amounts must be plain numbers without currency symbols.

Fields: vendor, invoice_number, invoice_date, due_date, currency, subtotal, tax, total

The two rules that matter most are “return null instead of guessing” and “plain numbers, standard dates”. They prevent most downstream headaches. In n8n you can use the Information Extractor node or an AI Agent with a structured output to enforce the shape.

5. Validate before you trust

AI reads documents well, but not perfectly. Add cheap checks right after extraction:

  • Required fields. Vendor, number and total must exist.
  • The math. Subtotal plus tax should equal the total (allow a cent of rounding).
  • Reasonable dates. The due date shouldn’t be before the invoice date.
  • Duplicates. Look up vendor plus invoice number in your records. If it exists, stop and flag it.

Anything that fails goes to the review path. Anything that passes continues.

6. Route by risk

Not every invoice deserves the same attention. A simple rule works well:

  • Small, known vendor, all checks pass: record it automatically.
  • Large amount, new vendor, or any failed check: send a message to a person with the extracted fields and the PDF, and wait for approval.

Use a Slack or email message with approve and reject links, or a quick form. Set the amount threshold to something your finance lead is comfortable with.

7. Record it

Write the validated invoice to where your team works:

  • Google Sheets or Airtable for a simple ledger.
  • QuickBooks or Xero if you want it in the books.

Start with a spreadsheet. It’s easy to inspect, and you can connect accounting software after you trust the extraction.

8. File the PDF

Upload the PDF to Google Drive (or your storage of choice) with a predictable name, for example 2026-10-03_ACME-Supplies_INV-2041.pdf. Add the file link to the spreadsheet row, so anyone can jump from a record to the source document.

9. Handle failures on purpose

Add a failure branch for the unexpected: unreadable PDFs, an AI error, a rate limit. Send those to a “review queue” (a sheet or a Slack channel) instead of letting them disappear. A missed invoice is worse than a slow one.

Making it safe

  • Test with real invoices first. Run 20 to 30 past invoices through the workflow and compare the extracted fields with the originals. Fix the prompt until errors are rare.
  • Never automate payment. Recording is low risk. Paying is not.
  • Keep an audit trail. Store the original PDF and the extracted values together.
  • Mind your data. Invoices contain bank details and customer information. Use an AI provider whose data terms you’ve reviewed, and avoid sending more than you need.
  • Spot-check regularly. Review a small random sample every month.

Common problems and fixes

Problem Likely cause Fix
Totals don’t match The AI read a subtotal as the total Add the math check; clarify the prompt
Blank text from a PDF It’s a scan or photo Add OCR or use an image-capable model
The same invoice is recorded twice No duplicate check Look up vendor plus number before writing
Dates come out wrong Mixed formats (DD/MM vs MM/DD) Ask for YYYY-MM-DD and set the locale if you know it
Odd currency symbols or commas Free-form amounts Ask for plain numbers; normalise in a Set node
Emails with several invoices One PDF per email assumed Loop over attachments

When to use this, and when not to

Great for:

  • A steady stream of vendor invoices in a similar format.
  • Small finance teams buried in data entry.
  • Getting invoice data into a spreadsheet for analysis.

Be careful or skip it when:

  • Invoices are handwritten or low-quality photos, unless you add strong OCR and review.
  • You have very few invoices a month. Manual entry may be fine.
  • Your accounting tool already has solid built-in inbox capture and you’re happy with it.

Next steps

  1. Create a dedicated invoices inbox and forward 20 sample invoices to it.
  2. Build up to step 5 and write results to a Google Sheet only.
  3. Review the output, tune the prompt, then add approvals and your accounting tool.

Want a head start? Describe it in AI to Workflow and import the draft into your Nitro:

When an email with a PDF attachment arrives in the Invoices label, extract vendor,
invoice number, invoice date, due date, currency, subtotal, tax and total with AI.
If subtotal plus tax doesn't equal the total, or the invoice number already exists
in my Google Sheet, post it to #finance on Slack. Otherwise add a row to the sheet
and save the PDF to Google Drive.

New to n8n hosting? Start a Nitro and have the first version running this afternoon.

Frequently asked questions

Does invoice automation work with scanned invoices?

Scanned invoices and photos contain no real text, so you need OCR or an AI model that can read images. Digital PDFs can be read directly.

How accurate is AI invoice extraction?

It is good but not perfect. Add checks (required fields, subtotal plus tax equals total, duplicate detection) and test 20 to 30 real invoices before trusting it.

Can n8n pay invoices automatically?

It can, but you should not. Recording invoices is low risk; payments should stay with a person.

Is it safe to send invoices to an AI provider?

Invoices contain bank and customer details. Use a provider whose data terms you have reviewed and send only what you need.

Where can the extracted data go?

Google Sheets or Airtable for a simple ledger, or QuickBooks and Xero for accounting. Start with a spreadsheet.

How do I avoid duplicate invoices?

Look up vendor plus invoice number in your records before writing. If it exists, stop and flag it.

Ready to launch your first Nitro?

No hidden fees · 14-day money-back guarantee · 24/7 support