serverserv serverserv

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

Free download
6 nodes · tested on n8n 2.35 · MIT licence · no credentials included
Download JSON
Telegram messageTelegram TriggerOnly allowed usersIfAI AgentAI AgentOpenAI Chat ModelOpenAI Chat ModelChat memorySimple MemorySend replyTelegram
How the workflow is wired, from the trigger at the top. Dashed lines connect the AI model and memory to the agent.

How it works

  1. Telegram message receives every message sent to your bot.
  2. Only allowed users lets through messages from your Telegram user ID and drops everything else.
  3. AI Agent answers using the chat model and the Chat memory, which keeps the recent conversation for each chat.
  4. 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

  1. Create a bot with @BotFather and copy its token. In n8n, add it as a Telegram credential in Telegram message and Send reply.
  2. 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.
  3. Add your API key in OpenAI Chat Model and choose a model.
  4. 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

Plans from $3.99/moSee plans