Extract invoice and receipt data from Gmail PDFs to Google Sheets with OpenAI
Ready for 3.0What this workflow does
This AI workflow has 14 nodes and runs on Gmail events. Along the way it connects Gmail, OpenAI Chat Model and Google Sheets.
How it runs
Trigger: On Gmail events.
- Check for PDF Attachment (If): checks a condition and branches into true / false
- Extract PDF Text (Extract from File): extracts data from a file (pdf)
- Extract Invoice Fields with AI (Basic LLM Chain): sends a prompt to an LLM, with model: AI Invoice Analyzer
- Validate AI Invoice Data (Code): runs custom JavaScript code
- Read Invoice Number from Sheets (Google Sheets): read
- Determine Duplicate Status (Code): runs custom JavaScript code
- Check Invoice Logged Status (If): checks a condition and branches into true / false
- Assess Need for Manual Review (If): checks a condition and branches into true / false
- Send Manual Review Alert (Gmail): uses Gmail
- Append Invoice to Sheets Log (Google Sheets): append
Services it uses
Other Google Sheets + Gmail templates (2,102) · Other OpenAI + Google Sheets templates (2,011) · Other OpenAI + Gmail templates (1,623)
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Still check Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll) (When Invoice Email Received).
Nodes used (9)
- Gmail Trigger
n8n-nodes-base.gmailTrigger - If
n8n-nodes-base.if - No Operation, do nothing
n8n-nodes-base.noOp - Extract from File
n8n-nodes-base.extractFromFile - Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Code
n8n-nodes-base.code - Google Sheets
n8n-nodes-base.googleSheets - Gmail
n8n-nodes-base.gmail
From the author
Quick overview Emails with PDF attachments are parsed automatically: AI extracts vendor, invoice number, dates and amounts into Google Sheets — validated in code (net + tax vs total), deduplicated against the sheet, and doubtful extractions are emailed to you…