Skip to content

Document AI: from inbox to ledger

Invoices and receipts go in as PDFs, scans and phone photos; structured, human-approved rows come out. Client deliveries, two open-source n8n templates and an open-weight experiment.

Year
2026
Role
Solo: workflow design, schemas, extraction pipeline, integration
Status
Shipped
Context
Product
The n8n editor on the invoice workflow: Drive archive, Mistral Document AI OCR, schema-locked Gemini extraction, then validation and routing
Document AI · Agentic automation · Human-in-the-loop2026

Results

  • 85%

    shorter processing cycle

    Client-reported, compared with manual invoice handling

  • 8/8

    pilot invoices processed

    Digital text first, OCR fallback for scans

  • 3

    open-source repos

    Two n8n templates and an OCR + open-weight LLM experiment

It started as client work. For an accounts team I built an n8n workflow that picks incoming PDF invoices up from Gmail and Google Drive, extracts them with a multimodal LLM against strict JSON schemas, sends every extraction to a human through an n8n Form, runs a vector-storage risk check for anything unusual, and only then writes rows to PostgreSQL. The client reported a processing cycle about 85% shorter than the manual one. That number is theirs, not a benchmark of mine.

A second delivery was a Python batch pipeline for messier files: pdfplumber reads digital text, Tesseract OCR (PSM 6, 300 DPI) takes over for scanned pages, and Gemini 2.5 Flash parses the text into a schema covering vendor metadata, invoice numbers, currencies, tax breakdowns and line items. An ETL layer writes JSON logs and multi-sheet Excel reports with duplicate checks, and errors are isolated per document so one bad file never stops the batch. It processed all 8 of the 8 pilot invoices.

The architecture is public as an MIT-licensed re-implementation, not the client’s flow: an accounts-payable template that watches a Gmail inbox, archives originals to Google Drive, runs Mistral Document AI OCR into Markdown, and extracts with Gemini 2.5 Pro at temperature 0 against a strict schema. Validation reconciles line items to totals and checks confidence; duplicates are blocked, exceptions are emailed to AP, high-value invoices go to Slack for one-tap approval, and clean ones are upserted into a Google Sheets ledger. Invoice text is treated as untrusted, so instructions hidden in a document are ignored.

Two siblings round it out. The AI Expense Receipt Assistant applies the same pattern to receipt photos sent to a Telegram bot, with a policy engine and manager approval. ReceiptLens is the open-weight experiment: PaddleOCR plus a zero-shot open LLM turning a scanned document into JSON, to see how far you get before paying for an API model.

What is still missing is a measured benchmark: field-level F1, valid-JSON rate and cost per document on public receipt datasets. That is the next thing I am building here, and it is the project that pulled me toward Document AI as a research area.

The whole 31-node invoice workflow zoomed to fit: six colour-coded stages from intake to ledger
The whole 31-node invoice workflow zoomed to fit: six colour-coded stages from intake to ledger