{"slug": "ai-invoice-data-extractor-free-n8n-workflow-template-from-the-ingenify-youtube-4", "title": "AI Invoice Data Extractor - free n8n workflow template from the Ingenify YouTube build (Claude Code + n8n + gpt-4.1, hallucination trust guard).", "summary": "Pankaj Pahuja of Ingenify built a free n8n workflow template that extracts invoice data from PDFs, scanned PDFs, and photos into Google Sheets, with a trust guard that blanks fabricated fields. The guard checks each extracted value against the source text and flags rows as 'NEEDS REVIEW' if any field fails verification, preventing hallucinated data from entering the books.", "body_md": "Drop an invoice into a Google Drive folder. A minute later the vendor, invoice number, dates, subtotal, tax, total, currency and line items are sitting in a Google Sheet row. PDFs, scanned PDFs and phone photos of paper bills all work.\n\nBuilt by [Pankaj Pahuja](https://ingenify.ai). Free to use, change, and pull apart.\n\n**The full build, including the part where it invented an invoice that did not exist:** [https://youtu.be/oSlq1rAV8XA](https://youtu.be/oSlq1rAV8XA)\n\nEvery invoice-extraction demo you have seen works on a clean invoice. Mine did too, until I fed it a document that was not an invoice and it confidently filled every field with plausible, completely fabricated data. A vendor name. A total. A tax figure. None of it was in the document.\n\nThat is the failure mode nobody films, and it is the one that matters, because a wrong number in your books is worse than no number at all.\n\nSo there is a **trust guard** after every extraction path. It takes each field the model returned and checks the value actually appears in the source text before letting it through. If it does not appear, the field is blanked rather than saved. The row still gets written, but it is flagged `NEEDS REVIEW`\n\ninstead of `OK`\n\n.\n\nThe AI reads. The code decides what is allowed to be true.\n\n```\nInvoice lands in Drive folder\n        |\n    Download file\n        |\n   Is it an image?\n    /            \\\n  yes             no (PDF)\n   |               |\nVision read    Extract text layer\n   |            /            \\\n   |     has text?          no text (scanned)\n   |         |                    |\n   |    Structured          Send whole PDF\n   |    extraction          to the model\n   |         |                    |\n   +---> TRUST GUARD <------------+\n              |\n     Append row to Google Sheet\n        Status: OK / NEEDS REVIEW\n```\n\nThree routes in, one guard, one sheet. Twelve nodes total.\n\n| Route | When it fires | How it reads the file |\n|---|---|---|\n| Photo | mime type contains `image` |\nVision model, high detail, transcribes then extracts |\n| Text PDF | PDF with a real text layer | Text extraction plus n8n's Information Extractor with a strict JSON schema |\n| Scanned PDF | PDF whose text layer is empty | Whole PDF posted to the OpenAI Responses API as a document |\n\nThe scanned-PDF branch is the one most templates skip. A photocopied or faxed invoice has no text to extract, so a text-only pipeline silently produces an empty row and you never find out.\n\n-\nIn n8n:\n\n**Workflows → Import from File**, pick`ai-invoice-extractor-template.json`\n\n. -\nConnect three credentials:\n\n**Google Drive OAuth2**,** Google Sheets OAuth2**,** OpenAI**. Every node that needs one will show a red warning until you pick it. -\nSearch the workflow for\n\n`YOUR_`\n\nand replace two placeholders:`YOUR_DRIVE_FOLDER_ID`\n\non the trigger, the folder you will drop invoices into`YOUR_GOOGLE_SHEET_ID`\n\non the sheet node\n\n-\nCreate a sheet named\n\n`Sheet1`\n\nwith these headers in row 1, spelled exactly:`Timestamp · File Name · Vendor · Invoice Number · Invoice Date · Due Date · Subtotal · Tax · Total · Currency · Line Items · Status`\n\n-\nActivate, then drop a real invoice in the folder and watch it run.\n\nThe trigger polls every minute. Free n8n Cloud plans throttle polling, so on those you may see a delay or want to switch the trigger to a schedule.\n\nA row is marked`NEEDS REVIEW`\n\nis the feature, not a bug.`OK`\n\nonly when vendor, total, invoice number and currency all survived the guard. Anything else gets flagged. Sort your sheet by that column and you have a work queue instead of a pile of maybe-wrong data.**The guard is deliberately strict, so it will sometimes blank a correct value.** A vendor name that is printed as a logo image rather than text will not be found in the text layer, so it gets blanked. That is the trade I chose. A blank you can see beats a fabrication you cannot.**Currency has a deterministic fallback.** If the model leaves it empty, plain code reads the symbol off the document. £ is GBP, € is EUR, ₹ is INR, and a bare $ defaults to USD unless the address mentions Canada or Australia. Change that default if you are not US-first.**The timestamp is hardcoded to** I am in India. Change it on the sheet node.`Asia/Kolkata`\n\n.**Model is**, at temperature 0 on the two PDF routes. Temperature 0 matters here, you want the same document to produce the same answer every time. The vision node does not expose a temperature setting, which is one more reason the guard sits downstream of all three.`gpt-4.1`\n\non all three routes**Cost is small but not zero.** Every file hits a model, and the scanned and photo routes send the whole document. Point the trigger at a folder you control, not a shared inbox folder, or one bad sync will process a thousand files.**This reads invoices. It does not pay them, approve them, or file them.** No write path touches your accounting system, on purpose.\n\nThe workflow was designed and pushed to n8n from Claude Code over the n8n API rather than clicked together node by node. The trust guard exists because the build broke on camera and the fix had to be real. That whole sequence, including the fabricated invoice, is in the video.\n\nQuestions: [hello@ingenify.ai](mailto:hello@ingenify.ai)", "url": "https://wpnews.pro/news/ai-invoice-data-extractor-free-n8n-workflow-template-from-the-ingenify-youtube-4", "canonical_source": "https://gist.github.com/pkpahuja/98005077d8373bc161e475833a1df367", "published_at": "2026-07-09 14:59:21+00:00", "updated_at": "2026-07-25 19:28:22.778507+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "ai-tools", "ai-agents", "developer-tools"], "entities": ["Pankaj Pahuja", "Ingenify", "n8n", "OpenAI", "Google Drive", "Google Sheets", "Claude Code", "GPT-4.1"], "alternates": {"html": "https://wpnews.pro/news/ai-invoice-data-extractor-free-n8n-workflow-template-from-the-ingenify-youtube-4", "markdown": "https://wpnews.pro/news/ai-invoice-data-extractor-free-n8n-workflow-template-from-the-ingenify-youtube-4.md", "text": "https://wpnews.pro/news/ai-invoice-data-extractor-free-n8n-workflow-template-from-the-ingenify-youtube-4.txt", "jsonld": "https://wpnews.pro/news/ai-invoice-data-extractor-free-n8n-workflow-template-from-the-ingenify-youtube-4.jsonld"}}