I built an AI expense tracker: Telegram message, processed by Gemini and recorded Google Sheets (beginner-friendly, open source)

Hi everyone,
I’m still fairly new to n8n, and I wanted a project that goes beyond “form → spreadsheet”. So I built a small expense tracker and put it on GitHub in case it helps other beginners.
How it works:
You send a plain message to a Telegram bot, like “Lunch 850 at KFC”. Gemini turns that into structured data (amount, currency, category, merchant, date). n8n saves it to a Google Sheet and the bot replies with a confirmation.
The flow:
Telegram Trigger → IF (is it me?) → AI extraction → IF (is the result valid?) → Google Sheets → Telegram reply
If the AI can’t find an amount, the bot asks you to try again instead of saving junk.
Things I learned that might save you some time:

  • A Structured Output Parser plus temperature 0 gave me clean JSON far more reliably than just asking for JSON in the prompt.
  • Don’t trust AI output blindly. I added an IF node that checks “valid” is true and the amount is above 0 before anything reaches the sheet.
  • After the AI node, $json holds the AI output, not the original message. To get the original text, I had to reference the earlier node, like $(‘Telegram Trigger’).
  • The IF node only accepts my own chat ID, so anyone who finds the bot gets ignored.
  • Only one active workflow can use a Telegram bot at a time, so don’t leave a test listener running next to an active one.
  • Set the date column in Sheets to plain text, or dates get converted.
    The repo has the sanitized workflow JSON, the exact prompt, sample test messages (including ones that should be rejected), a troubleshooting table, and a note on swapping Telegram for a Webhook in case Telegram isn’t available where you are.
    Repo: GitHub - codewithghani/n8n-ai-expense-tracker-telegram-google-sheets: Send expenses to a Telegram bot, let Gemini extract the details, and log them to Google Sheets with n8n. · GitHub
    I’d really appreciate feedback, especiall

Nice project, Usman! I like that you’ve added validation before writing to Google Sheets and restricted access using the Telegram chat ID.

One additional edge case worth testing is duplicate processing—for example, if the same Telegram message is delivered or processed twice. An idempotency check could help prevent duplicate expense entries. I’d also test how the workflow handles Gemini timeouts and malformed structured output.

I work with n8n, Python, APIs, and PostgreSQL, focusing on reliable processing, validation, and error handling. I’d be interested in contributing to practical workflow testing or implementation if you need extra support.

Are you planning to extend this into a more production-ready workflow?

thanks, i have incorporated

Hey there! This is a fantastic workflow, and you’ve put together a great write-up with some really practical tips. I especially like the Structured Output Parser + temperature 0 combination for reliable JSON, along with the validation IF node. Awesome work getting the AI output into Google Sheets!

My team and I built the easybits Extractor to simplify extracting clean, structured JSON from documents. It could be a useful option if you’re looking to streamline that part of the workflow. Another advantage is that you can keep the process deterministic rather than relying on an AI agent for the extraction step. Agents can sometimes hallucinate or behave unpredictably, and when you’re processing invoices in production, that’s something you want to minimize as much as possible.

Here’s my invoice intake template if you’d like to check it out:

Thanks for sharing your build, and keep on building! :slightly_smiling_face:

1 me gusta

surely, i would

1 me gusta