Extract invoice data from Gmail PDFs to Google Drive, Sheets, and OpenAI
Ready for 3.0What this workflow does
This AI workflow has 22 nodes and runs on Gmail events (plus 1 other trigger). Along the way it connects OpenAI Chat Model, Google Drive, Gmail and Google Sheets.
How it runs
Trigger: On Gmail events (plus 1 other trigger).
- Skip unwanted senders (Filter): keeps only the items that match a condition
- Get emails in a date range (Gmail): get many
- Pull PDF attachments out (Code): runs custom JavaScript code
- Combine PDFs and folder (Merge): merges the data from its input branches
- Find this month folder in Drive (Google Drive): work with file folder
- Loop over PDFs (Loop Over Items (Split in Batches)): loops over the items in batches
- Upload PDF to Drive (Google Drive): uses Google Drive
- Download PDF back (Google Drive): download
- Build Drive links (Code): runs custom JavaScript code
- Combine file and links (Merge): merges the data from its input branches
…plus 6 more steps. See the full node list below.
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) (Check inbox hourly).
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (16)
- OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Merge
n8n-nodes-base.merge - Extract from File
n8n-nodes-base.extractFromFile - Auto-fixing Output Parser
@n8n/n8n-nodes-langchain.outputParserAutofixing - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - Code
n8n-nodes-base.code - Google Drive
n8n-nodes-base.googleDrive - Filter
n8n-nodes-base.filter - If
n8n-nodes-base.if - AI Agent
@n8n/n8n-nodes-langchain.agent - Wait
n8n-nodes-base.wait - Gmail Trigger
n8n-nodes-base.gmailTrigger - Google Sheets
n8n-nodes-base.googleSheets - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - Gmail
n8n-nodes-base.gmail - Manual Trigger
n8n-nodes-base.manualTrigger
From the author
Quick overview This workflow checks Gmail for emails with PDF invoice attachments, saves each PDF to a month-based Google Drive folder, uses OpenAI to extract key invoice fields, and appends qualifying invoices to a month-named tab in Google Sheets. How it…