How to Set Up Financial RAG Chatbot — Ask Questions About Your Bank Statement via Telegram in n8n

Your bank statement holds the answer to "where did the money go last month?" — but getting it out means opening a spreadsheet, filtering by category, and building a pivot table you'll never reuse. For

How to Set Up Financial RAG Chatbot — Ask Questions About Your Bank Statement via Telegram in n8n

Your bank statement holds the answer to "where did the money go last month?" — but getting it out means opening a spreadsheet, filtering by category, and building a pivot table you'll never reuse. For a founder reconciling burn or an ops lead tracking spend, that friction means the question rarely gets asked until it's a problem. A Financial RAG (Retrieval-Augmented Generation) chatbot flips this: your transactions live in a spreadsheet, and you ask questions in plain English over Telegram. "How much on food last month?" gets a real answer, computed from your actual data, in seconds. This article shows you how to build it in n8n with GPT-4o as the reasoning engine.

The Problem: Your Financial Data Is Locked Behind Tooling

Bank statements arrive as CSV exports or PDFs. Accounting software gives you dashboards someone else designed, answering questions you didn't ask. The moment you have a specific question — "what did I spend on SaaS subscriptions in Q2?" or "how much went to that one vendor?" — you're back to manual filtering.

The deeper issue is that this friction compounds. Founders defer financial questions because asking is expensive in time. Ops teams build brittle spreadsheets that break when a column moves. Nobody wants to write SQL against their transaction log at 11pm. What you actually want is to talk to your data — ask a messy, natural-language question and get a precise, grounded answer. That's exactly the gap RAG plus a chat interface closes.

The Solution: RAG Over Your Transactions, Delivered on Telegram

Retrieval-Augmented Generation means the language model doesn't answer from memory — it answers from your data, retrieved at query time. The model never hallucinates a number because every figure it reports comes from rows you actually own. The architecture is simple:

  • Storage: a Google Sheet (or Airtable) holds your transactions — date, description, category, amount.
  • Interface: Telegram, because it's where you already are and the bot API is trivial to wire up.
  • Brain: GPT-4o, which reads the retrieved rows and computes the answer.
  • Glue: n8n, orchestrating the trigger, retrieval, reasoning, and reply.

You send a message to your bot. n8n catches it, pulls the relevant transactions, hands them to GPT-4o with your question, and Telegram delivers the answer. No dashboard, no export, no SQL. The whole loop runs in under ten seconds on typical statement volumes.

Step-by-Step: Building It in n8n

Here's the node-by-node build. The workflow has one trigger and a short linear chain — deliberately simple so it stays maintainable.

1. Telegram Trigger

Add a Telegram Trigger node. Create a bot with @BotFather, copy the HTTP API token, and add it as a Telegram credential in n8n. Set the trigger to listen for message updates. The incoming user text lands in {{ $json.message.text }} and the chat ID in {{ $json.message.chat.id }} — you'll need the latter to reply to the right person.

2. Load the Transactions

Add a Google Sheets node set to Get Rows. Point it at your transactions sheet and return all rows. For statements under ~2,000 transactions this fits comfortably in a GPT-4o context window, so you can pass the full table and let the model filter. If your data is larger, add a Filter node or use a date-range query in the Sheets node to narrow rows before they hit the model — that keeps token cost down and answers fast.

3. Format the Context

Add a Set (or Code) node to compress the rows into a clean, token-efficient block. A Code node like this works well:

const rows = $input.all().map(i => i.json);
const table = rows.map(r =>
  `${r.date} | ${r.description} | ${r.category} | ${r.amount}`
).join('\n');
return [{ json: { table, question: $('Telegram Trigger').item.json.message.text } }];

This gives GPT-4o a pipe-delimited ledger it can reason over directly.

4. The GPT-4o Reasoning Node

Add an OpenAI node (or the AI Agent node with an OpenAI Chat Model) using model gpt-4o. Set the system prompt to constrain the model to your data:

You are a financial assistant. Answer ONLY using the transaction
data provided. Sum amounts precisely. If the answer isn't in the
data, say so. Format currency clearly and show your math briefly.

Transactions:
{{ $json.table }}

Question: {{ $json.question }}

Set temperature to 0 — you want deterministic arithmetic, not creativity. The instruction to answer only from the provided data is what makes this RAG rather than a chatbot guessing; it's the single most important line in the whole build.

5. Reply on Telegram

Add a Telegram node set to Send Message. Set Chat ID to {{ $('Telegram Trigger').item.json.message.chat.id }} and Text to the model output, typically {{ $json.message.content }} or {{ $json.choices[0].message.content }} depending on the node. Enable Markdown parse mode for clean formatting. Activate the workflow, message your bot, and you have a working financial assistant.

Loading Your Statement Into the Spreadsheet

The chatbot is only as good as the data behind it. Most banks export CSV — import it into your Google Sheet once and standardize four columns: date, description, category, amount. If your bank doesn't categorize, add a lightweight n8n workflow that runs each new transaction through GPT-4o to tag its category (Food, SaaS, Payroll, Travel) before it's stored. For ongoing use, schedule a weekly import so the bot always answers against current data. Keep amounts as plain numbers — strip currency symbols and thousands separators — so the model's arithmetic stays clean.

Benefits: Why This Beats a Dashboard

  • Zero query language. Anyone on the team can ask "how much on ads this quarter?" without knowing your schema.
  • Grounded answers. Every number is retrieved from your rows, so there's no hallucinated total to catch you out.
  • Lives where you work. Telegram means answers arrive on your phone, no app to open, no login.
  • Extensible. The same pattern works for invoices, expense reports, or CRM data — swap the sheet and the system prompt.
  • Cheap to run. A GPT-4o query over a few hundred rows costs a fraction of a cent; n8n self-hosted is free.

Common Pitfalls to Avoid

Passing too many rows. If you dump 10,000 transactions into every prompt, you'll blow the context window and inflate cost. Filter by date range in the Sheets node first, or add a pre-retrieval step that narrows to the relevant period based on the question.

Non-zero temperature. A creative model invents plausible-but-wrong sums. Always set temperature to 0 for financial math.

Dirty amount fields. Values like $1,204.50 or (340.00) for negatives confuse arithmetic. Normalize amounts to plain signed decimals during import.

No fallback for missing data. Without the "if it's not in the data, say so" instruction, the model will guess. Keep that line in your system prompt so users trust the answers.

Forgetting the chat ID reference. A common bug is hardcoding one chat ID — always pull it dynamically from the trigger so the bot replies to whoever asked.

Exposing sensitive data. Your transactions go to OpenAI's API. Use a business API tier with data-retention disabled, and never load account numbers or full card details into the sheet — you don't need them to answer spending questions.

That's the entire system: a Telegram trigger, a spreadsheet read, a formatting step, one GPT-4o call, and a reply. Ten minutes of wiring gives you a financial analyst that never sleeps and never guesses. Ask it anything about your money — it answers from the truth.

Financial RAG Chatbot — Ask Questions About Your Bank Statement via Telegram
PRONTO PARA USAR

Ja construimos isso pra voce

Nao comece do zero. O Financial RAG Chatbot — Ask Questions About Your Bank Statement via Telegram e um workflow n8n pronto para instalar — conecta suas ferramentas em minutos, sem codigo.

Instalar por $59 →