# n8n: Extract Every Invoice in Your Inbox with GPT-4o Vision

> Attach an inbox to n8n, parse every PDF and image invoice with vision, and land structured line items in Google Sheets — no OCR service required.

**Platform:** n8n  
**Category:** business  
**Difficulty:** Intermediate  
**Tags:** n8n, vision, invoices, openai, accounting  
**Updated:** 2026-05-25  
**Source:** https://promptfoo.tech/workflows/n8n-invoice-parsing-with-vision

## Overview
Bookkeepers still copy line items from PDFs by hand. Vision-capable LLMs eliminate that job — including for handwritten receipts. This workflow turns any inbox into a structured invoice ledger in Google Sheets, with confidence scores so humans review only the uncertain ones.

## How it works
1. IMAP trigger monitors an accounting@ inbox for messages with attachments.
2. Attachments are filtered to PDF / PNG / JPG and passed to GPT-4o with a strict JSON schema.
3. The model returns vendor, invoice number, date, currency, subtotal, tax, total, and line items.
4. Confidence < 0.85 → routed to a 'Review' sheet; otherwise → appended to the main ledger.
5. Original file is uploaded to Google Drive with a link stored in the row.

## Benefits
- Kills a 4-hour weekly bookkeeping task.
- Structured line items — not just totals — mean better category analytics.
- Confidence-based routing keeps humans in the loop only where it matters.

## Use cases
- SMBs with 20-200 invoices/month.
- Consultancies handling client expense receipts.
- Anyone whose bookkeeper still asks 'can you send me the PDF?'

## Step-by-step
### Step 1: Set up a dedicated inbox
accounting@yourdomain — vendors and forwarding rules go here. Never point this at a personal inbox.

### Step 2: Filter attachments precisely
Reject anything > 10MB and anything not PDF/PNG/JPG. Multi-page PDFs need conversion to images before vision calls.

### Step 3: Design the JSON schema first
Match your accounting software's field names exactly. Retro-fitting later means every historical row needs migration.

### Step 4: Ask for confidence per field
Not just per invoice. If the total is high-confidence but the tax line is low, that's exactly the review signal you want.

### Step 5: Route by confidence
≥0.85 → main sheet. <0.85 → review sheet. Weekly, sample review-sheet rows to tune the threshold.

### Step 6: Archive originals
Upload every file to Drive under /invoices/YYYY/MM/. Store the link in the row for auditability.

## Example
```
Row: 2026-05-14 | Acme Cloud | INV-8821 | USD 1,248.00 (subtotal 1,155.00, tax 93.00) | 4 line items | conf 0.94 | drive.google.com/…
```

## FAQs
**Multi-page invoices?**

Convert PDF → per-page images and pass them all in a single vision call. Combine line items in a post-processing step.

**Handwritten receipts?**

GPT-4o handles them surprisingly well, but drop your confidence threshold to 0.7 and expect more review.

**Cost per invoice?**

Roughly $0.005-0.02 per page at current GPT-4o pricing. Cheaper than any dedicated OCR SaaS at this volume.

---
Licensed under CC-BY-4.0. Attribution: PromptFoo.tech