When should you use it?
- People upload invoice photos to your system and some uploads are not invoices at all
- Your invoices mix Arabic and English, or Arabic-Indic and Western digits
- The invoices you receive carry a tax QR code you could decode instead of trusting a model's reading
Not for: Teams that only receive clean, machine-generated PDFs a regular parser already handles; Posting straight to your accounting ledger with no person checking flagged fields; Anyone not yet comfortable with webhooks, Code nodes and HTTP Request nodes in n8n
What do you need, and what do you get?
You need
- An upload form or app that sends the file to an n8n webhook, ideally decoding any QR code in the browser
- A model API key with image and PDF input
- The list of fields your back office needs and which of them are required
You get
- A JSON record per invoice with typed numbers, ISO dates and a confidence note on the seller name
- A list of required fields the model could not find, for a person to complete on screen
- A clear rejection for files that are not invoices, with the upload deleted
How does it work, step by step?
- Guard the entranceReceive the file on a webhook, compare a secret header against a value kept in a credential or environment variable, and answer 401 when it does not match.
- Keep the instructions in one placeStore the extraction instructions in a Set node so you can change them without opening the AI node, and have the very first key say whether the file is an invoice.
- Route by file typeSend images to the model's image input and PDFs as a file through an HTTP request with JSON output enforced. If a PDF already contains a text layer, try a cheaper text-only call first.
- Clean and override in codeIn a Code node, parse the answer, convert Arabic-Indic digits, strip symbols, round money to two decimals and, when decoded QR values arrive, replace the seller, tax number, date, total and tax with them.
- Refuse before storingWhen the gate says the upload is something else, return a rejection and delete the upload. Otherwise send the record on, with any missing required fields listed for a person to fill in.
The prompt
Our own prompt, inspired by Nour_Aldeen_Tofi and written to work in n8n, ChatGPT and Custom agent. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
You are the extraction step in my invoice intake workflow for {business}. I will give you one uploaded file (photo or PDF) and, when the upload screen could decode it, a separate block of QR data from the invoice. Invoices may be in {languages}. Reply with JSON only, using exactly these keys: is_invoice, seller_name, seller_name_confidence, seller_tax_id, invoice_number, issue_date, currency, subtotal, tax_total, total_amount, line_items (each with description, quantity, unit_price, line_total), missing, notes. Rules: 1. First decide whether the file is an invoice or receipt at all. If it is something else (a menu, a selfie, a bank screenshot, a blank page), set is_invoice to false, set every other field to null and say what the file appears to be in notes. 2. Only report what is printed. Use null for anything you cannot see. Do not estimate, calculate a missing total or fill in a likely seller. 3. Write numbers as plain numbers with Western digits, no currency symbols and no thousands separators. Write dates as YYYY-MM-DD. 4. If QR data is supplied, use it for the seller name, tax ID, date, total and tax, because it is exact. If the printed value disagrees with the QR value, keep the QR value and describe the difference in notes. 5. List any required field you could not find (seller_name, total_amount) in missing. A missing field does not make the file invalid; a person will fill it in. 6. Rate seller_name_confidence as high, medium or low, and use low for handwriting you had to guess at. After the JSON, on a new line starting with CHECKS:, list the checks my code step should run before saving anything: line totals against the subtotal, subtotal plus tax against the total, and any field where you were unsure.
Inspired by Nour_Aldeen_Tofi: n8n Community: reading Arabic invoices with n8n and a vision model, rejecting non-invoices and trusting the QR code. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- Letting the model decide what is valid. It should read; your code should check the math and required fields.
- Treating a missing field as a failed invoice. Return it for a person to complete instead of throwing the upload away.
- Assuming the QR code is always right. Log any disagreement with the printed figures so someone looks at it.
Our take
What sets this apart from the many invoice extraction workflows on the site is how little it trusts the model. Three choices do the heavy lifting. The model is allowed to say the upload is not an invoice at all, which matters once real customers start sending menus and screenshots. Everything numeric passes through ordinary code that converts digits and rounds money before anything is stored. And where an invoice carries a tax QR code, those exact values beat the model's reading for the fields that matter most to an accountant. He also reports that reading the text layer of PDFs first and using vision only as a fallback cut his model spend per document by about three quarters; your figure will depend on how many of your PDFs are scans. Our one caution is to treat the QR rule as a rule, not a guarantee. In our dry run for an invented Riyadh catering company, the model correctly rejected a lunch menu, left a smudged seller name and an illegible total empty rather than guessing, and on a test where the QR total did not match the printed total it kept the QR value but flagged that subtotal plus tax no longer added up. Make sure your workflow sends that kind of mismatch to a person.
Where the time goes back: Junk uploads are turned away before they reach your records, numbers arrive already in a usable format, and staff only type in the specific fields the model could not read instead of rekeying every invoice.
FAQ
Why decode the QR code in the browser rather than in n8n?
Can I download his workflow?
Does this only work for Saudi invoices?
Source and credit
Inspired by Nour_Aldeen_Tofi. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- n8n Community: reading Arabic invoices with n8n and a vision model, rejecting non-invoices and trusting the QR code
- Creator
- Nour_Aldeen_Tofi
- Published on
- n8n Community
- Original date
- Dec 2, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- n8n
- AI dry run
- Dec 3, 2026: passed. Dry-run tested by our AI test agent on sample input. Reject gate, no guessing, QR override with disagreement noted, and code-side checks listed. Synthetic files only; the author's n8n workflow was not built or run, and no real QR code was decoded.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Dec 3, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.