Table of Contents
- Video walkthrough
- Prerequisites
- Step 1: Create a Telegram bot (BotFather)
- Step 2: Open your instance's Channels tab
- Step 3: Paste your bot token (Step 1 of 2)
- Where the token lives (config and environment)
- Step 4: Pair the bot (approve pairing code)
- Step 5: Restart and test
- Who can DM your bot: dmPolicy and the allowlist
- Groups vs direct messages
- Common failure modes
- Security notes
Do not index
In this tutorial, you will learn how to configure a Telegram bot and connect it with OpenClaw.
Follow the steps below or watch the full video tutorial.
The five steps below get you a working bot in about ten minutes. After the steps, this guide goes deeper: where the token lives in your config, how pairing and allowlists decide who can talk to your agent, how group chats behave differently from direct messages, the failure modes behind most "my bot is not responding" moments, and the security settings worth checking before you walk away.
Video walkthrough

Prerequisites
- An Agent37 account and an OpenClaw instance
- Access to your instance in the Agent37 dashboard (the Channels tab; the Terminal is optional for CLI setup)
Step 1: Create a Telegram bot (BotFather)
- Open Telegram and search for @BotFather.
- Start a chat and send
/newbot. - Give your bot a name (e.g., “My OpenClaw Assistant”).
- Give it a username (must end in
bot, e.g.,my_openclaw_assistant_bot).
- Copy the Bot Token BotFather returns.
- This token is your API key. Keep it secret.



That is the short version. Two BotFather details cause most first-run failures, so they are worth spelling out:
- The bot name is just a display label. The username is the unique handle, and Telegram requires it to end in
bot(for examplemy_openclaw_assistant_bot).
- The token looks like
123456789:ABCdefGhIJKlmNoPQRsTUvWXyz123456. Copy the whole string. A missing character at either end is enough to break authentication.
- Lost the token? Open BotFather, run
/mybots, select your bot, and choose API Token to view it again.
BotFather also offers optional polish commands like
/setdescription, /setabouttext, and /setuserpic. None of them are required for OpenClaw. For the full walkthrough with screenshots and the common mistakes to avoid, see our guide on how to create a Telegram bot with BotFather.Step 2: Open your instance's Channels tab
- Go to the Agent37 dashboard: https://www.agent37.com/dashboard
- Create an instance (or open an existing one).
- Make sure the bot is running, open the Channels tab, and click Set up Telegram. Telegram now uses an in-app setup flow, no terminal needed.
Step 3: Paste your bot token (Step 1 of 2)
Paste the token BotFather gave you into the setup panel and click Save token. Agent37 saves the token on your instance and restarts the OpenClaw gateway automatically. Prefer the terminal? The CLI path still works and does the same thing. Run:
openclaw configureThen follow the prompts:
- Where will the gateway run? → Select
Local
- Select Section to Configure? →
Channel
- Configure / Link
- Select Channel →
Telegram
- Enter Telegram bot token → Paste the token you copied
- Navigate to
Finish→Continue





Where the token lives (config and environment)
The configure wizard stores the token in your OpenClaw config (
openclaw.json) under channels.telegram. If you prefer editing config directly, the minimal Telegram setup looks like this:{
"channels": {
"telegram": {
"enabled": true,
"botToken": "123456789:ABCdefGhIJKlmNoPQRsTUvWXyz123456",
"dmPolicy": "pairing"
}
}
}- You can put the literal token in
botToken, or pointtokenFileat a file on disk that contains it.
- The
TELEGRAM_BOT_TOKENenvironment variable works as a fallback, but only for the default account. Named accounts in a multi-account setup must usebotTokenortokenFile.
- If more than one is set,
tokenFilewins overbotToken, which wins over the environment variable.
One quirk worth knowing: Telegram has no
openclaw channels login telegram flow. You set the token in config or the environment, then start the gateway. OpenClaw validates the token against Telegram on startup, and after a successful start it caches the bot identity for up to 24 hours. Changing or removing the token clears that cache.Step 4: Pair the bot (approve pairing code)
- In Telegram, open your bot and send
/start.

- Copy the 8-character pairing code the bot replies with and paste it into the same setup panel (Step 2 of 2), then click Approve pairing code. From the terminal, the equivalent is:
openclaw pairing approve telegram <code>
Pairing is OpenClaw asking you to vouch for a Telegram account before the agent will answer it. The first time an unknown user messages the bot, OpenClaw replies with a pairing code instead of an answer. Approving that code in the terminal is what grants access. Three details matter here:
- Pairing codes expire after one hour. If setup drags on, run
openclaw pairing list telegramto see which codes are still pending.
- Approval is per Telegram account, keyed to the numeric user ID, not the username.
- Pairing grants direct message access only. It does not authorize that person in group chats; groups have their own allowlists, covered below.
Step 5: Restart and test
- The dashboard flow restarts the gateway for you. If you used the CLI instead, restart the instance from the dashboard so the bot connection becomes active.
- Send a message to your bot to confirm it responds.
You have successfully connected a Telegram bot with OpenClaw.
Who can DM your bot: dmPolicy and the allowlist
channels.telegram.dmPolicy controls who can start a direct conversation with your bot. It takes four values:pairing(the default): unknown senders get a pairing code, and you approve each one from the terminal. This is what you used in Step 4.
allowlist: only the numeric Telegram user IDs listed inallowFromget through. No codes, no approvals, just a fixed list.
open: anyone who finds the bot can use it. OpenClaw requires you to also setallowFromto["*"], so you cannot open the bot up by accident.
disabled: the bot ignores all direct messages.
For a bot only you will ever use,
allowlist is the tidiest end state. Pairing is perfect for day one, but an explicit list in config survives reinstalls and leaves nothing to remember:{
"channels": {
"telegram": {
"dmPolicy": "allowlist",
"allowFrom": ["123456789"]
}
}
}Entries must be numeric user IDs;
telegram: and tg: prefixes are accepted and normalized. If an older setup left @username entries in your allowlist, run openclaw doctor --fix to resolve them to numeric IDs. And note that allowlist mode with an empty allowFrom would block everyone, so OpenClaw's config validation rejects that combination.To find your numeric ID, send your bot a DM, run
openclaw logs --follow in the terminal, and read the from.id field. That route keeps the lookup between you and your own bot. Third-party bots like @userinfobot also report IDs, but they share the data with someone else's bot.Groups vs direct messages
Group chats are gated separately from DMs, and the two never mix. A DM pairing approval does not authorize that person in a group, and group settings never open up DMs. Two layers control group behavior:
- Which groups the bot will work in.
groupPolicydefaults toallowlist, which means every group is blocked until you add its chat ID underchannels.telegram.groups. Group chat IDs are negative numbers starting with-100.
- Which people inside an allowed group can trigger the bot.
groupAllowFromlists their numeric user IDs; if you leave it unset, it falls back to yourallowFromlist.
A typical one-owner setup, DMs for you plus one allowed group, looks like this:
{
"channels": {
"telegram": {
"enabled": true,
"dmPolicy": "pairing",
"allowFrom": ["<YOUR_TELEGRAM_USER_ID>"],
"groupPolicy": "allowlist",
"groups": {
"<GROUP_CHAT_ID>": { "requireMention": true }
}
}
}
}To get the group chat ID, add the bot to the group and watch
openclaw logs --follow, or forward a group message to an ID bot. Once the group is allowed, /whoami@<bot_username> in the group confirms both your user ID and the group ID. Two behaviors to know:requireMentiondefaults totrue: in groups, the bot stays silent unless someone mentions it, for example@my_openclaw_assistant_bot ping. Set it tofalsein a group where the bot should respond to everything.
- A common mistake: negative group chat IDs belong under
groups, never ingroupAllowFrom. That field is for user IDs only, and non-numeric entries are ignored.
There is also a Telegram-side switch. Bots default to Privacy Mode, which limits which group messages they can see. If the bot should read every message (say, with
requireMention off), either disable privacy mode with /setprivacy in BotFather or make the bot a group admin. After toggling privacy mode, remove and re-add the bot in each group so Telegram applies the change.Common failure modes
When something breaks, it is almost always one of these. Run
openclaw channels status first; it surfaces configuration warnings directly.- The bot never responds. Check the basics in order: the instance is running, the token was pasted correctly, pairing was approved, and Telegram was actually selected during
openclaw configure.
getMe returned 401in the logs. Telegram rejected the token. Either it was mistyped, or it was regenerated in BotFather without you noticing. Get the current value from/mybotsand updatebotToken,tokenFile, orTELEGRAM_BOT_TOKEN.
- The pairing code no longer works. Codes expire after one hour. Run
openclaw pairing list telegramto see what is pending and approve a fresh code.
- Persistent 409 conflicts on
getUpdates. Two things are polling Telegram with the same token, usually a second gateway or a leftover script. Only one active poller can use a bot token at a time; stop the other one.
- The bot ignores group messages. The group is not listed under
channels.telegram.groups,requireMentionis stilltrueand nobody mentioned the bot, or Privacy Mode is still hiding messages from it.
setMyCommandsfails with network errors. Outbound DNS or HTTPS toapi.telegram.orgis blocked from wherever the gateway runs.
For deeper diagnosis, including revoked tokens, permission problems, and Telegram rate limits, work through our Telegram bot connection troubleshooting guide.
Security notes
- Treat the bot token like a password. Anyone holding it can read and send messages as your bot. Keep it out of screenshots, shared chats, and repositories. If it leaks, regenerate it in BotFather and update your config with the new value.
- Do not run an open bot casually.
dmPolicy: "open"withallowFrom: ["*"]means any Telegram account that finds or guesses the username can command your agent. Reserve that combination for intentionally public bots with tightly restricted tools.
- Remember what is on the other end. Messages to this bot drive an agent running on your instance, so allowlist only accounts you would trust with that access. For a one-owner bot, prefer an explicit
allowFromlist of numeric IDs over relying on old pairing approvals.
- Group access is deliberately separate. Group senders are authorized by explicit config allowlists, never by DM pairing history. That boundary is a feature; do not shortcut it with a wildcard.
That is the whole surface: token from BotFather, token into OpenClaw, pairing to let yourself in, allowlists and group rules to keep everyone else out. The five steps at the top are enough for a working bot. The sections after them are what make it a bot you can leave running.