Back to Projects
Day 1 / 30AI Automation

AI Invoice Extractor

A webhook-driven AI pipeline that turns PDF invoices into structured, validated records and logs clean results to Google Sheets.

AI Invoice Extractor workflow architecture

Overview

Day 1 focuses on building a reliable extraction pipeline rather than simply asking an AI model to read a document. The important part is the validation layer: the workflow checks required fields, line-item math, subtotal reconciliation, and subtotal + tax = total before writing data to the spreadsheet.

The Problem

Invoice processing is repetitive and easy to get wrong. Manually copying vendor details, dates, totals and line items into a spreadsheet creates unnecessary work and makes arithmetic or transcription errors harder to catch.

The Solution

The workflow accepts a PDF through a webhook, extracts its text, uses an OpenRouter-backed LLM to produce structured invoice data, then validates required fields and invoice arithmetic before routing the result. Valid records are appended to Google Sheets; inconsistent or incomplete invoices are returned for manual review instead of being silently accepted.

How the Workflow Works

  1. 1Receive an invoice PDF through a POST webhook.
  2. 2Extract text from the uploaded PDF.
  3. 3Send the invoice text to the LLM with a strict JSON schema and no-guessing rules.
  4. 4Normalize values and validate required fields and invoice arithmetic.
  5. 5Route valid data to Google Sheets or return a manual-review response with the validation reason.

Workflow Architecture

AI Invoice Extractor n8n workflow architecture

Key Features

Structured JSON extraction
Required-field validation
Line-item quantity × unit-price checks
Subtotal and total reconciliation
Google Sheets logging
Manual-review fallback

Tech Stack

n8nOpenRouterGoogle SheetsWebhooksPDF Parser

Scope & Limitations

  • Designed for text-based PDF invoices.
  • Scanned or photographed invoices need a vision-capable extraction step.
  • Credentials and production webhook configuration are intentionally excluded from the public JSON.