How do I start a /new session in Telegram?

Hi,

I have a pretty simple question. How do I do the equivalent of /new from within n8n?

My goal is to start a new session when it’s called from a specific webhook. So my original plan was to create two Telegram nodes: the first one with /new in it and wait for the response, and after that go to the next node. However, when I try it, I see that the /new is not treated as a command, but treated as a simple message.

Is this possible? If so, what’s the best way to do it?

Thanks,

L

hello @DupervalAI

Can you describe more? What is /new and which kind of session are you trying to re-establish?

Telegram node treats all commands as messages, so you should parse them accordingly

Are you looking to create a new chat for each incoming webhook call? @DupervalAI

Welcome @DupervalAI!

The Telegram node does receive /new as a message text (Telegram sends all bot commands as messages with the text starting with /), so you don’t need to send the command from n8n - you just need to detect it and react to it. Add an IF node right after your Telegram trigger checking {{ $json.message.text === '/new' }}, then in the “true” branch reset your session. How you reset depends on what “session” means in your workflow - if you’re using an AI Agent with a memory node (Window Buffer Memory, etc.), change the Session ID to a new value for that chat (e.g., append a timestamp: {{ $json.message.chat.id }}_{{ Date.now() }}), which effectively starts a fresh context. Send a confirmation back to the user via a Telegram node, then continue your normal flow in the “false” branch.

Oops, I just realized I forgot a teensy-weensy bit in my message: the Telegram bot is a front for a Hermes Agent. So, when I send messages to it, the information is supposed to go to a Hermes Agent.

After working on it more yesterday, I realized that the problem seems to be because I’m using a token for n8n to send a message to the Telegram bot. And because the n8n token is the same as the token of the Hermes bot, the bot does not reply because I think it believes it’s talking to itself. So any message that comes with the token of the bot is possibly ignored. When I send the message via n8n and I forward it manually in the same chat, then the agent reacts.

So now I’m looking for a solution where n8n can talk to the bot and not have the bot think that it’s talking to itself.

I’m not sure if that explanation makes any sense or not.

L

Oh, and to answer the question: /new is a Hermes command to tell the agent to start a new conversation, a bit like starting a new chat in ChatGPT, Claude or Gemini. Doing so prevents conversation drift, for one. But in my case, every conversation started by n8n needs a clean slate so I use /new to prevent “pollution” from existing information in the chat.

L

Thanks for all the answers you provided. I need to put all f that together to get a coherent view and test to see what works best for my purposes.

L