n8n portfolio · workflow 3 of 3
AI Accounts Payable Autopilot
An accounts-payable clerk that never sleeps: it reads every emailed invoice with Claude vision, checks it against the vendor master and purchase orders, stops bank-detail fraud before money moves, gets the right approver's decision in Slack and posts the bill to QuickBooks. Built for finance teams re-keying invoices by hand.
Architecture
Every attachment becomes one item with a SHA-256 fingerprint, so a re-sent invoice is skipped before any AI spend.
- Trigger
- Code / routing
- Postgres
- App action
- Claude step
- Human in the loop
- Fraud control
The decision ladder
Checks run in this order and the first match wins, so a fraud signal always beats a convenient auto-approval.
approval_matrix table.Engineering decisions
Why it is built this way.
- Claude reads the document itselfPDFs and phone photos go straight to the Messages API as document or image blocks, constrained by a JSON schema. No OCR step and no template per vendor.
- Trust, then re-checkThe workflow recomputes line totals, subtotal, tax and dates, and derives due dates and early-pay discounts from terms like “2/10 Net 30”.
- Fraud controls outrank everythingA changed bank account, a spoofed sender domain or a PO that belongs to someone else holds the payment and alerts the team. The workflow never replies to a possible attacker.
- Only the last 4 digits are storedThe schema asks for the last four digits of the bank account, enough to detect a change without holding account numbers.
- Idempotent end to endFile fingerprints and a unique constraint make re-deliveries harmless; a repeated invoice number gets a courteous reply instead of a second payment.
- Refusals and fallbacks handledRequests opt into Anthropic's server-side fallback, and a refusal or unparseable reply routes the document to AP review instead of failing the run.
- Money-aware schedulingPayments land on the discount deadline when there is one; the morning digest shows cash out for the next 7 days and discounts captured.