Switch Language
Toggle Theme

OpenClaw Telegram Integration Guide: Complete Tutorial from Bot Creation to Configuration

It was 2 AM, and I was staring at my code debugging window when a question popped into my head that needed AI help. Opening the browser, logging into the ChatGPT website, waiting for it to load—the whole process took several minutes. At that moment, I thought, wouldn’t it be great if I could just ask my AI assistant directly on Telegram, as naturally as chatting with a friend?

Later, I discovered that implementing this was much simpler than I imagined. OpenClaw paired with Telegram Bot—done in half an hour. You don’t need to understand complex backend development or worry about server configuration. Follow this tutorial, and you too can have a 24/7 AI personal assistant.

Honestly, the first time I saw the Bot reply to me on Telegram, that sense of accomplishment felt pretty amazing. Today, I’ll walk you through the entire process step by step, including the pitfalls I’ve encountered and common troubleshooting methods. Ready? Let’s get started.

Preparation: Basic Concepts You Need to Know

Before diving in, let’s clarify a few key concepts. This isn’t a boring theory lesson—understanding these will save you from many detours.

Telegram Bots aren’t regular accounts. They’re more like automated reply robot interfaces that can receive and send messages but can’t initiate conversations. Think of them like customer service chatbots—they only respond when you ask questions.

Who is BotFather? This is Telegram’s official “Bot factory” where all Bots are created. It’s itself a Bot, and you create and configure your own Bot by chatting with it. When I first heard about it, I thought it was pretty clever—using a Bot to manage Bots.

What role does OpenClaw play here? Simply put, it’s the bridge connecting Telegram and AI large language models. Telegram handles receiving messages, OpenClaw receives them and forwards to Claude or GPT, then sends the AI’s reply back to Telegram. You don’t need to write any code for the entire process.

4
Items Needed

What you need to prepare:

  • A Telegram account (you should already have one)
  • OpenClaw installed and running (if not installed yet, refer to the official documentation or my previous installation tutorial)
  • AI model API Key (Claude, GPT, Gemini all work—free tier options available for testing)

Honestly, these preparations aren’t complicated. OpenClaw supports multiple platforms (Telegram, WhatsApp, WeChat, etc.) and various AI models, and switching models is easy after configuring once.

Step 1: Create Your Telegram Bot via BotFather

Alright, let’s get to the main event. Open Telegram, type @BotFather in the search box, and look for the official account with the blue verification badge. Don’t click the wrong one—there are plenty of fakes.

The Bot creation conversation flow is super simple:

  1. Send the /newbot command to BotFather
  2. It will ask for your Bot’s display name—pick something nice, like “My AI Assistant”
  3. Then you need to set a username, which has rules: must end with bot and be globally unique. My first attempt with AIAssistantBot was taken, and it took three or four tries to succeed

If you encounter “username already taken,” try adding some numbers or your name initials, like MyAwesomeAI2024Bot.

Getting the Bot Token is the most critical step. After successful creation, BotFather will send you a long string of characters, formatted something like this:

123456789:ABCdefGHIjklMNOpqrsTUVwxyz1234567890

This Token is as important as your house keys. I’ve seen people accidentally commit Tokens to public GitHub repositories, resulting in quota depletion and losses of hundreds of dollars. I suggest you immediately copy it to a password manager or encrypted notes—never send it to chat logs or cloud notes.

Optional but recommended configurations:

  • Use /setdescription to set a Bot description that users will see when opening the Bot
  • Use /setabouttext to set “About” information
  • Use /setuserpic to upload an avatar to look more professional

Don’t forget to get your own Telegram user ID! You’ll need this when configuring the whitelist later. In Telegram, search for @userinfobot, send it /start, and it will return your numeric ID, looking something like 123456789. Write this down too.

Step 2: Configure OpenClaw’s Telegram Channel

After getting the Bot Token, next is configuring OpenClaw. This step looks a bit technical, but basically it’s just editing a JSON file.

Find the configuration file. OpenClaw’s config file is at ~/.clawdbot/config/channels.json by default. If you deployed with Docker, you need to confirm the mounted configuration file location first.

Open this file and you’ll see a JSON structure. If it’s your first time configuring, it might be empty or have an example. Let’s go straight to the complete configuration:

{
  "channels": [
    {
      "id": "telegram-main",
      "type": "telegram",
      "enabled": true,
      "config": {
        "botToken": "YOUR_BOT_TOKEN_HERE",
        "allowedUserIds": [123456789],
        "enableDmPairing": false
      }
    }
  ]
}

What each parameter means:

  • id: Give this Channel a name for easy management. If you only have one Telegram Bot, call it whatever you want, but something meaningful is recommended
  • type: Must be telegram, telling OpenClaw this is a Telegram channel
  • enabled: true means enabled, false means temporarily disabled
  • botToken: Paste the Token you got from BotFather here—be careful not to copy extra spaces or line breaks
  • allowedUserIds: Whitelist user ID array, this is super important, detailed in the next section
  • enableDmPairing: Pairing code mode, advanced feature, beginners should set to false

How to edit this file?

If you’re on Linux or Mac, use nano or vim:

nano ~/.clawdbot/config/channels.json

If using Docker, you can enter the container to edit like this:

docker exec -it openclaw sh
vi /root/.clawdbot/config/channels.json

Or edit the mounted directory’s file directly on the host machine.

Common error reminders:

  • JSON format must be strict: the last key-value pair can’t have a trailing comma
  • When pasting Token, it’s easy to copy extra quotes or spaces—check carefully
  • allowedUserIds is an array, even with just one user you need square brackets []

My first configuration had an extra comma, causing OpenClaw startup failure, and it took forever searching logs to find it. JSON format checking tools (like online JSONLint) can help you avoid these rookie mistakes.

Step 3: Set Whitelist to Protect Your Bot

Speaking of whitelists, this is really important. Imagine if your Bot Token accidentally leaked—anyone in the world could use your Bot and consume your AI quota. A friend of mine experienced this; a month’s Claude quota was gone in three days.

Why you must set a whitelist:

  • Prevent strangers from abusing your AI quota (this is real money)
  • Avoid sensitive information leaks (your conversations with AI might contain work content)
  • Control usage costs (especially with expensive models like GPT-4)

How to configure the whitelist? Remember the user ID you got from @userinfobot earlier? This is where you use it.

Single user configuration:

"allowedUserIds": [123456789]

Multi-user configuration (for team use):

"allowedUserIds": [123456789, 987654321, 555555555]

How to get other people’s Telegram IDs:

  1. Have them search for @userinfobot in Telegram
  2. Send the /start command
  3. Give you the returned numeric ID
  4. You add it to the allowedUserIds array

If you’re configuring for a team, I suggest maintaining a document recording all authorized users’ IDs and names for easy management. When someone leaves, promptly remove them from the whitelist—this is basic security awareness.

About Pairing mode (advanced feature, beginners can skip):

If you set enableDmPairing to true, OpenClaw will generate a pairing code, and users need to enter this code on first use to activate. This suits multi-tenant scenarios, like when you want many people to use it but want an activation process. We won’t make it this complex in this tutorial—whitelist is enough.

Step 4: Start OpenClaw and Test Connection

Configuration complete, the exciting moment has arrived. Start OpenClaw and see if your Bot can work properly.

Start OpenClaw service:

If locally installed:

openclaw start
# or
npm start

If deployed with Docker:

docker compose up -d

Check service status:

After starting, check logs to confirm the Telegram Channel loaded successfully. With Docker:

docker compose logs openclaw -f

You should see logs similar to this:

[INFO] Loading Telegram channel: telegram-main
[INFO] Telegram bot connected successfully
[INFO] Listening for messages...

If you see error messages, don’t panic—write down the error content, we have a troubleshooting checklist coming up.

First conversation test (this is the most exciting moment):

  1. Search for your Bot username in Telegram (the one ending with bot that you created)
  2. Click the Start button at the bottom of the chat window
  3. Send a test message, like “Hello” or “Hi there”
  4. If everything’s working, the Bot will reply with AI-generated content in a few seconds

The first time I saw the Bot reply, I was genuinely a bit excited. That feeling is like you built a robot with your own hands, and it can actually chat with you.

If the Bot doesn’t respond, what should you do? Don’t rush to reinstall—read the troubleshooting checklist below; 90% of issues can be quickly resolved.

Common Troubleshooting Checklist

Bot not responding? Configuration not taking effect? Don’t panic, let’s troubleshoot step by step. I’ve organized all the problems I’ve encountered into a checklist—following it will solve most issues.

Problem 1: Bot completely doesn’t respond to any messages

This is the most common problem, with several possible causes. Check in this order:

  • Is the OpenClaw service running? Confirm with docker ps or ps aux | grep openclaw
  • Is the Bot Token configured correctly? Check the Token in channels.json, ensure no extra spaces or quotes
  • Is your user ID in the whitelist? Confirm your ID again with @userinfobot and compare with config file
  • Is the config file’s JSON format correct? Check with an online JSONLint tool
  • Is the AI model’s API Key valid and have quota? Log into the AI provider’s backend to check balance

Diagnostic commands:

# View OpenClaw logs
docker compose logs openclaw -f

# Check config file format
cat ~/.clawdbot/config/channels.json | jq .

Problem 2: Getting “Unauthorized” or “Forbidden” errors

This error is almost always a whitelist issue. Check:

  • Is your Telegram user ID in the allowedUserIds array
  • ID should be numeric type, don’t add quotes: [123456789] not ["123456789"]
  • Remember to restart OpenClaw service after modifying config

Problem 3: Bot responds very slowly

If the Bot takes a long time to reply, possible reasons:

  • AI model API responds slowly (especially during peak hours)
  • Network connection issues (check server to AI provider network)
  • Insufficient server resources (check CPU and memory usage)

Improvement methods:

  • Try a faster AI model
  • If using GPT-4, try GPT-3.5 or Claude 3 Haiku first
  • Upgrade server configuration or optimize network

Problem 4: Config file changes don’t take effect

I’ve encountered this too—changed config for ages and nothing worked. Reason: forgot to restart the service.

Solution:

docker compose restart
# or
systemctl restart openclaw

Problem 5: How to view Bot conversation history

OpenClaw saves conversation records locally. You can:

  • View log files (default path)
  • Use OpenClaw’s Control UI (if enabled)
  • Directly view the database (SQLite or other configured database)

Problem 6: What to do if Bot Token leaks

If you accidentally commit Token to a public repo or it leaks:

  1. Immediately use the /revoke command in BotFather to revoke Token
  2. Use the /token command to generate a new Token
  3. Update OpenClaw config file
  4. Restart service
  5. Check AI provider usage to see if it was abused

Advanced Configuration (Optional)

Basic functionality is already sufficient, but if you want to play with advanced features, OpenClaw has plenty more to explore.

Configure welcome message and command menu:

In BotFather, you can use /setcommands to set a command menu for the Bot, like:

start - Start conversation
help - View help
clear - Clear conversation history

Users will see these command hints when typing /.

Enable DM pairing mode:

If you want multiple people to use it but don’t want to manually manage the whitelist, try pairing code mode:

"enableDmPairing": true

OpenClaw will generate a pairing code that users enter on first use to activate. This suits offering as a service to others.

Configure different AI models for different users:

OpenClaw supports assigning different AI models per user. For example, admins use GPT-4, regular users use GPT-3.5. Specific configuration can be found in OpenClaw’s official documentation Multi-Model section.

Integrate OpenClaw Skills:

Skills is OpenClaw’s killer feature, allowing the AI assistant to perform actual operations, such as:

  • File management (create, read, edit files)
  • Shell command execution
  • Web search
  • Code writing and debugging

However, Skills functionality should be enabled cautiously, especially shell command execution, which has significant security risks.

Set conversation memory and personalized responses:

OpenClaw automatically saves conversation history. You can configure memory length, personalized prompts, etc., to make the AI assistant better suited to your usage habits.

I won’t expand on these advanced features—if interested, dive deep into OpenClaw’s official documentation.

Conclusion

After all that, looking back, the entire process isn’t complicated. From creating a Bot in BotFather, getting the Token, to configuring OpenClaw, setting the whitelist, and testing—the whole process takes half an hour at most.

Recap of the easiest places to make mistakes:

  • Bot Token must be properly safeguarded, don’t commit to public repositories
  • Whitelist configuration is key to security, don’t skip this step for convenience
  • JSON format must be strict, one extra comma will cause configuration failure
  • Remember to restart service after changing config, or it won’t take effect

If you followed this tutorial, you should now have a working Telegram AI assistant. Open Telegram and ask it questions anytime—no need to open a browser, log into a website, wait for loading. The experience is so much better.

What you can do next:

  • Try different AI models to see which suits your needs better
  • Explore OpenClaw’s Skills functionality to let your AI assistant perform actual operations
  • If it works well, you can also configure it for team members

OpenClaw doesn’t just support Telegram—it can also integrate with WhatsApp, Enterprise WeChat, and other platforms. Master this configuration method, and other platforms are similar.

When you encounter problems, don’t panic. Review the troubleshooting checklist, or ask in the OpenClaw community. The fun of tinkering with these tools is exactly this—every time you solve a problem, you learn something new.

Now, go chat with your AI assistant!

Complete OpenClaw Telegram Bot Configuration Process

Build a Telegram AI assistant from scratch, including Bot creation, OpenClaw configuration, security settings, and testing verification

⏱️ Estimated time: 30 min

  1. 1

    Step1: Create Telegram Bot via BotFather

    Creation steps:
    1. Search for @BotFather in Telegram (look for blue verification badge)
    2. Send /newbot command to start creation
    3. Enter Bot display name (can be anything)
    4. Set username (must end with bot, globally unique)

    Get key information:
    • Bot Token: Format like 123456789:ABCdefGHIjklMNOpqrsTUVwxyz1234567890
    • Save immediately to password manager, never leak
    • Search @userinfobot to get your user ID (needed for whitelist)

    Optional configuration (recommended):
    • /setdescription - Set Bot description
    • /setabouttext - Set about information
    • /setuserpic - Upload avatar
  2. 2

    Step2: Configure OpenClaw's channels.json file

    Find config file:
    • Default path: ~/.clawdbot/config/channels.json
    • Docker deployment needs to confirm mount directory

    Edit configuration (complete example):
    {
    "channels": [
    {
    "id": "telegram-main",
    "type": "telegram",
    "enabled": true,
    "config": {
    "botToken": "YOUR_BOT_TOKEN_HERE",
    "allowedUserIds": [123456789],
    "enableDmPairing": false
    }
    }
    ]
    }

    Parameter explanation:
    • id: Channel identifier (custom)
    • type: Must be telegram
    • botToken: Paste Token from BotFather
    • allowedUserIds: Whitelist user ID array (numeric type, no quotes)
    • enableDmPairing: Pairing code mode, set to false for beginners

    Common errors:
    • JSON format errors (extra commas, missing brackets)
    • Token contains extra spaces or line breaks
    • allowedUserIds uses strings instead of numbers
  3. 3

    Step3: Configure whitelist protection

    Get user ID:
    1. Search @userinfobot in Telegram
    2. Send /start command
    3. Record returned numeric ID (like 123456789)

    Single user configuration:
    "allowedUserIds": [123456789]

    Multi-user configuration (team use):
    "allowedUserIds": [123456789, 987654321, 555555555]

    Security essentials:
    • Only add trusted users to avoid API quota abuse
    • Regularly review whitelist, remove departed staff
    • Token leaks can cause hundreds of dollars in losses
    • Recommend maintaining documentation of user ID to name mappings
  4. 4

    Step4: Start service and test

    Start OpenClaw:

    Local installation:
    openclaw start
    # or
    npm start

    Docker deployment:
    docker compose up -d

    Check service status:
    docker compose logs openclaw -f

    Expected log output:
    [INFO] Loading Telegram channel: telegram-main
    [INFO] Telegram bot connected successfully
    [INFO] Listening for messages...

    Test conversation:
    1. Search for your Bot username in Telegram
    2. Click Start button
    3. Send test message (like "Hello")
    4. Wait for AI reply (usually a few seconds)

    Must restart after config changes:
    docker compose restart
  5. 5

    Step5: Common problem troubleshooting

    Bot not responding checklist:
    • Is OpenClaw service running (docker ps or ps aux | grep openclaw)
    • Is Bot Token configured correctly (no extra spaces)
    • Is user ID in whitelist
    • Is JSON format correct (validate with JSONLint)
    • Is AI API Key valid and has quota

    Unauthorized error:
    • Confirm user ID is in allowedUserIds array
    • ID must be numeric type: [123456789] not ["123456789"]
    • Restart service after modification

    Improving slow responses:
    • Switch to faster AI model (like Claude 3 Haiku)
    • Check network connection quality
    • Upgrade server configuration

    Emergency handling for Token leak:
    1. Execute /revoke in BotFather to revoke Token
    2. Execute /token to generate new Token
    3. Update OpenClaw config file
    4. Restart service
    5. Check AI provider usage statistics

FAQ

Why doesn't the Bot respond to my messages?
Bot not responding is 90% due to these reasons:

1. User ID not in whitelist: Use @userinfobot to confirm your Telegram ID, check if it's in the allowedUserIds array
2. Bot Token configuration error: Check Token in channels.json, ensure no extra spaces or line breaks
3. OpenClaw service not running: Use docker ps or ps aux | grep openclaw to confirm service status
4. JSON format error: Use online JSONLint tool to check config file format
5. AI API quota exhausted: Log into AI provider backend to check balance

Follow this order to troubleshoot, and you can usually quickly identify the issue.
How do I add access permissions for team members?
Team configuration steps:

1. Have members search @userinfobot in Telegram
2. Send /start to get user ID (numeric format)
3. Add ID to allowedUserIds array:
"allowedUserIds": [123456789, 987654321, 555555555]
4. Restart OpenClaw service for config to take effect

Management recommendations:
• Maintain documentation of ID to name mappings
• Remove from whitelist promptly when members leave
• Regularly review whitelist for security
• Consider using pairing code mode (enableDmPairing: true) for automated management
What should I do if the Bot Token leaks?
Token leak emergency handling process:

1. Immediately revoke Token: Send /revoke command in BotFather
2. Generate new Token: Send /token to get new Token
3. Update config: Edit channels.json to replace with new Token
4. Restart service: docker compose restart for new config to take effect
5. Check damage: Log into AI provider backend to view usage statistics

Prevention measures:
• Don't commit Token to public GitHub repositories
• Use password manager to save Token
• Don't save in plain text in chat logs or cloud notes
• Configure whitelist to restrict access
• Token leak cases have resulted in hundreds of dollars in losses
Can I configure different AI models for different users?
Yes, OpenClaw supports assigning AI models per user.

Implementation method:
1. Set up multiple AI models in OpenClaw configuration
2. Use user groups or permission config to assign models
3. For example: Admins use GPT-4, regular users use GPT-3.5

Specific configuration steps refer to OpenClaw official documentation's Multi-Model chapter. This feature suits team use and can control costs and access permissions.

Other advanced features:
• Skills integration (file management, shell execution, web search)
• Conversation memory configuration
• Personalized prompt settings
• Custom command menus
What other platforms can OpenClaw integrate with?
OpenClaw supports multiple mainstream chat platforms:

Supported platforms:
• Telegram (covered in this tutorial)
• WhatsApp
• Enterprise WeChat
• Discord
• Slack

Configuration method is similar:
1. Create Bot or app on corresponding platform
2. Get API credentials (Token/Key)
3. Configure OpenClaw's channels.json
4. Set whitelist or permission control
5. Start service and test

After mastering Telegram configuration, other platforms are quite similar. Specific configuration for each platform can be found in OpenClaw official documentation's corresponding chapters.
Why don't config file changes take effect?
Most common reason: forgot to restart service.

Correct operation process:
1. Edit channels.json config file
2. Save file
3. Restart OpenClaw service:
• Docker: docker compose restart
• System service: systemctl restart openclaw
• Local run: Stop process then restart
4. Check logs to confirm config loaded successfully

Other possible reasons:
• JSON format error causing config load failure (check logs)
• Edited wrong config file (confirm mount path)
• File permission issues (ensure OpenClaw process can read)
• Config overridden by other config (check priority)

Recommend checking startup logs after every config change to confirm no errors.
How do I view the Bot's conversation history?
OpenClaw provides multiple ways to view conversation history:

Method 1: View log files
• Default path: ~/.clawdbot/logs/
• Docker deployment: docker compose logs openclaw

Method 2: Control UI (if enabled)
• View and manage conversations through web interface
• Needs Control UI feature enabled in config

Method 3: Direct database query
• OpenClaw uses SQLite by default to store conversations
• Database path: ~/.clawdbot/data/
• Can view with SQLite client

Privacy recommendations:
• Regularly clean sensitive conversation records
• Pay attention to database file access permissions
• Clarify data retention policy for team use

13 min read · Published on: Feb 5, 2026 · Modified on: Feb 5, 2026

Comments

Sign in with GitHub to leave a comment

Related Posts