n8n Receipt OCR Automation: Email a Receipt, Get a P&L Row
Build an n8n receipt OCR automation that reads emailed receipts with GPT-4o-mini Vision, routes by confidence, and logs vendor, amount, and tax to a P&L sheet.
A box of receipts. A shoebox, a phone camera roll, a folder of forwarded PDFs nobody's opened. Month-end arrives and someone keys them into a spreadsheet by hand, mistyping a total or skipping the tax line. The P&L is late and slightly wrong, every single month.
n8n receipt OCR automation ends the manual keying. You forward a receipt or invoice to an inbox, GPT-4o-mini Vision reads it, and the vendor, date, amount, tax, and category land as a row in your Google Sheets P&L. No third-party parsing SaaS, no shoebox, and a confidence gate that keeps the bad reads out of your books.
The guides ranking here lean on extra services and skip the gate. The Azure OCR receipt guide chains Azure Computer Vision plus a chat model and never mentions confidence scoring, email ingestion, or P&L reporting. The popular Telegram expense template is photo-via-Telegram with a Mistral agent, no Gmail polling, and no confidence routing to an Errors tab. Email-in, vision-direct, confidence-gated is the unwritten version.
What receipt OCR automation can do
Receipt entry is a clerical loop that a workflow erases:
- Watch an inbox for emails carrying a receipt or invoice attachment.
- Read the image directly with a vision model, no separate OCR step.
- Extract vendor, date, amount, tax, currency, and category as JSON.
- Score each extraction's confidence and route on it.
- Append high-confidence rows to the P&L, low-confidence to an Errors tab.
- Send a monthly category-breakdown digest of where the money went.
- Run entirely on your n8n instance plus an OpenAI account.
That's bookkeeping that updates itself between month-ends.
Why the confidence gate is non-negotiable
Here's the take worth defending: a receipt OCR flow without a confidence check is worse than no automation, because it logs wrong numbers with the same confidence as right ones. A human keying receipts at least squints at a blurry total. A naive workflow appends whatever the model guessed and you discover the error during a tax filing.
The fix is one extra field and one extra branch. Ask the model to return a confidence score with the data. An n8n-nodes-base.if v2 node reads it. High-confidence receipts flow to the main P&L tab; anything uncertain or unreadable routes to a separate Errors tab where a person spends ten seconds confirming or fixing it. The fast path stays fully automatic for the clean 90 percent, and the murky 10 percent gets a glance instead of silently corrupting the ledger.
Dropping the separate OCR service is the other quiet win. The two-step Azure-then-model pattern was necessary when vision models couldn't read images. GPT-4o-mini Vision reads the receipt and returns fields in one call, so the workflow loses a service, a credential, and a failure point.
The receipt OCR pipeline
Gmail poll (every 5 min, attachment present)
│
Extract first attachment (image/PDF)
│
GPT-4o-mini Vision → vendor, date, amount, tax, currency, category, confidence
│
Parse JSON (Code node)
│
IF confidence high? ── yes ──► append to P&L tab
│ no
Append to Errors tab (manual review)
One pass, with a gate that protects the books.
Step-by-step breakdown
1. Poll Gmail for attachments
A Gmail trigger checks every 5 minutes for new emails carrying an attachment. Poll on an interval, not every minute; tight polling burns OAuth quota for no benefit since receipts arrive in clusters, not by the second. Forwarding a receipt to one inbox is the lowest-friction capture there is.
2. Pull the attachment
A n8n-nodes-base.code v2 node grabs the first attachment, whether it's a photo, a screenshot, or a PDF, and prepares it for the model. One attachment per email keeps the mapping simple; multi-attachment emails are an edge case you can add later.
3. Read the receipt with Vision
The @n8n/n8n-nodes-langchain.openAi v2.1 node sends the image to GPT-4o-mini Vision with a structured prompt asking for vendor, date, amount, tax, currency, category, and a confidence score. Its response lands at $json.output[0].content[0].text. The model needs the modelId.__rl wrapper (value gpt-4o-mini, mode list) to resolve correctly; copying an older n8n-nodes-base.openAi config from a 2023 tutorial breaks the output path silently.
4. Parse the JSON
The model returns text, and the next node expects an object, so a n8n-nodes-base.code v2 node parses the JSON every time. Add this step even when it feels redundant. A missing parse is the most common reason these workflows fail, and the execution log makes the broken parse obvious while the failure itself doesn't announce.
5. Route by confidence and log
An n8n-nodes-base.if v2 node compares the confidence score against your floor. High-confidence extractions append a timestamped row to the main P&L tab via n8n-nodes-base.googleSheets v4.5; low-confidence ones land in an Errors tab. A separate monthly digest reads the ledger on the 1st and emails per-category totals, so trends surface without anyone building a report.
Implementation patterns
Pattern 1 — Vision-direct extraction. Skip the separate OCR service entirely. One vision call returns structured fields, which removes a credential and a whole class of layout-change failures.
Attachment → GPT-4o-mini Vision (image + structured prompt) → JSON fields
Pattern 2 — Confidence routing. The model's own confidence score drives the split between trusted and review.
Parse JSON → IF (confidence ≥ floor) → P&L tab | Errors tab
Pattern 3 — The month-end digest. A second n8n-nodes-base.scheduleTrigger v1.2 fires on the 1st, reads the ledger, totals by category, and emails a plain-text summary. The reporting comes free off the data the intake already captured.
n8n nodes you'll use most
| Node | Purpose |
|---|---|
| Gmail trigger | Poll for emails with receipt/invoice attachments |
n8n-nodes-base.code v2 | Pull the attachment and parse the model's JSON |
@n8n/n8n-nodes-langchain.openAi v2.1 | Read the receipt with GPT-4o-mini Vision |
n8n-nodes-base.if v2 | Route by confidence to P&L or Errors |
n8n-nodes-base.googleSheets v4.5 | Append rows and read the ledger for the digest |
n8n-nodes-base.scheduleTrigger v1.2 | Fire the monthly category digest |
Getting started
- Set up a Google Sheet with a P&L tab and a separate Errors tab.
- Add the Gmail trigger and point it at the inbox you'll forward receipts to.
- Pull the first attachment in a Code node.
- Send it to GPT-4o-mini Vision with a structured field-and-confidence prompt.
- Parse the JSON, then route on confidence with an IF node.
- Append to the right tab, and add a monthly digest on a Schedule trigger.
- Or import a tested flow and start forwarding receipts now.
The Vision prompt, the confidence floor, and the two-tab routing take real tuning to get right. The ReceiptLedger: Receipts & Invoices to Google Sheets P&L template ships it: Gmail polling, GPT-4o-mini Vision extraction, confidence-based routing to a P&L tab and an Errors tab, and a monthly category digest, with no third-party parsing SaaS.
Where this fits
Receipt capture is the front door of a finance stack. Once expenses land in a structured ledger, the same data feeds reporting and reconciliation, which is why teams pair this with broader expense tracking automation. The confidence-routing pattern here is the same trustworthiness gate that shows up in data validation workflows anywhere a model's output enters a system of record.
The ReceiptLedger template ships this end-to-end, including the GPT-4o-mini Vision extraction and the confidence-routing gate that keeps misreads out of your P&L. It's part of The Complete n8n Templates Bundle, a one-time lifetime license to the whole catalog plus every template added later, worth it if you run more than one of these automations.
A workflow that turns a forwarded receipt into a clean P&L row makes month-end a query instead of a chore. For the bigger picture, see how this connects to finance automation across the books, and if invoices flow out as well as in, pair it with the Automated Invoice Chase & Escalation template to keep receivables moving too.
See the ReceiptLedger template →Common questions
Does n8n need a separate OCR service to read receipts?
How do I avoid logging a misread receipt?
Can receipts come in by email instead of a chat app?
What fields can it extract from a receipt?
Get the workflow templates this guide is built on
Import-ready n8n JSON, step-by-step setup, and tested end-to-end. One-time payment, own it forever.
Get 3 tested n8n templates, free
The full customer package for three real catalog templates — workflow JSON, step-by-step setup guide, credential checklist. Built through the same live-instance release process as everything we sell. Plus new templates and automation guides in your inbox. No spam, unsubscribe anytime.
- 01Smart To-Do List ManagerPre-built n8n workflow template that automates productivity with OpenAI. Live in about 10 minutes.$14
- 02Email Follow-Up AutomatorPre-built n8n workflow template that automates crm with OpenAI. Live in about 15 minutes.$12
- 03Market Trend AnalyzerPre-built n8n workflow template that automates data processing with OpenAI. Live in about 10 minutes.$14
More automation guides

How to Build n8n Decision Support Automation with AI Frameworks
A founder spends a week circling a pricing decision. Not because the information's missing. It's all there. The hold-up is that there's no process to run it through. The pros and cons live in three ha…

How to Build n8n Employee Wellness Automation with AI Risk Scoring
Two people resign in the same month, both citing burnout. Nothing in the 1:1 notes flagged it. Nothing in their Slack activity looked off. The signals were there, in the throwaway comments, the slippi…

How to Build n8n Approval Workflow Automation That Auto-Approves and Escalates
A finance lead approves the same refunds every morning. Under $100, customer in good standing, clear reason. Approved, approved, approved. The decision was never hard. It just never got automated, so…