Most invoice automation stops at extraction. You get the vendor name and total, it goes into a spreadsheet, someone still has to check whether the numbers add up and whether it matches the purchase order. The boring part is still manual.
This workflow does the full AP intake — extraction, math validation, PO matching, and routing — without touching a spreadsheet.
What it does
Invoice email arrives in Gmail → downloads PDF attachment → extracts all invoice data → validates arithmetic → looks up PO in database → checks amount within 2% tolerance → logs to Invoice Log → auto-sends confirmation email (approved) or flags for manual review (mismatched)
About 10-12 seconds per invoice.
The four stages
Stage 1 — Get invoice
Gmail Trigger watches for new emails. Get Message downloads the attachment. A Code node renames attachment_0 to data for PDF Vector compatibility — this is a required step that most Gmail invoice workflows miss.
Stage 2 — Extract and validate
PDF Vector pulls the full invoice structure:
-
Invoice number, date, due date
-
Vendor name and address
-
PO number
-
Line items — description, quantity, unit price, amount per line
-
Subtotal, tax amount, total amount
-
Payment terms, bank details
Then the Validate Invoice Code node checks two things:
-
Do the line items add up to the subtotal? (
sum of line amounts = subtotal) -
Does subtotal + tax equal the total? (
subtotal + tax = total)
Any arithmetic discrepancy over $0.01 gets flagged as a warning. Missing required fields (invoice number, vendor name, total) become hard errors that stop processing.
Stage 3 — PO matching
PO Lookup reads your Google Sheets PO Database tab, filtering by the PO number extracted from the invoice. Check PO Match compares the invoice total against the PO amount with a configurable tolerance — default 2%.
Four flag reasons:
-
PO not found — no matching PO number in database
-
PO amount mismatch — invoice total outside 2% tolerance
-
Validation errors — missing required fields
-
No PO number — invoice arrived without a PO reference
Stage 4 — Log and notify
Approved invoices → logged to Invoice Log tab → confirmation email sent to vendor
Flagged invoices → logged as Flagged → alert email sent to AP team with reason
What lands in Google Sheets (Invoice Log)
Each row: Invoice Number, Invoice Date, Due Date, Vendor, PO Number, Subtotal, Tax, Total, Items (summary), Status, Warnings, Flag Reason, File Name, Processed Date
Approved and flagged invoices both log to the same sheet — filter by Status to see your queue.
Setup
You’ll need:
-
Gmail (AP inbox receiving invoices)
-
Google Sheets with two tabs: PO Database and Invoice Log
-
n8n instance (self-hosted — uses PDF Vector community node)
-
PDF Vector account (free tier: 100 credits/month)
About 20 minutes to configure. The PO Database tab needs columns: po_number, amount, vendor, status — the workflow matches on po_number.
Download
Workflow JSON:
workflow-01-invoice-processing.json
Full workflow collection:
Setup Guide
Step 1: Get your PDF Vector API key
Sign up at pdfvector.com — free plan works for testing.
Step 2: Set up your Google Sheet
Create a spreadsheet with two tabs:
PO Database tab — columns: po_number, amount, vendor, status
Add your open POs here. The workflow matches invoices against this tab.
Invoice Log tab — columns:
Invoice Number | Invoice Date | Due Date | Vendor | PO Number | Subtotal | Tax | Total | Items | Status | Warnings | Flag Reason | File Name | Processed Date
Step 3: Import the workflow
Download JSON → n8n → Import from File.
Step 4: Configure the nodes
Gmail Trigger + Get Message:
- Connect Gmail account (OAuth2)
PDF Vector - Extract Invoice:
- Add credential (Bearer Token), paste API key
PO Lookup + Log Approved + Log Flagged:
- Connect Google Sheets, paste Sheet ID in all three nodes
Confirm Approved:
-
Sends reply to the sender’s email automatically
-
Update the “From” display name to match your company
Alert Flagged:
- Change
[email protected]to your actual AP team email
Step 5: Adjust the PO tolerance
In the Check PO Match Code node, find tolerance = 0.02 — change to whatever percentage fits your AP policy.
Accuracy
Tested on vendor invoices from accounting systems (QuickBooks, FreshBooks, Xero-generated) and supplier PDF templates.
-
Invoice number, vendor, totals: ~97%
-
Line items with quantity and unit price: ~94% on structured invoices
-
PO number extraction: ~91% — location varies by invoice template
-
Tax calculation validation: ~99% — pure arithmetic check
-
Line item math validation: ~98% — catches most discrepancies
Works on both digital PDFs and scanned/photographed invoices — the PDF Vector extraction prompt handles both.
Cost
3-4 credits per invoice. Free tier covers ~25-30 invoices per month.
Customizing it
Change PO tolerance:
Find const tolerance = 0.02 in Check PO Match and adjust. Some AP teams use 0% (exact match), others 5% for older POs.
Add Slack instead of email:
Swap the Gmail Confirm and Alert nodes for Slack nodes — approved invoices post to #ap-approvals, flagged ones go to #ap-review.
Multi-attachment handling:
Vendors sometimes send multiple invoice PDFs in one email. Add a loop after Get Message to process each attachment separately.
Connect to QuickBooks or Xero:
After logging approved invoices, add an HTTP Request node to create a bill in your accounting system automatically.
Limitations
-
Requires self-hosted n8n (PDF Vector is a community node)
-
Only processes
attachment_0(first attachment) — multi-PDF emails need a loop -
PO matching requires POs to be pre-loaded in the Sheets database
-
2% tolerance is global — can’t set different tolerances per vendor
-
Doesn’t handle credit notes or partial payments
Questions? Drop a comment.
