{"slug": "n8n-ai-telegram-chatbot", "title": "n8n : AI Telegram chatbot", "summary": "N8n, a source-available low-code workflow automation platform, now enables users to build an AI-powered Telegram chatbot without extensive coding. By connecting a Telegram trigger node to a Google Gemini Chat Model via an AI Agent node, users can create a bot that understands messages and generates responses using a free API key from Google AI Studio. The platform handles the complex integration, requiring only the configuration of credentials and API tokens through a drag-and-drop interface.", "body_md": "n8n is a source-available, low-code workflow automation platform that allows users to automate repetitive tasks, integrate multiple apps and services, and build complex workflows with or without extensive coding knowledge.\n\nYou can use n8n in cloud (14 days in free trial), or in local by running a docker image of the official n8n's image in docker hub.\n\ninstall n8nio/n8n image then run the next command:\n\n```\ndocker run -it --rm --name n8n -p 5678:5678 -e GENERIC_TIMEZONE=\"Africa/Casablanca\" -e TZ=\"Africa/Casablanca\" -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true -e N8N_RUNNERS_ENABLED=true -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n\n```\n\nyou can change the timezone\n\nthen create an account and you will be redirected to the n8n dashboard to create your first workflow\n\nbut in this post we will work with n8n in cloud by creating an account for free, and use the free trial, then you will have a hosted n8n instance on the web to automate tasks using various apps without problems.\n\nIn this post we will build a Telegram bot connected with n8n:\n\nfirst of all create a bot in your telegram account using BotFather, follow instructions to create your personal bot.\n\nThen create a personal workflow in n8n dashboard:\n\nevery workflow starts with a trigger as a first step, the trigger is the event listener that really executes the workflow, it can be a mouse click, message input, webhook but in this example our trigger is a telegram message, so click on the plus canvas and search for \"**telegram**\" and select **On message** trigger.\n\nThen the configuration window appear :\n\nclick on **Set up credentials**, and put your access token (You can get the access token of your chatbot from **BotFather** by sending \"**/token**\" then the username of your bot\n\nand click save (A success toast appear at the right bottom if the connection is successfully settled between n8n and telegram)\n\nNow our workflow is ready to receive messages from the bot, you can test that by double clicking on the node and click on **Execute step** to pull events from telegram, then send a new message from bot, you will see an output in the right side of the window contains meta data of your message , which means the trigger is successfully receiving message from telegram.\n\nNow you have a plus icon to add more nodes to complete your workflow, click on it\n\nAnd add an AI Agent Node\n\nNow we need to configure our Agent with a AI model to use to generate responses and a memory storage to conserve previous chats.\n\nclick on Chat Model's plus and choose **Google Gemini Chat Model**\n\nWe will use **Gemini 2.5 flash** model api key, it is completely free and you can get it from **Google AI studio** ([https://aistudio.google.com/](https://aistudio.google.com/)), create a new project an copy paste the api key into the credentials section of your node.\n\nAnd that is it ! you have a real AI modal connected to your Agent, Now he can generate responses after understanding messages, that is the power of low-code tools, it does not require a lot of technical knowledge about AI Agents and coding, it's just about drag and drop and configure credentials and api tokens.\n\nn8n offers a lot of AI models to use, all what you have to do is copy and paste the api key.\n\nSo when you have a conversation whit someone, it's always essential to keep remembering the paste chats and ideas to keep chating and interacting with him, that 'remembring' part is the memory storage in AI Agents world, the agent use the memory tool to store previous chats and interactions.\n\nWe will use a Simple Memory, you can of course use you favorite database as a memory that's will be more efficient then using the memory node offered by n8n, but that will serve us in more complex workflows.\n\nChange the session ID to **Define Below** and copy paste this line of code into the key input :\n\n```\n{{ $('Telegram Trigger').item.json.message.chat.id }}\n```\n\nTools are representing apps to use by the AI agents like for example google calendar to retrieve appointments or google sheet to store some data etc ...\n\nbut in our chatbot workflow we will use **Think Tool**, to push the agent to think before responding.\n\nNow we after generating the message we need to finish the workflow by the node that will send the message to the telegram bot as response, to that add **Send a text message node**.", "url": "https://wpnews.pro/news/n8n-ai-telegram-chatbot", "canonical_source": "https://dev.to/khalid_edaoudi_f60d2bbc68/n8n-ai-telegram-chatbot-24d5", "published_at": "2026-05-26 14:57:14+00:00", "updated_at": "2026-05-26 15:04:17.436216+00:00", "lang": "en", "topics": ["ai-tools", "ai-products", "ai-agents", "ai-infrastructure", "ai-startups"], "entities": ["n8n", "Telegram", "BotFather", "Docker"], "alternates": {"html": "https://wpnews.pro/news/n8n-ai-telegram-chatbot", "markdown": "https://wpnews.pro/news/n8n-ai-telegram-chatbot.md", "text": "https://wpnews.pro/news/n8n-ai-telegram-chatbot.txt", "jsonld": "https://wpnews.pro/news/n8n-ai-telegram-chatbot.jsonld"}}