Templates / Extract and validate invoice PDFs from email with OpenAI, Sheets and Xero

Extract and validate invoice PDFs from email with OpenAI, Sheets and Xero

Ready for 3.0

by Pushbuild ✓ · 36 views · created 2026-11-21

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-12-01.

📬 Weekly n8n 3.0 breakage alerts, free

What this workflow does

This AI workflow has 25 nodes and runs when a new email arrives over IMAP (plus 1 other trigger). Along the way it connects Google Sheets and OpenAI Chat Model. It also calls api.xero.com over HTTP.

How it runs

Trigger: When a new email arrives over IMAP (plus 1 other trigger).

  1. Config (Edit Fields (Set)): sets 7 fields: workflow_label, model, total_tolerance…
  2. One item per PDF (Code): runs custom JavaScript code
  3. Sample run? (If): checks a condition and branches into true / false
  4. Has a text layer? (Code): runs custom JavaScript code
  5. Extract PDF text (Extract from File): extracts data from a file (pdf)
  6. Scanned? (If): checks a condition and branches into true / false
  7. Describe failure (Code): runs custom JavaScript code
  8. Scan to review (Code): runs custom JavaScript code
  9. Extract fields (AI) (Basic LLM Chain): sends a prompt to an LLM, with model: OpenAI model; output parser: Invoice schema
  10. Failure alert (Slack) (HTTP Request): calls an HTTP API (POST)

…plus 11 more steps. See the full node list below.

Services it uses

Google SheetsOpenAI Chat Model

HTTP calls to: api.xero.com

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Check at runtime on n8n 3.0
  • Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Informational: a static scan can't see the data, so test these on your own instance. Status above is unchanged.

Nodes used (12)

From the author

Quick overview This workflow monitors an IMAP inbox for invoice PDF attachments, extracts structured invoice fields with OpenAI, validates totals and dates, logs results to Google Sheets, and optionally creates draft bills in Xero while sending Slack alerts…

Excerpt from Pushbuild's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.