What this workflow does
- Gmail Trigger polls the AP inbox every minute for unread emails with a PDF, JPG or PNG attachment.
- Config holds your QuickBooks company ID, default expense account, approval threshold and amount tolerance in one place.
- Build extraction request sends the first PDF or image to Claude as a base64 content block, with a JSON schema for vendor, invoice number, dates, currency, subtotal, tax, total and line items.
- Claude: extract invoice calls the Anthropic Messages API with structured outputs, so the reply is always parseable JSON. API errors leave through the error output to Slack.
- Parse and validate handles refusals and cut-off replies, then checks in code that line items sum to the subtotal, subtotal plus tax equals the total, the date is real and not in the future, the currency matches, and the document is an invoice rather than a credit memo or statement.
- QBO: find vendor and QBO: find existing bill query QuickBooks Online for the vendor and for any bill with the same invoice number.
- Decide route requires an exact, single vendor match, blocks duplicates, sends anything over your threshold to a person, and builds the bill with one line per invoice line plus tax.
- QBO: create bill posts the bill, and Mark email processed marks the email as read. Review items stay unread in the inbox.
- Post to review channel receives every exception with the vendor, invoice number, total and the reason codes.
Before you import
- A current n8n version, cloud or self-hosted.
- A Gmail or Google Workspace mailbox used only for vendor invoices.
- An Anthropic API key, added as n8n’s built-in Anthropic credential.
- A QuickBooks Online company and an Intuit developer app for the OAuth2 credential. Start with a sandbox company.
- A Slack app with a bot token that can post to your review channel.
Setup
- Import the JSON file into n8n and open each node with a credential warning to select or create the credential.
- In Gmail Trigger, replace
REPLACE_WITH_AP_INBOX_ADDRESSwith your AP address. - In Config, replace
REPLACE_WITH_QBO_COMPANY_IDwith your QuickBooks company (realm) ID andREPLACE_WITH_QBO_EXPENSE_ACCOUNT_IDwith the expense account ID new bills should use. SetapprovalThresholdandhomeCurrency. While testing, changeqboBaseUrltohttps://sandbox-quickbooks.api.intuit.com. - In Post to review channel, replace
REPLACE_WITH_SLACK_CHANNELwith your channel name and invite the bot to it. - Make sure vendors in QuickBooks use the same names that appear on their invoices, or the vendor check will send them to review.
Test it
Disable QBO: create bill, send yourself three emails: a clean invoice, an invoice whose total does not add up, and a credit memo. Run the workflow manually. The clean one should reach the disabled bill node with a bill payload you can inspect. The other two should arrive in Slack with subtotal_plus_tax_does_not_match_total and not_an_invoice: credit_memo. Then send the clean invoice a second time after enabling the bill node in a sandbox company, and confirm the duplicate check stops it.
Make it production-ready
- Error workflow. Set an error workflow in the workflow settings so node failures outside the handled paths still alert someone.
- Logging. Append every decision to a sheet or database table with the message ID, reason codes and QuickBooks bill ID, so you can measure exception rates by vendor.
- Retries. The Claude node already retries three times. Add the same to the QuickBooks nodes, and watch Intuit’s API rate limits on large backfills.
- Human review. Keep new vendors and anything over your threshold on manual approval. The accounts payable approvals template can take over from the review channel.
- Coding. The template posts every line to one expense account. Add a vendor-to-account mapping table before turning on auto-posting for many vendors.
- Attachments. Upload the original PDF to the bill through QuickBooks’ attachments API once the core flow is stable.
- Model choice.
claude-haiku-5-5is a cheaper option for high volumes of simple, typed invoices. Keep a test set of real invoices and re-run it whenever you change models.
Read the full guide, how to automate invoice processing with AI, for architecture and edge cases, or talk to Lumeor if you want help taking this to production.