{"slug": "extracting-invoices-from-gmail-with-n8n-and-gemini-then-checking-the-iban-before", "title": "Extracting invoices from Gmail with n8n and Gemini, then checking the IBAN before anyone pays it", "summary": "A developer built a free n8n template that uses Gemini to extract vendor, total and bank details from Gmail invoices, paired with a separate Cloudflare Worker API that validates IBANs via the ISO 13616 mod-97 checksum and EU VAT numbers through VIES. The API batches up to 50 identifiers per request, returns a reason rather than a false \"invalid\" when VIES is throttled, and flags failed checks as \"needs review\" so a human sees why a row was flagged.", "body_md": "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 risky part is that an LLM can read a perfectly formatted IBAN with one wrong digit, and nothing downstream notices.\n\nThis post walks through a free n8n template that handles the extraction, and a small API I built that handles the checksum part. They're separate pieces: the template doesn't call the API out of the box. I'll show how to add it.\n\nNodes, in order:\n\n`invoices` with a PDF attached.`needs_review`.\nSetup takes about 10 minutes: a Gmail label and filter, a sheet with an `Invoices` tab, and three credentials (Gmail, Sheets, a free Gemini key from Google AI Studio).\n\nTwo things that made it more reliable:\n\nExtraction confidence doesn't tell you whether an IBAN is real. The ISO 13616 mod-97 checksum does. I put that, plus a few related checks, in a Cloudflare Worker:\n\nUp to 50 identifiers per batch request. Here's a real response from the keyless demo endpoint:\n\n```\ncurl \"https://invoice-validator.mohamed-bahaa53000.workers.dev/demo/v1/iban?value=DE89370400440532013000\"\n{\n  \"iban\": \"DE89370400440532013000\",\n  \"country\": \"DE\",\n  \"check_digits\": \"89\",\n  \"bban\": \"370400440532013000\",\n  \"valid\": true,\n  \"formatted\": \"DE89 3704 0044 0532 0130 00\",\n  \"sepa\": true,\n  \"errors\": []\n}\n```\n\nThe demo allows 10 calls per IP per day without a key.\n\nWhy a Worker rather than an n8n Code node? Mostly reuse: the same check is useful from Make, Zapier or a backend, and it's stateless, so it runs at the edge in milliseconds. It also isolates the slow part. VIES throttles by member state, so when it's unavailable the API returns `checked: false` with a reason instead of a false \"invalid\".\n\nAfter Normalize Invoice, add an HTTP Request node:\n\n`/v1/batch` endpoint from the RapidAPI listing`X-RapidAPI-Key` and `X-RapidAPI-Host`\n\n```\n{\n  \"items\": [\n    { \"id\": \"INV-1042-iban\", \"type\": \"iban\", \"value\": \"DE89370400440532013000\" },\n    { \"id\": \"INV-1042-vat\", \"type\": \"eu_vat\", \"value\": \"DE123456789\", \"live\": true }\n  ]\n}\n```\n\nIn n8n, map each value with an expression from the previous node, for example $json.invoice_number, $json.vendor_iban and $json.vendor_vat.\n\nYou'll need to add `vendor_iban` and `vendor_vat` to the Gemini schema first. Then treat `valid: false` as \"needs review\", and `checked: false` from VIES as \"verify manually\", not as a rejection. A person sees exactly why a row was flagged.\n\nFeedback on either is welcome, especially edge cases where the extraction or the validation gets it wrong.", "url": "https://wpnews.pro/news/extracting-invoices-from-gmail-with-n8n-and-gemini-then-checking-the-iban-before", "canonical_source": "https://dev.to/member_bb10b304/extracting-invoices-from-gmail-with-n8n-and-gemini-then-checking-the-iban-before-anyone-pays-it-27fe", "published_at": "2026-10-18 08:41:33+00:00", "updated_at": "2026-10-18 08:44:33.240308+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "generative-ai"], "entities": ["n8n", "Gemini", "Google AI Studio", "Cloudflare Workers", "VIES", "RapidAPI"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/extracting-invoices-from-gmail-with-n8n-and-gemini-then-checking-the-iban-before", "markdown": "https://wpnews.pro/news/extracting-invoices-from-gmail-with-n8n-and-gemini-then-checking-the-iban-before.md", "text": "https://wpnews.pro/news/extracting-invoices-from-gmail-with-n8n-and-gemini-then-checking-the-iban-before.txt", "jsonld": "https://wpnews.pro/news/extracting-invoices-from-gmail-with-n8n-and-gemini-then-checking-the-iban-before.jsonld"}}