Supplier invoices captured from email: run the example workflow in n8n

The agent extracts the supplier, lines and tax from invoice emails, matches them to the purchase order, proposes coding and routes them for approval. It checks for duplicates and changed bank details. The approver signs off.

Approval gate: the approver signs off (approved=true). A price or quantity mismatch always needs review, even if approved.

Download the workflow (JSON) Download the sample input Back to the use case

1. Set up n8n once

Follow the setup guide: start n8n on your own computer, import the file, and press Publish.

2. Send the sample input

Save the sample input next to where you run the command, and use the Production URL path twwp-accounts-payable-invoice-capture-0302:

curl -X POST -H "Content-Type: application/json" --data-binary @accounts-payable-invoice-capture-0302-sample-input.json http://localhost:5678/webhook/twwp-accounts-payable-invoice-capture-0302

Sample input:

{
 "email": "Subject: Invoice 77\nSupplier: Delta Office Supplies\nPO: PO-5001\nLine: Printer paper A4 | 10 | 4.5\nLine: Toner black | 2 | 60\nTax: 18%",
 "approved": true,
 "purchase_orders": {
  "PO-5001": [
   {
    "desc": "Printer paper A4",
    "qty": 10,
    "unit": 4.5
   },
   {
    "desc": "Toner black",
    "qty": 2,
    "unit": 55
   }
  ]
 }
}

3. What you should see

With the gate closed (default):

{
 "status": "needs_review",
 "invoice": {
  "supplier": "Delta Office Supplies",
  "po": "PO-5001",
  "lines": [
   {
    "desc": "Printer paper A4",
    "qty": 10,
    "unit": 4.5
   },
   {
    "desc": "Toner black",
    "qty": 2,
    "unit": 60
   }
  ],
  "net": 165,
  "tax": 29.7,
  "total": 194.7
 },
 "mismatches": [
  "price Toner black: ordered 55, invoiced 60"
 ]
}

With the gate open (clean_approved), after changing the input as in the test file:

{
 "status": "routed_to_payment_local",
 "invoice": {
  "supplier": "Delta Office Supplies",
  "po": "PO-5002",
  "lines": [
   {
    "desc": "Stapler",
    "qty": 3,
    "unit": 8
   }
  ],
  "net": 24,
  "tax": 4.32,
  "total": 28.32
 },
 "match_ok": true
}

All 3 test cases, with their inputs and answers, are in the test file. The AI step is a simple stand-in, so the answer is the same every time. See the setup guide for how to swap in a real AI and what it costs.