Skip to content
NEWMeet Alaaddin, your AI genie with a voice. trig8n launches 1 January 2027. See what is new

Library / Finance, Invoices & Accounting

Finance, Invoices & Accounting

Extract invoice data from Gmail PDFs into Google Sheets with OpenAI

Checks Gmail hourly for new emails with PDF invoices, saves each PDF to a dated Google Drive folder, and uses OpenAI to log supplier, invoice number, date, taxes and total as Sheets rows.

What it does

# Extract invoice data from Gmail attachments into Google Sheets Watches your inbox for emails with PDF invoices attached, files each PDF in a dated Google Drive folder, then uses AI to read the company, invoice number, date, taxes and total into a spreadsheet row. Removes the monthly job of opening every supplier email by hand. ### How it works 1. A Gmail trigger checks the inbox every hour with attachments downloaded. A manual trigger is included so you can also backfill a specific date range. 2. Emails from senders you do not want are skipped, then a Code node pulls out only the PDF attachments. 3. The current month's folder is found in Drive and each PDF is processed one at a time: uploaded, downloaded back, and given a view link and folder link. 4. The PDF text is extracted and an AI agent returns the invoice fields as strict JSON, with an auto-fixing parser retrying if the format is wrong. 5. Rows that contain a tax value are appended to a monthly tab in your sheet. Rows without one are skipped, and either way the loop moves to the next PDF. ### Setup 1. Connect your Gmail, Google Drive and Google Sheets accounts, and add your OpenAI API key to both model nodes. 2. On Skip unwanted senders, replace the example address with any sender you want to ignore, or disable the node. 3. In Drive, create folders named by month such as 2026-04, and select the parent folder on the Find this month folder node. 4. Point the sheet node at your own spreadsheet. A tab is written per month. ### Customization Edit the agent prompt and output parser to capture extra invoice fields.

The steps

  1. Chat model - Extraction
  2. Combine file and links
  3. Read text from the PDF
  4. Auto-fixing Output Parser
  5. Output Parser - Invoice fields
  6. Chat model - Parser auto-fix
  7. Build Drive links
  8. Upload PDF to Drive
  9. Download PDF back
  10. Skip unwanted senders
  11. Pull PDF attachments out
  12. Combine PDFs and folder
  13. Any tax found?
  14. Extract invoice fields with AI

22 steps in total.

Similar automations