Using Agent node to maintain Telegram bot dialogs

Describe the problem/error/question

Hi,

We are testing the capabilities of the platform to create a Telegram bot based on N8N AI-Agent node. We are faced with the problem of the lack of ready-made instructions for preserving the context of the dialog with each new execution of the Telegram message trigger. For example, a user asks a question to a bot, the bot requests confirmation, and the next message should be recognized as confirmation and refers to the user’s previous request. Where and how is it better to store the context in order to maintain a dialogue with the user, as is done in the web version of ChatGPT?

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

Hi @fargofar, welcome to the community!

n8n trigger nodes (including the Telegram one) will not have any information about previous executions.

While ChatGPT’s web version will have built-in functionality to store and retrieve such data during user interaction, you would have to build this in your workflow when using n8n. For example, when receiving a new message, fetch the latest context you have stored for the chat ID in question.

I typically use a Postgres database to store and retrieve information from within my workflows, but the best approach here really depends on your own requirements.