Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Extracting invoices from Gmail with n8n and Gemini, then checking the IBAN before anyone pays it

Description and use

Automating invoice extraction from Gmail using n8n and Gemini, with IBAN validation via an API to prevent payment errors.

Problem

LLMs can extract invoice data but may misread an IBAN, leading to payment errors.

Outcome

Invoices are extracted, validated for math and IBAN correctness, and stored in Google Sheets with review flags for any issues, reducing payment errors.

Workflow

  • 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

Evidence

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.

Source

The ISO 13616 mod-97 checksum does. I put that, plus a few related checks, in a Cloudflare Worker:

Source

Up to 50 identifiers per batch request. Here's a real response from the keyless demo endpoint:

Source

  • Record date: 2026-10-18T09:56:24.176Z