2026-06-18
Automate Telegram With OpenClaw (2026)
Automate Telegram with OpenClaw: the steipete/telegram skill for bots, polling, webhooks, and channel workflows.
2026-06-11
Automate Telegram With OpenClaw (2026)
A practical guide to creating a Telegram bot via @BotFather, getting a token, configuring OpenClaw, and launching an AI agent in the messenger.
Telegram is no longer just a messenger for friends. Today it is a working channel: client requests, orders, service alerts, internal team notifications, chat moderation, leads from landing pages, and support flows. Dozens of working processes pass through Telegram every day.
The problem is that as the message flow grows, manual handling stops being enough. Replying to repetitive questions, classifying messages, filtering noise, tracking important topics, drafting replies — this is work an AI agent can run around the clock.
One of the fastest ways to give an agent a live channel in Telegram is to connect OpenClaw to Telegram through the official Bot API and the @BotFather bot. In this article, we will break down why Telegram is best integrated through a bot, what BotFather is, how to get a token, what steps are required for the bot to start working, and why a ready-made agent server is easier than manual setup.
This is the second article in the "How to connect X to OpenClaw" series — the first one covers Gmail. If you have already read How to automate Gmail with OpenClaw, you will notice that Telegram is significantly faster to set up: there is no Google Cloud, no OAuth Consent Screen, no keyring, and no refresh tokens. Just one token from BotFather.
What is OpenClaw?
OpenClaw is an open-source environment for running AI agents. Such an agent can work through Telegram or other channels, execute commands, use skills, access external services, and run as a persistent server process.
To put it simply, OpenClaw is not just a chatbot. It is an environment where AI gets access to tools: files, APIs, CLI commands, a browser, calendar, email, messengers, and other services.
For Telegram automation, OpenClaw itself is not the final goal. It acts as an agent runtime: the place where the agent lives, receives your commands, and calls the Telegram Bot API.
What is a Telegram bot and why BotFather?
There are two main ways to integrate third-party software with Telegram.
The first way is to connect through a user account. Technically possible: you give the agent your phone number, it impersonates you in Telegram. This is what some no-code builders and old scripts do. But this path:
- violates Telegram's terms of service;
- gets blocked easily under suspicious activity;
- requires storing and rotating session strings;
- breaks when you change devices, passwords, or two-factor auth.
The second way is the official Telegram Bot API. This is the path Telegram recommends. You create a special bot account: it has no phone number, no personal chats, no access to your account. Instead, it has:
- a unique username like
@my_company_bot; - a token for the API;
- a set of commands and descriptions;
- a clear permission model;
- webhook and long-polling support;
- built-in spam-protection mechanisms.
Bots are created through a special bot — @BotFather. This is Telegram's official tool, through which all bots in the system are registered. Without BotFather you get no token, no username, and no way to manage the bot.
In this article we will take the second path. It is the correct, supported, and safe way to connect.
Why Telegram is simpler than Gmail
If you have already connected Gmail to OpenClaw, you know what is involved there: create a project in Google Cloud, set up the OAuth Consent Screen, download a JSON file, complete OAuth authorization, configure a keyring, organize refresh-token storage, verify the agent runs under the same user the secrets live under. Many steps.
With Telegram everything is simpler. There is no OAuth, no Google Cloud, no Consent Screen, no keyring, no refresh tokens. One token from BotFather is enough.
But this does not mean Telegram has no complexities of its own:
- the token is effectively a password. If it leaks, anyone can run the bot;
- the token has to be passed correctly into the same environment where the OpenClaw agent runs;
- polling or webhook has to be configured properly — otherwise the bot either misses messages or wastes resources;
- in groups, by default, the bot only sees commands, not the full message stream;
- there are rate limits: 30 messages per second globally, 1 message per second per chat;
- if Telegram is blocked in your country, a proxy is required.
We will cover all of this step by step.
General flow for connecting Telegram to OpenClaw
The full path looks like this:
- Find @BotFather in Telegram.
- Create a new bot.
- Save the token.
- Set username, description, commands, avatar.
- Provide the token to OpenClaw.
- Start OpenClaw and verify the bot responds.
- Verify the bot works after a service restart.
- Optional: configure a webhook for production mode.
Step 1. Find @BotFather
Open Telegram and type @BotFather in the global search. Make sure the bot you find has a blue checkmark — that is the official Telegram account. Never send tokens, codes, or commands to bots that impersonate BotFather but do not have the checkmark.
Open the chat with BotFather and press Start. You will see the list of available commands:
/newbot— create a new bot;/mybots— open the menu of your existing bots;/token— get the token of an existing bot;/revoke— revoke the old token and issue a new one;/setname— change the display name;/setdescription— set the description shown before /start;/setabouttext— set the text in the bot's profile;/setuserpic— set the avatar;/setcommands— set the list of commands;/setprivacy— control the privacy mode in groups;/deletebot— delete the bot.
Step 2. Create a new bot
In the chat with BotFather, send:
/newbot
BotFather will ask you to set:
-
Bot name (name). This is what users see in the chat header. It can contain spaces, Cyrillic, any characters. Example:
GolemWorkers Assistant. -
Bot username (username). This is a unique handle like
@my_company_bot. It must:
- be unique across all of Telegram;
- end with
bot(for example,golemworkers_helper_bot); - contain only Latin letters, digits, and underscores;
- be 5 to 32 characters long.
If the username is already taken, BotFather will ask you to pick another. That is normal.
Once created, BotFather will issue a token of the form:
712345…xxxx
This token is the single key to managing the bot through the API. With it you can send messages, read inbound messages, add buttons, and manage chats. Treat the token like a password.
Step 3. Save the token
As soon as you receive the token, save it somewhere safe. Unlike BotFather, OpenClaw has no "history of issued tokens" — if you lose the token, you can only recover it through /token, which is an extra step.
Recommended storage:
# option 1: environment variable
export TELEGRAM_BOT_TOKEN=712345…xxxx
# option 2: secret file
mkdir -p ~/.config/openclaw/secrets
chmod 700 ~/.config/openclaw ~/.config/openclaw/secrets
echo -n "712345…xxxx" > ~/.config/openclaw/secrets/telegram-bot-token
chmod 600 ~/.config/openclaw/secrets/telegram-bot-token
Important: do not commit the token to git, do not write it to public logs, do not send it to Telegram chats "so you do not lose it." If the token leaks, an attacker can send messages on behalf of your bot. In that case, run immediately in BotFather:
/revoke
The bot gets a new token, and the old one stops working.
Step 4. Set description, commands, and avatar
Before connecting the bot to OpenClaw, it is worth spending a minute on the bot's metadata. It takes a moment and dramatically improves the user experience.
/setdescription
— a short text the user sees before pressing Start. This is usually where you write what the bot can do.
/setabouttext
— text shown in the bot's profile.
/setuserpic
— the avatar. Telegram accepts a square image.
/setcommands
— the list of commands, in the format:
start - start the bot
help - get help
status - check the agent's state
These hints appear when the user types / in the chat with the bot. Without them, the user does not know what can be called at all.
/setprivacy
— privacy mode. By default, in a group, the bot only sees commands that start with /. If the agent needs to process the full message stream in a group, disable privacy mode. For private chats this setting does not matter.
Step 5. Provide the token to OpenClaw
Once the token is saved, it has to be passed to the OpenClaw agent. The most reliable way is through an environment variable.
In the OpenClaw service configuration (systemd, supervisor, Docker, or a launch script), add:
TELEGRAM_BOT_TOKEN=712345…xxxx
If you prefer to keep the token in a file, OpenClaw also reads the value from ~/.config/openclaw/secrets/telegram-bot-token if the channel settings point to that file.
If you have the OpenClaw UI, go to Settings → Channels → Telegram → Add channel and paste the token through the interface. The UI usually stores the token encrypted, which is safer than a plaintext file.
After the token is saved, OpenClaw automatically:
- validates the token through
getMe; - detects the bot's username;
- starts long polling;
- registers the inbound message handlers.
Step 6. Verify the connection
Open Telegram, find your bot by username (for example, @golemworkers_helper_bot) and press Start.
Possible outcomes:
- The bot replies with a greeting — the token was read, polling works, OpenClaw is alive.
- The bot is silent — the token did not reach OpenClaw. Check the env, PATH, and the user the service is running under.
- "Bot not found" or "Unauthorized" — the token was typed incorrectly or was revoked. Re-check with
/tokenin BotFather.
A useful manual check that does not involve OpenClaw — a direct request to the Telegram API:
curl https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/getMe
If the response is JSON with ok: true and a bot description, the token is valid.
Step 7. Verify the bot works after a restart
A common situation: everything works in the current SSH session, but after restarting OpenClaw, the bot goes silent again. The cause is almost always the same — the environment variable is not picked up by the service.
Minimum check:
systemctl restart openclaw
Or, if OpenClaw is started differently, restart the process. After the restart, write the bot again. If it responds, the config is correct.
If the bot stays silent:
- check that
TELEGRAM_BOT_TOKENis set in the systemd unit's environment file (/etc/systemd/system/openclaw.service→ theEnvironment=section, orEnvironmentFile=); - check that OpenClaw and the token live in the
HOMEof the same user; - check OpenClaw logs: you will see whether the token reached the agent.
Example environment file for systemd:
PATH=/home/openclaw/.local/bin:/usr/local/bin:/usr/bin:/bin
TELEGRAM_BOT_TOKEN=712345…xxxx
Never store this file in a public repository. It should only exist in a protected server config.
Step 8 (optional). Enable webhook instead of long polling
By default, OpenClaw uses long polling: the agent periodically pulls updates from Telegram. This works almost everywhere, but has drawbacks:
- it holds a persistent connection;
- after multiple restarts, Telegram can briefly block polling;
- it does not scale well if you run multiple OpenClaw instances in parallel.
The alternative is webhook. In this mode, Telegram itself pushes updates to a URL on your server as soon as a new message appears.
For a webhook you need:
- a public HTTPS address with a valid certificate (Let's Encrypt is enough);
- an open port — 443, 8443, 80, or 88 (your choice);
- a correct URL like
https://your-domain.com/telegram-webhook/<token>; - a manual call to
setWebhookthrough the Telegram API or through the OpenClaw UI.
For most personal and SMB scenarios, long polling is enough. Webhook is worth enabling if you:
- run the agent in production under serious load;
- use multiple agents in parallel;
- want to minimize message delivery latency.
Optional: proxy if Telegram is blocked
In a number of countries (Russia, Iran, some regions), Telegram is partially or fully blocked. If your server is in such a country, OpenClaw will not be able to reach api.telegram.org directly.
Solutions:
- stand up a SOCKS5 / HTTPS proxy on a server in another country;
- set the proxy in the OpenClaw config (for example,
TELEGRAM_PROXY=socks5://user:pass@proxy:1080); - use a VPN tunnel at the OS level.
Without a proxy, the bot simply cannot reach Telegram: neither polling nor webhook will work.
What you can automate after connecting
Once the bot is connected to OpenClaw, the AI agent can run real scenarios.
1. Personal assistant in Telegram
The agent accepts commands, keeps a task list, sets reminders, saves notes, looks up information, and answers questions in context.
Example commands:
/task finish the Telegram article, deadline tomorrow/find the latest GA4 report/note client meeting moved to Thursday
2. Customer support in a group chat
The bot is added to a group where customer conversations happen. The agent:
- answers common questions from a knowledge base;
- classifies incoming requests by topic;
- hands complex cases to a human operator;
- collects feedback and ratings.
3. Channel and chat monitoring
The agent is subscribed to specific channels or invited into working chats. It:
- tracks posts by keywords;
- reacts to important events;
- pings you in DM when the right signal appears;
- keeps a feed of mentions.
4. Content pipeline
The bot accepts content ideas, texts, links, voice notes. The agent:
- transcribes voice notes through Whisper;
- classifies by topic;
- drops tasks into ClickUp / Notion / Sheets;
- sends finished drafts for review.
5. Lead capture from a landing page
A user leaves a request on the website → the bot messages them on Telegram instantly → qualifies them → pushes them to a CRM (AmoCRM, HubSpot, Pipedrive) → notifies the manager in the work chat.
6. Internal team notifications
A DevOps agent, an analytics agent, a content agent — all of them can post into one shared Telegram chat when:
- a build broke;
- metrics dropped;
- a new lead came in;
- an A/B test finished;
- a new art asset was published.
The main safety rule
A Telegram bot, unlike a human, can send hundreds of messages per second. If you give the agent full access to the bot with no restrictions, complaints from users and a Telegram-side ban come quickly.
Safe starting mode:
- The agent can read inbound messages and analyze context.
- The agent can create reply drafts.
- The agent does not send messages without confirmation.
- The agent does not send messages to chats the bot should not be writing to.
- The agent does not delete messages, change chat settings, or ban members without an explicit command.
- Before sending a message to a user, the agent shows a summary: to whom, what, why.
Minimum safe policy for the agent:
- Do not send messages without confirmation.
- Do not send more than N messages per minute.
- Do not post into chats the bot has not been invited to.
- Do not mute, ban, or delete messages without a command.
- Do not log the token, even partially.
- Log all outgoing messages for audit.
Why manual setup is not "5 minutes"
On paper it looks simple: find BotFather, create a bot, copy the token, paste it into OpenClaw. Three minutes.
In practice, problems appear quickly:
- the token is saved, but the env is not picked up by the service → the bot is silent;
- OpenClaw runs under the
openclawuser, but the token lives in root'sHOME; - polling works, but NAT or a firewall blocks Telegram from reaching the agent;
- the username is taken — you have to invent a new one;
/setcommandswas forgotten — the user does not know what the bot can do;/setprivacywas not set — the bot does not see regular messages in the group;- the token is in plaintext in
.env, which got committed to GitHub by accident; - the bot is active, but a similar username already exists on Telegram — users confuse the two;
- Telegram is blocked in the country — a SOCKS proxy is required;
- rate limit: a mass broadcast fails at 30 messages per second;
- webhook is set up, but the certificate is self-signed — Telegram refuses it;
- the agent sends messages on behalf of the bot with no confirmation — users complain;
- the bot is silent after
systemctl restartbecauseEnvironmentFileis not wired up; - the bot was blocked by a user, and the agent does not understand why
sendMessagereturns 403; - inline mode is enabled, but
/setdomainis missing — nothing works; - the bot was added to a group, but without admin rights it cannot read full history;
- the token leaked through CloudWatch logs — you have to do
/revokeurgently.
All of these are real situations teams hit the first time they set up a Telegram bot. And each one costs time.
How GolemWorkers makes this easier
If you want to give an agent a Telegram channel but do not want to manually configure a server, install OpenClaw, store tokens, wire envs, configure polling, and figure out proxies and rate limits, GolemWorkers handles all of it.
In GolemWorkers, Telegram is one of the ready-made channels you can connect in a few clicks: paste the BotFather token, and the agent immediately gets:
- secure token storage in an encrypted secrets manager;
- automatic choice between polling and webhook;
- bot health monitoring with an alert if the bot stops responding;
- ready-made templates for commands, descriptions, and avatars;
- support for multiple bots under different tasks;
- ready-made agents for typical scenarios: support, lead capture, monitoring, content pipeline, internal notifications;
- a built-in rate-limit governor so the bot does not get banned by Telegram;
- a proxy layer for cases where Telegram is blocked.
This is not magic. It is the same BotFather + OpenClaw + Telegram Bot API stack, just assembled, tested, and working out of the box.
If you want to see the contrast with a heavier integration, read How to automate Gmail with OpenClaw — that article shows the same shape of setup, with more moving parts.
Conclusion
Connecting OpenClaw to Telegram through BotFather is the fastest and most official way to give an AI agent a live channel in a messenger. Three minutes to create a bot, five minutes to configure OpenClaw — and you have a full-featured assistant in Telegram that can receive messages, reply, manage tasks, notify the team, and process requests.
Three things are worth remembering:
- the token is a password, and it should be stored like a private API key;
- the agent should not send messages without confirmation until you have verified it behaves correctly;
- long polling is simpler, but webhook is more reliable in production.
If you do not want to deal with systemd, env files, polling timeouts, and rate limits by hand, GolemWorkers ships a ready-made Telegram channel with the right defaults, monitoring, and agent templates.
Common pitfalls
- Skipping the planning phase — Teams that jump straight into prompt engineering usually spend weeks rebuilding once they hit edge cases. Spend 30 minutes mapping the trigger, the action, and the fallback before writing the first instruction.
- Treating the first successful run as done — A 90% pass rate still produces 1 wrong answer in 10. Set an explicit acceptance threshold (typically 99% for production) and instrument the agent to log when it falls short.
- Skipping audit logging — If you can't replay what the agent did three weeks ago, you can't debug it, bill it, or trust it. Persist every tool call with timestamps and inputs from day one.
- Not pinning dependency versions — A skill that worked in dev but breaks in prod because a transitive dependency bumped a major version is the most common automation outage. Pin everything in
package.json/requirements.txt.