Starbase / 02 RecipeAgents

RecipeAgents / Guides

Agent recipe guide

AI invoice extraction automation

Filter Gmail for invoice PDFs, turn each PDF into text, ask the model for fixed fields as JSON with null for anything missing, check that net plus VAT equals total, and only then append the row. This recipe does that with Zapier and ChatGPT, plus a duplicate check on vendor and invoice number, so your bookkeeping starts from a clean list.

The prompt

Extract from this invoice text: vendor, invoice_number, date, currency, net, VAT, total. Return JSON; null if missing. Text: {{pdf_text}}

Step by step

  1. Trigger: new Gmail email with a PDF attachment (use a search filter like 'invoice OR receipt').
  2. Convert the PDF to text with a PDF parsing step.
  3. Send the text to ChatGPT with the extraction prompt.
  4. Append the fields to a Google Sheet, or create a bill in QuickBooks.
  5. Flag duplicates by checking vendor plus invoice_number before writing.
SPONSOR SLOT · AVAILABLEFeature your product here

What 437 public invoice workflows use

n8n's Invoice Processing category in our study of 13,574 public n8n templates (snapshot 2026-10-20) holds 437 templates. 232 (53.1%) write to Google Sheets and 211 (48.3%) use Gmail, so 'email in, sheet row out' is the standard shape. Only 216 (49.4%) contain an AI step, and 105 (24.0%) use n8n's Extract From File node to read the file. Plenty of invoice automations run without a model at all, which is worth knowing if your invoices come from a handful of suppliers with fixed layouts.

Only 16 of the 437 (3.7%) include an Error Trigger. Most templates you import will fail without telling anyone.

Failure alerts: the step most invoice guides skip

A missed invoice is worse than a misread one, because nobody notices it. In n8n you fix that with an error workflow, per the n8n error-handling docs: create a workflow that starts with the Error Trigger node, then pick it under Error workflow in the invoice workflow's Settings. It runs whenever an execution fails, and one error workflow can cover all your workflows. Have it send you the workflow name and the node that failed.

One detail from the same docs: if the trigger itself fails (for example the Gmail connection expires), the alert arrives with less detail and no execution link. If an alert has no link, check the trigger's credentials first.

Why 'null if missing'

Telling the model to return null for missing fields stops it from guessing. A null VAT field is a clear signal for a human to check; an invented one would silently corrupt your books.

Checks worth adding

Verify that net plus VAT equals total and flag rows where it doesn't. Keep the original PDF link in the sheet so anyone can check a row. Route anything over a set amount to a person for review before it reaches QuickBooks.

Mistakes to avoid

Writing straight into accounting software without a review step in the first weeks.

Relying on text extraction for scanned image PDFs; those need OCR first.

Ignoring currency: store it with every amount.

A sample row, and the check that catches errors

An example of what gets extracted: vendor 'UAB Spausdinimas', invoice 2026-114, 2026-10-02, EUR, net 200.00, VAT 42.00, total 242.00. That's an illustration, not a real invoice. Add one sheet formula that checks net + VAT = total and highlights the row if it doesn't. That single check catches most extraction mistakes, because models tend to misread one number rather than all three.

The full small recipe is at invoice PDFs from email into a sheet. Once that's running, supplier price change alerts build on it.

Build it in Make, Zapier or n8n

The recipe is tool-agnostic. Every step maps to a standard building block: a trigger from the app where the data starts, an AI step that sends text to a model with the prompt, a parser that reads the JSON or text that comes back, and actions in the destination apps. Zapier is the quickest to get running for linear flows. Make makes branching and loops easier to see. n8n can be self-hosted if you want to keep data on your own infrastructure. Pick the one your team already pays for.

Test it before you trust it

Run the recipe on ten to twenty real examples before you switch it on for everything. Put the inputs and outputs side by side in a sheet and mark each one right or wrong. Where it's wrong, add one specific line to the prompt that addresses the pattern, then run the same examples again. Keep a human approval step on any action that is visible to customers or touches money until the error rate is one you'd accept from a new hire.

Watch running costs as well. Each AI step is billed by the model provider and each task or operation by the automation tool. Filtering inputs before the AI step, for example skipping newsletters or tiny files, is the easiest way to keep both down. Check current pricing on each vendor's site, since it changes often.

Before you use it

Every recipe on RecipeAgents follows the same shape: a trigger, the tools, the steps, and the exact prompt. Start with the human-approval version. Once you have watched a few dozen runs and trust the output, decide which steps can run on their own. Model and tool names change often, so check current pricing and features in each tool before you build.

Frequently asked questions

Can ChatGPT read invoices?
It can extract fields from invoice text reliably for common layouts. Always validate totals and keep the original.
Google Sheets or QuickBooks?
Start with Sheets for review. Move to direct QuickBooks bills once the extraction is consistently correct.
What about receipts photographed on a phone?
Those need an OCR step before the extraction prompt.

From our sister sites

More guides

Back to all of RecipeAgents

Newsletter

One small automation every Friday

Each Friday email has one recipe, the prompt for it, and the way it broke when we wrote it up. It's free, and every email has an unsubscribe link.