Let the model read the invoice, not approve it: an n8n pattern for AP automation
说明与用途
模型提取发票数据,但不做付款决策。n8n 工作流验证数据,应用业务规则,并将发票路由到自动批准、Slack 审批或保留,并给出明确原因。
问题
Automating accounts payable requires decisions beyond invoice extraction; models should not approve invoices, and fraud or errors must be caught before payment.
结果
The pattern separates extraction from decision logic, normalises data, applies comprehensive checks (vendor, bank, arithmetic, duplicates, PO), and routes invoices appropriately, improving accuracy and auditability.
工作流
- Trigger on Gmail email with PDF
- Execute workflow per email
- Store PDF in Google Drive
- Claude call to extract JSON with fixed schema and confidence
- Code node normalises fields and runs checks
- Route to auto_approve, approve, or hold
- Create QuickBooks bill for approved invoices
- Send Slack message for approvals or holds
- Log all actions in Google Sheet
- Label Gmail thread with status
证据
The model never approves anything. This post walks through the pattern, with the actual checks we run.
If one batch run handles five invoices and the third one throws, you get a half-processed mess. One execution per invoice means one red run you can retry.
The extraction prompt asks for a fixed schema: vendor name, tax ID, invoice number, dates, currency, subtotal, tax, total, PO number, bank details, line items, plus two fields that do a lot of work: is_invoice and confidence.
We also run a regex over the email body and the model's notes for phrases like "updated bank details" or "remit to our new account".
- 记录日期: 2026-10-07T10:41:02.617Z