How can I know when a Telegram reply is related to the previous message?

I’m making a Telegram bot that should follow certain paths based on the initial command (/start, /help etc…)

My current problem is when I ask for the user’s email.
I will probably ask for emails on other flows, so how can I know from which flow the reply is comming from, to continue with the correct flow?

If I’m using inline buttons, then it’s easy to use triggers that wait for Callback IDs. But when the user has to type the answer, I don’t know what to do.

Information on your n8n setup

  • n8n version: 1.27.3
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own,main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: ubuntu 22.04

You can save ur last request (for your case email) in the user’s as last conversation field(create a column in user database).

So every time when the user send a message you have to check what was ur last request then act accordingly.

If it is a long list of info then save it as json in user database field.

I’m no coder, sorry for my poor interpretation.

Thanks man! When you say database you mean creating a field with the Set node, right?

No, save it in your postgres database.

You have two callback trigger for telegram , but
You can have only one webhook for telegram, from there you have branch out for callback, message or whatever.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.