Extract, validate, and log email invoices from Gmail to Google Sheets with GPT-4
Needs changesWhat this workflow does
This AI workflow has 12 nodes and runs when someone submits an n8n form (“AI Financial Mail Detector and Summarizer”). Along the way it connects Gmail, Guardrails, Google Sheets and OpenAI Chat Model.
How it runs
Trigger: When someone submits an n8n form (“AI Financial Mail Detector and Summarizer”).
- Get Email Content (Gmail): get many
- Guardrail: Is Finance? (Guardrails): uses Guardrails, with model: OpenAI Chat Model
- If: checks a condition and branches into true / false
- Filter: keeps only the items that match a condition
- AI Agent: runs an AI agent, with model: gpt 4o mini
- Validate Extraction (Code): runs custom JavaScript code
- Check for Errors (If): checks a condition and branches into true / false
- Apply Finance Rules (Code): runs custom JavaScript code
- Log to Invoices Sheet (Google Sheets): append
Services it uses
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in AI Agent (Email OCR) (v1.9): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) AI Agent (Email OCR) (v1.9) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (9)
- Gmail
n8n-nodes-base.gmail - Guardrails
@n8n/n8n-nodes-langchain.guardrails - If
n8n-nodes-base.if - Filter
n8n-nodes-base.filter - AI Agent
@n8n/n8n-nodes-langchain.agent - Code
n8n-nodes-base.code - Google Sheets
n8n-nodes-base.googleSheets - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - n8n Form Trigger
n8n-nodes-base.formTrigger
From the author
Inbox2Ledger is an end-to-end n8n template that turns a noisy finance inbox into a clean, structured ledger. It fetches emails, uses AI guardrails to keep only finance-relevant messages, extracts invoice/receipt fields via an OCR-style agent, validates and…