Stack Junkie
Published on

OpenClaw Telegram Setup in 5 Minutes: Here's Exactly How

Authors

OpenClaw Telegram Setup in 5 Minutes: Here's Exactly How

TLDR

Create a Telegram bot with @BotFather. Copy the token. Tell your OpenClaw agent (previously known as Clawdbot and Moltbot) to use it. DM your bot, approve the pairing code, and you're chatting with your AI from your phone.

Introduction

You have OpenClaw running. Now you want to talk to it from your phone.

Telegram is the fastest way. No webhooks to configure. No servers to expose. Long-polling works out of the box.

This guide gets you from zero to first message in about five minutes.

What You Will Need

Before starting:

  1. OpenClaw installed and gateway running - If you need a server, see [How I Finally Got OpenClaw Running 24/7: 6/MonthonDigitalOcean](/blog/openclawdigitaloceanvpssetup)(use[thisreferrallink](https://m.do.co/c/0acfc78dffba)for6/Month on DigitalOcean](/blog/openclaw-digitalocean-vps-setup) (use [this referral link](https://m.do.co/c/0acfc78dffba) for 200 in free credit)
  2. A Telegram account - Requires a phone number
  3. About 5 minutes

If your gateway is not running yet, start it first. The Telegram connection needs a running gateway to work.

Step 1: Create a Telegram Bot

Telegram bots are created through @BotFather, Telegram's official bot management tool.

  1. Open Telegram on your phone or desktop
  2. Search for @BotFather and start a chat
  3. Send /newbot
  4. BotFather asks for a display name - pick anything (e.g., "My Assistant")
  5. BotFather asks for a username - must end in bot (e.g., "myassistant_bot")
  6. BotFather replies with your bot token

The token looks like this: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz

Keep this token secret. Anyone with the token can control your bot. If it leaks, regenerate it in BotFather with /revoke.

Optional BotFather settings

While you're in BotFather, you can configure a few things:

  • /setdescription - What users see when they open the bot profile
  • /setabouttext - Short description shown in search results
  • /setuserpic - Give your bot an avatar

These are optional. The bot works without them.

Step 2: Give the Token to Your Agent

The simplest approach: tell your agent.

Message your agent through whatever channel is already working (terminal, another chat):

"Set up Telegram with this bot token: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz"

Your agent will:

  1. Add the token to your OpenClaw config
  2. Restart the gateway
  3. Confirm when Telegram is ready
Alternative: Environment variable

If you prefer not to paste tokens in chat:

export TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"

Add this to your shell profile (.bashrc, .zshrc) or systemd service file to persist it.

Then restart the gateway:

openclaw gateway restart
Alternative: Config file

Edit openclaw.json directly:

{
  "channels": {
    "telegram": {
      "enabled": true,
      "botToken": "123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
    }
  }
}

Restart the gateway after editing:

openclaw gateway restart

Step 3: Pair Your Telegram Account

OpenClaw uses pairing to control who can message your bot. This prevents random people from using your AI if they find your bot username.

  1. Open Telegram
  2. Search for your bot by username (the one ending in bot)
  3. Send any message - "hello" works

The bot replies with a pairing code like:

Your pairing code is: ABC123 Approve this code to continue.

Now approve it. Tell your agent:

"Approve Telegram pairing code ABC123"

Or use the CLI directly:

openclaw pairing approve telegram ABC123

Once approved, you're connected. The bot responds to your messages.

Why pairing exists

Without pairing, anyone who discovers your bot username could chat with your AI and potentially trigger actions. Pairing ensures only approved users get access.

Pairing codes expire after 1 hour if not approved.

You can also pre-approve users by adding their Telegram user ID to channels.telegram.allowFrom in config. But pairing is easier for most setups.

Step 4: Send Your First Message

With pairing approved, send a message to your bot:

"What can you help me with?"

Your agent responds through Telegram. You're now chatting with your AI from your phone.

That's the setup done.

Troubleshooting

Bot does not respond at all:

  • Check if the gateway is running: openclaw gateway status
  • Check logs for errors: openclaw logs --follow
  • Verify the token is correct in config or environment

401 Unauthorized in logs:

  • Token typo. Go to @BotFather, use /revoke to get a new token, and update your config.

Pairing code never appears:

  • Gateway might not have started the Telegram channel. Check openclaw logs for "Telegram channel started" or errors.
  • Token might be invalid. Regenerate in BotFather.

Bot responds but very slowly:

  • Check your server's network connection
  • Large model responses take time. Consider using a faster model for Telegram.

Optional: Prepare for Groups

If you plan to add your bot to Telegram groups later, configure these now in BotFather:

Allow groups: Send /setjoingroups to BotFather. Select your bot. Choose "Enable".

See all group messages: By default, bots only see messages that @mention them. To see everything:

  • Send /setprivacy to BotFather
  • Select your bot
  • Choose "Disable"

Or make your bot a group admin. Admin bots see all messages regardless of privacy setting.

Note: After changing privacy settings, you need to remove and re-add the bot to existing groups for the change to take effect.

For full group setup instructions, see 6 Telegram Groups That Finally Organized My OpenClaw Agent: Here's How.

FAQ

Q: Can I use the same bot for multiple OpenClaw instances?

No. Each bot token should connect to one OpenClaw gateway. If you need multiple agents, create multiple bots.

Q: Do I need a public IP or domain for this to work?

No. Long-polling works without exposing any ports. Your server connects outbound to Telegram.

Q: How do I add more users to my bot?

Each new user goes through pairing. They DM the bot, get a code, you approve it. Or add their Telegram user ID to channels.telegram.allowFrom in config.

Q: Can I change the bot username later?

No. Telegram bot usernames are permanent. You would need to create a new bot.

Sources

  1. OpenClaw Telegram Documentation - Official docs
  2. Telegram Bot Tutorial - Official Telegram documentation
  3. OpenClaw Telegram Bot Setup - Macaron Blog
  4. OpenClaw Docker Setup - Simon Willison's TILs

Conclusion

You now have Telegram connected to your OpenClaw agent.

  1. Created bot with @BotFather
  2. Gave token to your agent
  3. Approved the pairing code
  4. Started chatting

Next step: organize your work with 6 Telegram Groups That Finally Organized My OpenClaw Agent: Here's How. Each group becomes a separate project workspace.

Enjoyed this post?

Get new articles delivered to your inbox. No spam, unsubscribe anytime.

Comments