n8n logon8n Automation Hub
Build breakdown

Building a Telegram AI Support Bot With n8n and Groq (With Real Memory)

Build breakdown · n8n workflow · August 24, 2026

The FAQ-bot version of this is easy — trigger, one LLM call, reply, done. What actually gets used in production needs two things that version doesn't have: it has to remember what was already said in the conversation, and it has to know when to stop pretending it has an answer and hand off to a person instead.

Workflow at a glance
  1. Telegram trigger receives the incoming message
  2. Load the user's recent conversation history from a Sheet, keyed by chat ID
  3. Send the message plus history to Groq for a context-aware reply
  4. If the model isn't confident it knows the answer, branch to a human-escalation path instead of guessing
  5. Save both sides of the exchange back to the history log
Screenshot of the actual n8n workflow canvas: Telegram Trigger, conversation history load, Groq LLM call, and the escalation branch

The actual workflow canvas, straight from my n8n instance.

Memory is a Sheet, not magic

There's no built-in "remember this conversation" switch — memory here is just the last several messages for that chat ID, pulled from a Sheet and formatted into the prompt before the model sees the new message. The two decisions that actually mattered: keying strictly by chat ID so conversations never bleed into each other, and clearing old history past a certain age so the context sent to the model doesn't grow indefinitely and slow every reply down. A typing-indicator step while all this happens turned out to matter more than I expected for how the bot feels to actually talk to — a silent multi-second pause before a Telegram reply reads as broken even when it isn't.

Teaching it to say "I don't know" on purpose

The harder design problem isn't the happy path, it's getting the model to admit uncertainty instead of confidently answering wrong. The fix that worked was structuring the prompt to explicitly separate "answer from known information" from "escalate" as two different outputs the model has to choose between, rather than just asking it to answer and hoping it hedges appropriately on its own. When it picks escalate, the workflow branches to a notification path instead of sending the model's guess to the user, and logs that case separately so I can see exactly what the bot couldn't handle.

The bug that made this fail with a "success" status

This one wasn't a design problem, it was a model-behavior problem I didn't see coming. Some of Groq's newer models spend part of their token budget on internal reasoning before producing the actual answer — invisible to you, but real, and it comes out of the same token limit as everything else. If that limit isn't sized with that hidden reasoning cost in mind, the actual JSON reply gets cut off mid-string, fails to parse, and a workflow with any kind of fallback-on-parse-error logic will silently return a blank or default response — execution shows success, nothing is actually wrong from n8n's point of view, and the bot just quietly stops working. I found this because a different bot went a full day without replying properly and nothing had errored. The fix was two settings, not a redesign: cap how much of the budget goes to reasoning, and size the token limit with enough headroom for both the hidden reasoning and the real answer.

Why I check every workflow after a model swap now

That bug didn't just hit one workflow — the same silent-failure pattern was sitting in five different automations that all happened to share the same model change, and only one of them was loud enough about it to get noticed immediately. The others kept reporting success while doing nothing useful. If you swap the underlying model on any LLM-calling workflow, that's the moment to go check every downstream JSON-parsing step, not just the one you were actually working on.

Want a support bot that actually knows when to hand off?

I build Telegram and web chatbots with real conversation memory and honest escalation, not a bot that guesses when it shouldn't.