Tutorials 02

Lesson 02 — Connecting Telegram: Put Your AI Assistant in Your Chat App

Goal: Configure a Telegram Bot so you can chat with AI from your phone anytime, with support for both private chats and groups.


How It Works

When the OpenClaw gateway starts, it listens on multiple "channels." The Telegram channel uses Bot API long-polling to receive messages, routes them to the AI agent for processing, and sends the reply back to Telegram.

Your phone → Telegram servers → Bot → OpenClaw gateway → MiniMax → Reply

Step 1: Create a Telegram Bot

  1. Open Telegram and search for @BotFather

  2. Send /newbot and follow the prompts to set a name and username

  3. You'll receive a token in a format like:

    8543054163:AAHc-yE-nfRlbGw1clvW1OwjdMZ6O_j9tWs
    

Step 2: Add the Token to Your Config

Edit .env (in the project root or ~/.openclaw/.env):

TELEGRAM_BOT_TOKEN=your-token

Or add it directly to the env block in ~/.openclaw/openclaw.json:

{
  "env": {
    "MINIMAX_API_KEY": "${MINIMAX_API_KEY}",
    "TELEGRAM_BOT_TOKEN": "your-token"
  }
}

Step 3: Enable the Telegram Channel

Add the channels configuration to openclaw.json:

{
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "${TELEGRAM_BOT_TOKEN}"
    }
  }
}

Step 4: Restart the Gateway

pnpm openclaw gateway restart

Check the logs to confirm the Telegram channel connected:

tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | grep -i telegram
# You should see something like: Telegram channel connected

Step 5: Test a Conversation

  1. Open Telegram and find your Bot

  2. Send /start to begin the pairing

  3. Send a message:

    "What's the weather like today? Give me an analysis."

The Bot should reply within a few seconds.


Using in Groups

  1. Add the Bot to a group and give it admin permissions

  2. In a group, you must @mention the Bot for it to respond (default behavior to prevent spam):

    @yourbotname Can you summarize the discussion above?
    

Slash Commands

Send these directly in Telegram:

Command Function
/new Start a new session (clears context)
/reset Reset the current session
/status View current model and configuration
/think Toggle deep thinking mode
/usage View token usage

FAQ

The Bot isn't responding — what do I do?

Troubleshoot in order: ① Run pnpm openclaw gateway status to confirm the gateway is running; ② Check the logs tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | grep -i telegram to confirm the channel connected; ③ In a private chat, you must send /start first to complete the pairing — messages sent before pairing are ignored.

The Bot is replying to things it shouldn't in a group — how do I fix this?

OpenClaw defaults to only responding to @mentions, which prevents flooding. If the Bot is responding to messages it shouldn't, check the channels.telegram.replyToMode setting in openclaw.json and set it to "mention".

Can the Telegram Bot serve multiple users simultaneously?

Yes. OpenClaw's Telegram channel supports multiple concurrent users by default, and each user has their own isolated session context. Everyone shares the same API Key quota, so keep an eye on usage.

Does the Bot support sending images and files?

Image support requires a vision model (such as MiniMax VL-01); see Lesson 07. File sending capabilities depend on the OpenClaw version — use /status to check what's currently supported.

How can I use the same Bot on multiple devices?

The Bot Token is configured once in openclaw.json, and any device logged into your Telegram account can chat with the same Bot. Sessions are isolated by chat_id and won't interfere with each other.


Next Steps

  • Lesson 03 — Write your own Skill to give AI new capabilities
  • Lesson 04 — Let AI automatically control web pages for you

Stay up to date with OpenClaw

Follow @lanmiaoai on X for tips, updates and new tutorials.

Follow