Skip to content
AgeDash

Guide · Finance

How to automatically extract invoice data from email into Google Sheets

By Dev Patel, founder of AgeDash. Published . 7 minute read.

To extract invoice data from email into Google Sheets automatically, you watch an inbox for new mail, pick out the invoice attachments, have an AI model read the fields, check the numbers in code, and append one row per invoice to your sheet. The reading is the easy part now. The checks and the review step decide whether you can trust the sheet at month-end.

The pieces of an invoice workflow

StepWhat it doesTypical tool
Watch the inboxPicks up each new mail in a chosen label or folderGmail, Outlook or IMAP node in n8n
Pick attachmentsKeeps PDFs and images that look like invoices, skips logos and signaturesRules on file type, size and name
Read the invoicePulls vendor, GSTIN, number, date, lines, tax and totalAn AI model that accepts PDFs and images
CheckTotals add up, number not seen before, dates sensiblePlain code
FileSaves the file in a month and vendor folderGoogle Drive, OneDrive, Dropbox or SharePoint
RecordAppends a row with a statusGoogle Sheets, Excel 365 or Airtable
NotifyTells a person about anything that needs reviewSlack, email or WhatsApp

You can play with all seven steps in the invoice processing demo, including an invoice whose total does not match its lines.

Step 1: give invoices their own path into the inbox

Do not watch your whole inbox. Use a dedicated address such as accounts@, or a Gmail filter that labels mail with invoices, and watch only that label. It cuts noise, and it means a newsletter with a PDF is never entered as a bill. Keep a rule for forwards, because staff will forward invoices they receive personally.

Step 2: pick the right attachments

A single vendor mail can contain the invoice, a delivery note, the company logo and a signature image. Simple rules remove most noise: keep PDFs and photos above a minimum size, skip inline images, and skip files whose names suggest a delivery challan or a quote. When a mail has two invoices, treat each as its own record. Many setups wrongly merge them into one row.

Step 3: read the invoice with an AI model

Modern models from OpenAI, Anthropic and Google can read PDFs and phone photos directly, which handles most layouts without building a template per vendor. Ask for a fixed structure, such as JSON with named fields, and include the fields you need for your books:

  • Vendor name and GSTIN (or VAT number).
  • Invoice number and invoice date.
  • Each line: description, quantity, rate, amount.
  • Subtotal, tax rate and tax amount. For GST, CGST, SGST and IGST separately if your accountant needs them.
  • Total, currency, and due date if printed.

Tell the model to leave a field empty when it cannot read it, rather than guess. An empty field is easy to catch; a confident wrong number is not.

Step 4: check the numbers in code

This is the step that makes the sheet trustworthy, and the one most tutorials leave out. A model can misread a 3 as an 8 on a crumpled photo. Plain code catches it:

  1. Sum of the lines equals the subtotal, within a rupee or so for rounding.
  2. Subtotal plus tax equals the total.
  3. Tax amount matches the tax rate applied to the subtotal.
  4. The GSTIN has the right length and format.
  5. The invoice date is not in the future and not unreasonably old.
  6. The same vendor and invoice number are not already in the sheet.

Any failed check sets the status to Needs review instead of Ready to pay. The row is still added, so nothing goes missing, but nobody pays it until a person looks.

Step 5: file the original

Save every original in a predictable place, such as Invoices / 2026-11 / Vendor name, and rename it to date plus invoice number. Put the file link in the row. At audit time, the sheet and the folder tell the same story.

Step 6: append the row

Append, never overwrite. Use one row per invoice with a status column (Ready to pay, Needs review, Paid, Duplicate) and the link to the file. Keep a hidden column with the source mail ID, so the same mail processed twice can be detected.

Step 7: the review loop

Send flagged invoices to one named person with the reason and both links. When they correct a value, update the row and set the status. Over a few weeks, the reasons tell you where the workflow needs a rule, for example a vendor who always prints the total before discount.

Gotchas that show up in the first month

  • Password-protected PDFs. Some vendors send them. Route these straight to review, or store the password per vendor if your policy allows.
  • Credit notes. They look like invoices with negative totals. Detect the words "credit note" and record them separately.
  • Scanned multi-page invoices. Make sure all pages are sent to the model, not just the first.
  • Currency. Foreign invoices need the currency field, or totals in your sheet get mixed.
  • Sheet limits. Google Sheets has a cell limit per spreadsheet. Start a new sheet each year, or move to a database when volumes grow.

Doing it yourself vs having it built

n8n has built-in nodes for Gmail, Outlook, Google Drive, Google Sheets and the major AI models, so a basic version is within reach of a technical person in a few days. The time goes into checks, exceptions and the review loop. If you want it built and run for you, see business process automation.

Common questions

Do I need OCR software to read invoices?

Not separately for most invoices. Current AI models read text in PDFs and photos directly. A dedicated OCR step can still help with very poor scans, but checks in code matter more than the reading tool.

How accurate is AI invoice extraction?

It depends on the quality of your invoices, so measure it on your own. Run a few weeks of real invoices, compare with what a person typed, and look at which fields go wrong. The checks then catch most errors before they reach a payment.

Can it handle invoices sent on WhatsApp?

Yes, if the number is on the WhatsApp Business API. Forwarded PDFs and photos arrive as media files and go through the same steps as email attachments.

Can the data go to my accounting software instead of a sheet?

If your accounting software has an API, yes. A common setup creates a draft bill there and keeps the sheet as the review log.

Try it yourself

Playable demos from the AgeDash library, with fictional data.

Finance and documents

Invoice processing from email to spreadsheet

Invoices that arrive by email are read, checked, filed in the right folder and added to your ledger, and anything that does not add up goes to a person.

Tools: Gmail, Outlook, Custom mailbox (IMAP), WhatsApp Business API, Google Drive, OneDrive, Dropbox, SharePoint, Google Sheets, Excel 365, Airtable, Slack, OpenAI, n8n+9
Try the previewView dashboard

Read next

Want this set up for you?

Book a 30 minute call. We look at how you work today and say plainly what is worth automating.