This time Eduard and Yulia wrote a tutorial where you can learn how to create an AI-powered Telegram chatbot that is able to send text messages and AI-generated images. The overall principle of creating Telegram bots is explained, so you can use the workflow template as a starter for your own bots.
Which kind of Telegram bots do you have in n8n?
Share your experiences below, and let’s inspire and learn from one another!
How do i add the chat history to this telegram flow? As of now the chatbot only replies to the last message sent and doesn´t consider the messages before
Thanks for your question! Generally, you will need to have some kind of storage where you add all user messages and bot’s replies. It is also important to keep user’s Telegram ID so that each user has its own conversation with the bot.
An easy solution would be NocoDB, Baserow (if we speak about open-source tools). Airtable is also fine for super-small bots. Alternatively you can create a proper SQL database. In all cases n8n has built-in nodes for working with NocoDB, Baserow, Airtable and PostgreSQL / MySQL.
The trickiest part is to prepare a JSON with message history for the GPT API. You’ll probably need to use a Code node to prepare a valid array (check the red box):
Finally, an HTTP Request node is needed, because the default OpenAI node doesn’t support dynamic arrays. But this is rather easy, because OpenAI credentials can be re-used in the HTTP Request node.
Following the growing interest in Telegram bot creation, we’ve just published a new guide on the 11 best Telegram bots!
Explore the top bots in our latest blog and learn how to create a simple yet useful echo-bot with n8n, enhancing your Telegram experience. Check it out here!