Extract invoice data from Gmail PDF attachments to Google Sheets with GPT-4.1-mini
Ready for 3.0What this workflow does
This AI workflow has 17 nodes and runs on Gmail events. Along the way it connects Gmail, Google Sheets and OpenAI Chat Model.
How it runs
Trigger: On Gmail events.
- If: checks a condition and branches into true / false
- Code: runs custom JavaScript code
- Check Duplicate (Code): runs custom JavaScript code
- Is PDF? (If): checks a condition and branches into true / false
- Extract from File: extracts data from a file (pdf)
- Flag Unsupported Format (Edit Fields (Set)): sets 4 fields: reason, file_name, from_email…
- AI Agent: runs an AI agent, with model: OpenAI Chat Model
- Log Manual Review (Google Sheets): append
- Parse JSON Response (Code): runs custom JavaScript code
- Has Error? (If): checks a condition and branches into true / false
…plus 4 more steps. See the full node list below.
Services it uses
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.
Nodes used (10)
- Gmail Trigger
n8n-nodes-base.gmailTrigger - If
n8n-nodes-base.if - Code
n8n-nodes-base.code - Edit Fields (Set)
n8n-nodes-base.set - Google Sheets
n8n-nodes-base.googleSheets - Extract from File
n8n-nodes-base.extractFromFile - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Gmail
n8n-nodes-base.gmail - No Operation, do nothing
n8n-nodes-base.noOp
From the author
Quick overview This workflow checks Gmail everyday for emails with invoice-related keywords and PDF attachments, extracts the PDF text, uses OpenAI (gpt-4.1-mini) to turn the content into structured invoice fields, normalizes the result, and appends the…