Private Telegram AI assistant: free n8n workflow template
By the serverserv team · 3 min read · Updated
Build your own AI assistant on Telegram in about ten minutes. It answers with the model of your choice, remembers the last ten messages of each chat, and only talks to the Telegram users you allow, so nobody else can run up your AI bill.
Download the template
How it works
- Telegram message receives every message sent to your bot.
- Only allowed users lets through messages from your Telegram user ID and drops everything else.
- AI Agent answers using the chat model and the Chat memory, which keeps the recent conversation for each chat.
- Send reply sends the answer back to the same chat.
Nodes used: Telegram Trigger, If, AI Agent, OpenAI Chat Model, Simple Memory, Telegram.
What you need
- A Telegram bot token from @BotFather
- An OpenAI API key, or another chat model
- An n8n instance reachable over HTTPS, because Telegram delivers messages by webhook
Set it up
- Create a bot with @BotFather and copy its token. In n8n, add it as a Telegram credential in Telegram message and Send reply.
- Find your Telegram user ID (for example by messaging @userinfobot) and put it in Only allowed users instead of 123456789. Add more IDs with extra conditions set to OR.
- Add your API key in OpenAI Chat Model and choose a model.
- Activate the workflow and message your bot.
New to importing? In n8n, open a new workflow, then either paste the copied JSON onto the canvas or use the menu (the three dots) and choose Import from file. Credentials are never included, so you connect your own accounts after importing.
Ways to customise it
- Give the agent tools: a calculator, web search, your Google Calendar or an HTTP Request tool for your own API.
- Swap the simple memory for Postgres or Redis chat memory so conversations survive restarts.
- Change the system message to make it a support bot for your business instead of a personal assistant.
Security notes
Keep the allowed-users check. Without it anyone who finds your bot can use your AI credits. The simple memory lives in n8n's process memory, so it is cleared when n8n restarts; use a database memory if you need it to last.
Where to run it
Templates with webhooks or triggers need n8n running all the time and reachable over HTTPS. You can run n8n on your own computer to try it, but for real use it belongs on a server. serverserv n8n Hosting gives you n8n pre-installed on your own KVM server with HTTPS, from $14.99 a month with no execution limits, and we will set up your first workflow for you, this one included.
Questions
Is this the same as OpenClaw?
No. This is a simple bot built in n8n. OpenClaw is a full AI agent with its own skills, memory and many chat channels. Both run well on your own server.
Can it reply in groups?
Yes, if you add the group's members to the allowed list and turn off privacy mode for the bot in @BotFather. Most people keep it private.
Is this n8n template free to use?
Yes. It is free under the MIT licence, for personal and business use. You need your own n8n instance and your own accounts for the connected apps.
Sources
Related
Website form to Google Sheets and Slack
send website contact form leads to Google Sheets and Slack, with email validation and a reply to the form.
n8n templateView →AI reply drafts for Gmail
Free n8n workflow that writes an AI reply draft for every new Gmail message and saves it in the same thread. N
n8n templateView →AI lead scoring with Slack alerts
score each new lead from 1 to 10 with AI against your ideal customer, log every lead to Google Sheets and aler
n8n templateView →