How to Use n8n with ._Template 129 Relatorio Despesas Foto Recibo
Every expense report starts as a photo. A crumpled receipt on a car seat, a PDF invoice buried in an inbox, a screenshot of a card charge. Someone — usually your most expensive person — then retypes t
Every expense report starts as a photo. A crumpled receipt on a car seat, a PDF invoice buried in an inbox, a screenshot of a card charge. Someone — usually your most expensive person — then retypes the vendor, the date, the amount, and the category into a spreadsheet or an accounting tool. Multiply that by a sales team of ten and you lose a full workday every week to manual transcription that a machine does faster and more accurately. Template 129 (Relatório de Despesas por Foto de Recibo) closes that gap: a receipt photo goes in, a structured, categorized, ready-to-approve expense line comes out.
The Problem: Receipts Don't Structure Themselves
Receipt data is the hardest kind of data to work with. It's unstructured (free-form thermal-printer text), inconsistent (every vendor formats totals differently), multilingual, and often photographed at an angle in bad lighting. Traditional OCR gives you a wall of text but no meaning — it can't tell you which number is the tip, which is the subtotal, and which is the grand total.
The downstream cost is worse than the transcription time. Manual entry produces category errors that break your P&L, duplicate submissions that inflate reimbursements, and month-end scrambles where finance chases missing receipts. For a founder tracking runway, unreliable expense data means you're steering by a broken instrument. You need the extraction to be automatic, structured, and trustworthy enough to feed straight into approvals.
The Solution: Vision Models + n8n as the Glue
Modern vision-capable LLMs read a receipt image and return structured JSON in a single call — vendor, date, currency, line items, tax, total, and a suggested category. n8n is the orchestration layer that catches the incoming photo, sends it to the model, validates the output, and writes it wherever your team already works (Google Sheets, Airtable, Notion, QuickBooks, or a Slack approval thread).
The architecture is deliberately simple: a trigger receives the image, an AI node extracts fields, a code node validates and normalizes, and an output node persists the record. Because n8n handles retries, error branches, and credentials natively, you get a production-grade pipeline without writing a backend. The whole workflow is one screen of nodes.
Step-by-Step Setup in n8n
Here's the concrete build. Each step maps to one or two nodes.
1. Trigger the workflow. Add a Telegram Trigger (or Email Trigger (IMAP), or a Webhook node) so employees submit receipts through a channel they already use. Telegram is ideal for mobile teams: they photograph a receipt and send it to a bot. Configure the trigger to listen for the message update type and enable "Download Image" so the binary file lands in the workflow.
2. Fetch the image binary. If your trigger only returns a file ID (Telegram does), add a Telegram → Get File node to pull the actual image into a binary property named data. For email, the IMAP node exposes attachments directly.
3. Extract with a vision model. Add the Anthropic Chat Model node (or use the Basic LLM Chain with an Anthropic credential). Point it at claude-opus-4-8 for maximum accuracy on messy receipts, or claude-haiku-4-5 when you're processing high volume and want lower cost and latency. Pass the binary image as an image content block and use a prompt like:
"Extract the following fields from this receipt as strict JSON: vendor, date (ISO 8601), currency (ISO 4217), subtotal, tax, total (numbers only), and category (one of: meals, travel, lodging, software, office, other). If a field is missing, use null. Return only JSON."
4. Force structured output. Attach a Structured Output Parser to the LLM node and define the schema. This guarantees the model returns valid, typed JSON instead of prose — critical for the next step. In n8n's AI Agent nodes you can also enable "Require Specific Output Format" and paste a JSON schema.
5. Validate and normalize. Add a Code node (JavaScript). Here you enforce business rules the model can't know: coerce the amount to two decimals, reject totals of zero, flag duplicates by hashing vendor + date + total, and stamp the submitting employee's ID from the trigger metadata. Throw an error here to route bad extractions to a review branch instead of your ledger.
6. Branch on confidence. Add an IF node. If total is null or the category is "other", route to a human-review path (a Slack message asking the employee to confirm). Otherwise, continue to auto-approval. This keeps the automation fast for clean receipts and safe for ambiguous ones.
7. Persist the record. Add a Google Sheets → Append Row node (or Airtable, Notion, or the QuickBooks node) mapping each JSON field to a column. Include the original image URL so approvers can audit the source.
8. Notify and close the loop. Finish with a Slack or Telegram node that replies "Expense logged: $X at [Vendor], category [Y]." Instant feedback stops employees from re-submitting the same receipt.
The Benefits: Speed, Accuracy, and an Audit Trail
The measurable wins stack up fast. Extraction that took two minutes per receipt manually drops to under ten seconds and requires zero human keystrokes for clean submissions. Category consistency goes from "whatever the employee guessed" to a controlled vocabulary the model applies uniformly, which means your expense reports actually reconcile at month-end.
Because every record carries the source image and a timestamp, you build an audit trail automatically — invaluable for tax season and any future due diligence. And since the pipeline is event-driven, it scales linearly: ten receipts or ten thousand, the workflow doesn't change and you're not hiring a data-entry temp in Q4. For a lean ops team, that's the difference between finance being a bottleneck and finance being background noise.
Common Pitfalls (and How to Avoid Them)
Skipping the structured output parser. If you let the model return free text and parse it with a regex, you'll fail the first time a receipt has an unusual layout. Always enforce a JSON schema at the LLM node — it's the single biggest reliability lever.
Sending giant images. Phone photos can be 8–12 MB. Add a Edit Image node (resize to ~1500px on the long edge) before the LLM call to cut token cost and latency without hurting accuracy — receipts are legible well below full resolution.
No duplicate detection. Employees will submit the same receipt twice. Without the hash check in your Code node, you'll double-count reimbursements. Store recent hashes in a data store node or a dedicated sheet column and reject collisions.
Trusting the total blindly. Vision models occasionally grab the subtotal or a line item instead of the grand total. A cheap safeguard: have the model return subtotal, tax, and total separately, then assert subtotal + tax ≈ total in your Code node and flag mismatches for review.
Hard-coding credentials. Use n8n's built-in credential store for your Anthropic key, Telegram token, and Sheets OAuth. Never paste secrets into node parameters — it breaks sharing and leaks keys in exported workflows.
Build it once, wire in your own channel and ledger, and Template 129 turns the most tedious task in your finance stack into an invisible background process — one that gets your team's receipts logged before they've even put their phone back in their pocket.