Extracting invoices from Gmail with n8n and Gemini, then checking the IBAN before anyone pays it
说明与用途
使用 n8n 和 Gemini 自动从 Gmail 提取发票,并通过 API 验证 IBAN,以防止支付错误。
问题
LLMs can extract invoice data but may misread an IBAN, leading to payment errors.
结果
Invoices are extracted, validated for math and IBAN correctness, and stored in Google Sheets with review flags for any issues, reducing payment errors.
工作流
- Poll Gmail for unread emails labeled "invoices" with PDF attachments
- Split PDF attachments into individual items
- Extract text from each PDF
- Use Gemini with Structured Output Parser to return vendor, invoice number, PO number, dates, currency, subtotal, tax, total, line items and confidence score as JSON
- Normalize invoice data: clean numbers/dates, verify subtotal+tax=total, flag low-confidence rows as "needs_review"
- Append validated rows to Google Sheets and mark email as read
- (Optional) Send HTTP request to external API to validate IBAN, BIC, VAT, etc. and flag invalid or unchecked entries
证据
Most invoice automations stop at extraction: an LLM pulls the vendor, total and bank details out of a PDF, and the numbers go straight into a spreadsheet or ledger.
The ISO 13616 mod-97 checksum does. I put that, plus a few related checks, in a Cloudflare Worker:
Up to 50 identifiers per batch request. Here's a real response from the keyless demo endpoint:
- 记录日期: 2026-10-18T09:56:24.176Z