Extract invoice data to Google Sheets with n8n and AI (free template)
By the TestedFlows team · Published October 16, 2026
This page contains affiliate links. If you sign up through them we may earn a commission, at no extra cost to you. How we make money.
Typing invoice details into a spreadsheet is slow and error-prone. This workflow watches Gmail for emails with PDF invoices, reads the text of each PDF, uses AI to pull out the vendor, invoice number, dates and amounts, and adds a clean row to Google Sheets. Your bookkeeping sheet fills itself.
What you’ll build: invoice email arrives → read the PDF text → AI extracts the fields → row added to Google Sheets. Time: about 20 minutes. You need: n8n (Cloud or self-hosted), a Gmail account, an OpenAI API key and a Google Sheet.
Download the free workflow templateHow the workflow works

- Invoice email arrives checks Gmail every hour for emails that have a PDF attachment and mention an invoice, receipt or bill, and downloads the attachment.
- Read PDF text turns the PDF into plain text.
- Extract invoice fields asks an AI model to find eight fields in that text: vendor, invoice number, invoice date, due date, currency, subtotal, tax and total.
- Prepare invoice row tidies the result and adds the date received and the email subject.
- Add row to Google Sheets writes the row to your sheet.
Step 1: Import the template
Download the template above. In n8n, create a new workflow, open the ⋯ menu, choose Import from File and select the file. Nodes with warnings need your accounts connected in the next steps.
Step 2: Connect Gmail and set the search
Open Invoice email arrives and connect your Google account.

Three settings matter here:
- Simplify is off and Download Attachments is on (under Options). The workflow needs the actual PDF file, which the simplified output does not include.
- Search uses Gmail’s syntax:
has:attachment filename:pdf (invoice OR receipt OR bill). If your suppliers use other words, add them. If invoices arrive at a dedicated address,to:invoices@yourcompany.com has:attachment filename:pdfis more precise. - Poll times is every hour. Invoices are rarely urgent, and hourly checks keep execution usage low.
Tip: the cleanest setup is a Gmail filter that applies an “Invoices” label to supplier emails, with the trigger searching label:invoices has:attachment.
Step 3: Read the PDF
The Read PDF text node uses n8n’s Extract from File operation for PDFs, reading the first attachment (attachment_0). It works for PDFs that contain real text, which covers invoices generated by accounting and billing software.
Scanned paper invoices are images inside a PDF and contain no text, so this step returns nothing for them. For those, send the file to a vision-capable AI model or an OCR service instead; see the ideas at the end.
If emails often carry several PDFs, add a Split Out node after the trigger so each attachment is processed on its own.
Step 4: Connect the AI and review the fields
The Extract invoice fields node is n8n’s Information Extractor. Each field has a name, a type and a description that tells the AI what to look for:

- Click the OpenAI model node and add your OpenAI API key. The template uses
gpt-5-mini. - Review the eight fields. Add any you need, such as
po_number,vat_numberorcategory, each with a clear description. - Keep the system prompt’s rule: “Use only values printed in the document. If a field is not present, leave it empty. Never calculate or guess amounts.” It stops the AI from inventing a due date or adding up totals that are not printed.
Step 5: Connect Google Sheets
- Create a sheet with these headers in the first row:
received,vendor,invoice_number,invoice_date,due_date,currency,subtotal,tax,total,email_subject. - Open Add row to Google Sheets, connect your Google account, and pick the spreadsheet and tab.
Columns are mapped automatically by name, so the headers must match the field names exactly.
Step 6: Test and publish
- Email yourself two sample invoices as PDF attachments, ideally from two different suppliers.
- Open the trigger, click Fetch Test Event, and run the workflow.
- Compare the new rows with the PDFs, field by field. Pay particular attention to the totals and dates.
- When the results are right, click Publish. The workflow now runs every hour.
Review the sheet weekly at first. AI extraction is accurate on clear, text-based invoices, but a person should check amounts before they reach your accounts or payments.
Common problems and fixes
“No binary data found” in Read PDF text. Attachments are not being downloaded. Turn off Simplify and turn on Download Attachments in the trigger.
Empty text from the PDF. The invoice is a scanned image. Use a vision model or OCR for these files.
Dates in the wrong format. Add the format you want to the date fields’ descriptions, for example “Date the invoice was issued, as YYYY-MM-DD”.
The same invoice appears twice. It arrived in two emails. Add a Google Sheets lookup on invoice_number before the final step and skip rows that already exist.
Amounts include currency symbols. Keep the field type as Number so the AI returns plain numbers, and keep currency in its own column.
Ideas to extend it
- Scanned invoices: send the PDF or image to a vision-capable model, or to an OCR service, before the extraction step.
- Save the file: add a Google Drive node to store each PDF in a folder named by vendor and month.
- Accounting: send the extracted data to QuickBooks or Xero with their n8n nodes instead of, or as well as, the sheet.
- Approvals: post invoices over a set amount to Slack for approval before they are logged.
Find more free workflows in the template library, including AI Gmail reply drafts and AI lead qualification.
Try n8n Cloud freeFrequently asked questions
Does this work with invoices in other languages?
Yes. Modern AI models read invoices in most major languages. Keep the field names and descriptions in English and the AI will map the values.
Is it accurate enough for accounting?
It is accurate on clear, text-based invoices, but treat it as data entry, not as approval. Check amounts before paying or filing.
Can I watch a Google Drive folder instead of Gmail?
Yes. Replace the Gmail trigger with a Google Drive trigger for new files in a folder, then add a Google Drive download step before Read PDF text.
How many executions does it use?
On n8n Cloud, each hourly check that finds new invoice emails is one production execution, however many steps run. See n8n pricing explained.
Get the free workflow template pack
Tested n8n workflows you can import in one click, plus a short email when new templates and comparisons go live.