Skip to main content
Lifetime license included with every purchase
n8n workflowsaccounts payablefinance automationapproval routing

n8n Accounts Payable Automation: 3-Way Match and Approval Routing

Build n8n accounts payable automation that does a real 3-way match (PO, invoice, receipt) and routes approvals by threshold — with a full audit trail.

Nn8n Marketplace Team·September 7, 2026·Updated September 7, 2026·8 min read

Most accounts payable content shows you the easy half. A vendor emails an invoice, an AI node reads the amount, you match it against a purchase order, you pay. The n8n.io invoice-PO matching template that ranks does exactly this, and it does it well. It also pays for things you ordered but may never have received, because a 2-way match never checks whether the goods actually arrived.

Real n8n accounts payable automation does a 3-way match. The purchase order says what you agreed to buy. The invoice says what the vendor billed. The goods receipt says what showed up on the dock. Pay only when all three agree, and route everything else to a human. That's the difference between an AP demo and an AP control.

This is the upstream half of finance, by the way. Chasing money owed to you is accounts receivable, a different job covered elsewhere. This post is about paying out without paying wrong.

What You Can Automate in Accounts Payable

The AP steps that automate cleanly:

  • Capturing invoices from an AP inbox or a Drive folder
  • Extracting vendor, amount, line items, and PO number with an AI node
  • Pulling the matching PO and goods receipt from your records
  • Running a 3-way match on totals and line items
  • Auto-approving matched invoices under a low threshold
  • Routing matched invoices over a threshold to a manager
  • Sending unmatched or mismatched invoices to procurement
  • Logging every decision with who approved it and when

The match decides the path. The threshold decides how much human attention each invoice gets. The log makes the whole thing auditable.

The Accounts Payable Pipeline

The shape that keeps a bad invoice from becoming a bad payment:

Capture → Extract → Match (3-way) → Route by threshold → Approve → Pay → Log

A concrete run:

Gmail Trigger v2 / Google Drive Trigger: new invoice arrives
  → AI extraction (openAi v2.1): vendor, amount, line items, PO number
  → Google Sheets v4: fetch matching PO + goods receipt
  → Code v2 (jsCode): 3-way match on totals + line items
  → Switch v3: matched-low | matched-high | unmatched
  → matched-low: mark approved
  → matched-high: Slack v2 approval request → Wait v1.1
  → unmatched: email procurement with the discrepancy
  → Google Sheets v4: append AP decision log

Notice the unmatched path never reaches payment. An invoice with no PO, a missing receipt, or a total that doesn't tie out is an exception, and exceptions go to people, not to the bank.

2-way matching pays for ghosts

The ranking n8n AP template matches the invoice against the purchase order and stops. That confirms you agreed to buy something. It does not confirm the something arrived. Vendors over-bill, partial shipments get invoiced in full, and a 2-way match waves all of it through. The goods receipt is the third leg, and it's the one that catches the money you'd otherwise lose quietly.

Step-by-Step Breakdown

1. Capture the invoice

Watch an AP inbox or a dedicated Drive folder. The moment an invoice lands, the workflow fires. Don't make someone forward it manually — that's the bottleneck you're trying to remove.

2. Extract the structured fields

An AI node reads the PDF and returns vendor, total, line items, and the PO number as structured data. The @n8n/n8n-nodes-langchain.openAi v2.1 node returns its output at $json.output[0].content[0].text; a Code node parses that JSON into fields the matcher can use.

3. Pull the other two documents

With the PO number in hand, fetch the purchase order and the goods receipt. If either is missing, that's already an exception — you can't 3-way match against documents that don't exist.

4. Run the 3-way match

One Code node compares totals and line items across PO, invoice, and receipt. Exact agreement on all three is a clean match. Anything else is a candidate for human eyes, not for payment.

5. Route by threshold and exception

A Switch node sends matched-and-small straight to approved, matched-and-large to a manager for sign-off, and any mismatch to procurement. Three paths, three owners. The threshold is a number you set, not a guess the workflow makes.

Implementation Patterns That Hold Up

Pattern 1: The 3-way match in one node. Compare the three documents on the fields that matter.

Code v2 (jsCode):
  const poOk  = Math.abs(invoice.total - po.total) < 0.01;
  const rcvOk = receipt.lineItems.every(li =>
    invoice.lineItems.find(x => x.sku === li.sku && x.qty === li.qty));
  if (poOk && rcvOk) return [{ json: { result: 'matched' } }];
  return [{ json: { result: 'exception', poOk, rcvOk } }];

The receipt check is the leg the 2-way templates omit. It confirms the quantities billed match the quantities received, SKU by SKU, which is where over-billing hides.

Pattern 2: Threshold routing that doesn't stall. A matched invoice under, say, a few hundred dollars carries little risk and auto-approves. Above that, it routes to a manager. The trap is approvals that sit in a travelling approver's inbox. Add a timeout: if the Wait node doesn't get a response in a set window, escalate to a backup approver or a Slack channel, so a quiet manager never becomes an overdue vendor.

Pattern 3: A tamper-evident audit trail. Every decision appends a row: invoice ID, match result, amount, who approved, timestamp. Don't update rows in place. Append-only logging means the history of an approval can't be quietly rewritten, which is exactly what an auditor wants to see.

n8n Nodes You'll Use Most

NodePurpose
n8n-nodes-base.gmailTriggerCatch invoices arriving in the AP inbox
@n8n/n8n-nodes-langchain.openAiExtract vendor, total, and line items from the PDF
n8n-nodes-base.codeThe 3-way match and the field parsing
n8n-nodes-base.googleSheetsRead PO and receipt records, write the audit log
n8n-nodes-base.switchRoute matched-low, matched-high, and exceptions
n8n-nodes-base.slackManager approval requests above threshold
n8n-nodes-base.waitHold for approval with a timeout escalation

The Code node doing the match is the one to get right. Everything upstream feeds it three documents; everything downstream acts on its verdict. Test it against a deliberately over-billed invoice and confirm the receipt leg catches it.

Getting Started

  1. Get all three documents into the workflow. PO, invoice, and receipt as named branches. You can't 3-way match what you can't see.
  2. Build the extraction and confirm the parse. The AI node returns text; a Code node turns it into fields. Test on a few real invoices before trusting it.
  3. Write the 3-way match and break it on purpose. Feed it a partial-shipment invoice and confirm the receipt leg flags it.
  4. Set your thresholds explicitly. Auto-approve under X, escalate over X, exception otherwise. Write the numbers down in the Config node.
  5. Add the approval timeout. A pending approval that never resolves is an overdue invoice waiting to happen. Escalate on a clock.
  6. Append every decision. Invoice ID, result, approver, timestamp, append-only. That log is your audit trail.
Browse the AP escalation templates
Skip the build

The Vendor Payment Escalator ships the escalation backbone this workflow needs: staged, AI-written reminders for invoices stuck in the approval chain, plus Slack alerts when a critical payment goes quiet — so an approval sitting in a travelling manager's inbox becomes a visible escalation instead of an angry vendor call. It's part of The Complete n8n Templates Bundle, a one-time lifetime license to the whole catalog (plus every template added later) if you run more than one of these finance automations.

Get the Vendor Payment Escalator

One honest limitation: AI extraction from invoice PDFs is good, not perfect. A smudged scan or an unusual vendor layout will occasionally misread a total. Treat the extracted amount as a claim to verify against the PO and receipt, not as ground truth. The 3-way match is what protects you when the extraction slips.

If AP is one piece of your finance stack, the n8n finance automation guide covers the receivable side, and the n8n bank reconciliation workflow shows how the payments you make here get matched back against the bank feed later.

Build the 3-way match first, with the receipt leg. The approval routing is configuration on top of it. The match is the control that actually saves money.

See more finance templates
FAQ

Common questions

What is a 3-way match in an n8n accounts payable workflow?
A 3-way match confirms three documents agree before an invoice is paid: the purchase order (what you agreed to buy), the invoice (what the vendor billed), and the goods receipt (what actually arrived). In n8n, a Code node compares line items and totals across all three. Only invoices where all three agree route to payment automatically. The n8n templates that rank only do a 2-way match (invoice against PO), which pays for goods you ordered but may never have received.
How does approval routing work in n8n accounts payable?
Route by amount and exception. A matched invoice under a low threshold can auto-approve. A matched invoice over a higher threshold routes to a manager for sign-off via Slack or email. Any invoice that fails the match — wrong amount, missing receipt, no PO — routes to procurement to investigate, never straight to payment. A Switch node on the match result plus the invoice amount handles all three paths.
Why automate accounts payable instead of just paying invoices?
Because the expensive AP failures are silent. A duplicate invoice paid twice, a vendor billing for undelivered goods, an approval that sat in a travelling manager's inbox until the vendor called asking why they weren't paid. Automating AP gives you a consistent match, threshold-based approvals that don't stall when someone's away, and a tamper-evident log of who approved what. The point isn't speed. It's control.
Stop reading. Start running.

Get the workflow templates this guide is built on

Import-ready n8n JSON, step-by-step setup, and tested end-to-end. One-time payment, own it forever.

Free — $40 value

Get 3 tested n8n templates, free

The full customer package for three real catalog templates — workflow JSON, step-by-step setup guide, credential checklist. Built through the same live-instance release process as everything we sell. Plus new templates and automation guides in your inbox. No spam, unsubscribe anytime.

  • 01Smart To-Do List ManagerPre-built n8n workflow template that automates productivity with OpenAI. Live in about 10 minutes.$14
  • 02Email Follow-Up AutomatorPre-built n8n workflow template that automates crm with OpenAI. Live in about 15 minutes.$12
  • 03Market Trend AnalyzerPre-built n8n workflow template that automates data processing with OpenAI. Live in about 10 minutes.$14