Skip to content
Document Intelligence · n8n

LedgerDrop

Drop an invoice into a Google Drive folder — LlamaParse OCRs it, a Groq-powered extractor pulls structured fields, the ledger row lands in Sheets, and the file files itself.

    n8nGoogle Drive APIGoogle Sheets APILlamaParseGroqInformation Extractor

The Problem

Invoice processing is silent admin work: PDFs arrive in every layout imaginable, someone re-types invoice numbers and totals into a spreadsheet, and misfiled originals make audits painful. The typing adds nothing — it's pure transcription.

The Solution

A zero-touch document pipeline on n8n. Invoices dropped into an 'Unprocessed' Drive folder trigger automatically: binaries upload to LlamaParse, whose OCR-grade parsing survives scans, tables, and multi-page layouts; a wait/poll loop tracks the async job to completion. Parsed markdown feeds n8n's Information Extractor backed by Groq-hosted Kimi K2 under a typed schema — invoice number, dates, vendor, client, amounts with required-field enforcement. Validated rows append to a Google Sheets ledger while the original moves itself into 'Processed', keeping the inbox honest for the next drop.

How the workflow runs

  1. 01 · Detect

    The Drive trigger polls the Unprocessed folder every minute; any new invoice fires the flow.

  2. 02 · Download

    The binary is fetched from Drive with its original filename preserved.

  3. 03 · Parse

    LlamaParse converts the PDF — scan or native — into clean markdown; polling handles async job completion.

  4. 04 · Extract

    Kimi K2 via Groq fills a typed schema (invoiceNumber, dates, vendor, client, totalAmount) with required-field validation.

  5. 05 · Record

    Extracted columns append to the Google Sheets ledger as one row.

  6. 06 · File

    The original uploads to Processed and deletes from Unprocessed — the pipeline is self-cleaning.

AI layer

OCR-first parsing
LlamaParse handles the visual mess (scans, tables, stamps) so the LLM only ever sees clean text.
Schema-constrained extraction
Typed attributes turn freeform invoices into predictable, machine-checkable records.
Groq inference
Kimi K2 on Groq keeps per-invoice cost near zero and latency low at minute-scale cadence.

Automation layer

Folder-as-queue design
The Unprocessed folder is the entire interface — no forms, no bots, works with email-to-Drive rules.
Async-safe orchestration
Wait/Switch polling turns a long-running external OCR job into a linear, retry-friendly flow.
Idempotent filing
Processed documents leave the watched folder, so completed invoices can never double-process.

Technical challenges

  • Invoices arrive as scans, photos, and multi-page statements that break naive text extraction.

    Delegated layout understanding to LlamaParse's specialised parser before any LLM involvement.

  • LLM extraction of financial fields hallucinates when values are ambiguous or missing.

    Required-field enforcement in the extractor schema plus OCR-clean input keeps records trustworthy.

  • OCR jobs are asynchronous — naive chains fire requests before results exist.

    An explicit wait-and-poll subflow routes on SUCCESS/PENDING until the parse job completes.

Outcome

  • Invoice-to-ledger-row with zero manual typing — the spreadsheet maintains itself.
  • Every processed document ends up filed in Processed, giving a natural audit trail.
  • Adding new fields is a one-line schema change, not a code change.

Lessons learned

  • Specialised parsers beat prompting when input is visual — give the LLM text, not pixels.
  • Folders are a perfectly good message queue for non-technical users.
  • Design pipelines so their output location excludes them from re-triggering; idempotency for free.