Beginner Openclaw 11 min read

OpenClaw Telegram Bot: Connect Your AI to Messaging

#openclaw #telegram #bot #messenger #channel #security #tutorial

Once OpenClaw is running on your machine, the next natural question is: how do you talk to it from anywhere? Running a command in your terminal is fine for testing, but real power comes when your AI agent is reachable through the apps you already use every day. This tutorial walks you through connecting OpenClaw to Telegram — the fastest, most accessible integration for most developers.

By the end of this guide you will have a Telegram bot that forwards messages directly to your OpenClaw agent, with proper security controls so that only you (and anyone you explicitly permit) can interact with it.


Why Telegram First?

Among the messaging platforms OpenClaw supports — Telegram, WhatsApp, and Slack — Telegram makes the most sense as your starting point for three reasons.

BotFather is genuinely frictionless. Telegram’s official bot creation wizard (@BotFather) takes under two minutes. There are no developer accounts to register, no app review queues, and no business verification requirements. You send a command, receive a token, and you are ready.

Bots are first-class citizens. Telegram was designed with bots in mind. Every Telegram bot gets a dedicated API endpoint, a persistent token, and reliable message delivery. The OpenClaw team chose grammY — a well-maintained TypeScript bot framework — as the underlying library for its Telegram channel adapter, which means the integration benefits from a stable and actively developed foundation.

Security controls are straightforward. Telegram exposes your numeric User ID, which OpenClaw uses to build an Allow List. Unlike email-based systems where spoofing is possible, Telegram User IDs are immutable identifiers assigned by Telegram’s servers. This makes them a reliable key for access control.

WhatsApp integration (via the Baileys library) is available but involves more setup steps and occasional breakage as WhatsApp updates its unofficial API. Slack integration is powerful for team scenarios but requires OAuth app registration and workspace permissions — covered in the next article in this series. For personal or solo-developer use, Telegram is the right starting point.


Prerequisites

Before proceeding, confirm the following:

  • OpenClaw daemon is running. You completed the setup in Getting Started with OpenClaw and the OpenClaw process is active. You can verify this by running openclaw status in a terminal and seeing daemon: running.
  • Telegram app is installed. Download the Telegram app on your phone (iOS or Android) or use Telegram Desktop. You need an active Telegram account with a confirmed phone number.
  • You know your Telegram User ID. You will need this number during the Allow List configuration step. If you do not know it yet, the section below explains how to find it.
  • Your machine is reachable. OpenClaw uses outbound polling (not inbound webhooks), so no port forwarding or public IP is required. Your machine just needs internet access.

Step 1: Create a Bot with BotFather

BotFather is Telegram’s official meta-bot for managing all bots on the platform. You interact with it through a normal Telegram chat to create and configure your bots.

Find BotFather and Create Your Bot

Open Telegram and search for @BotFather. The verified account displays a blue checkmark. Start a conversation and send the /newbot command.

BotFather will ask for two things in sequence:

  1. A display name — this is the human-readable name shown in Telegram chats. It can contain spaces and mixed case. Example: My OpenClaw Agent.
  2. A username — this must end in bot (case-insensitive) and contain only letters, numbers, and underscores. It must be globally unique across all Telegram bots. Example: my_openclaw_bot.

The conversation looks like this:

You:        /newbot
BotFather:  Alright, a new bot. How are we going to call it?
            Please choose a name for your bot.
You:        My OpenClaw Agent
BotFather:  Good. Now let's choose a username for your bot.
            It must end in `bot`. Like this, for example:
            TetrisBot or tetris_bot.
You:        my_openclaw_bot
BotFather:  Done! Congratulations on your new bot. You will find
            it at t.me/my_openclaw_bot. You can now add a description,
            about section and profile picture for your bot...

            Use this token to access the HTTP API:
            7483920156:AAF3mK2vLhXpQnRjT8wYdUeI6sOzBcNvWgA
            Keep your token secure and store it safely, it can be
            used by anyone to control your bot.

The long string at the end — 7483920156:AAF3mK2vLhXpQnRjT8wYdUeI6sOzBcNvWgA in the example above — is your bot token. This is the credential that authorizes OpenClaw to send and receive messages through your bot.

Save Your Bot Token Securely

Security Warning: Your bot token is equivalent to a password. Anyone who holds this token can send messages as your bot, read all messages your bot receives, and control its behavior. Never paste it into public forums, commit it to version control, or share it in screenshots.

Store the token immediately in a password manager or a local secrets file that is excluded from version control. If you ever suspect the token has been leaked, return to BotFather and send /revoke to invalidate it and generate a new one.

A safe local storage pattern:

# Store the token in a local env file (never commit this)
echo "TELEGRAM_BOT_TOKEN=7483920156:AAF3mK2vLhXpQnRjT8wYdUeI6sOzBcNvWgA" >> ~/.openclaw/.env

# Confirm it was written
cat ~/.openclaw/.env

Make sure ~/.openclaw/.env is not inside a git repository, or add it explicitly to .gitignore if it is.


Step 2: Register the Bot in OpenClaw

With your bot token in hand, you can register the Telegram channel inside OpenClaw. OpenClaw uses an interactive configuration prompt to walk you through channel registration.

Run the channel add command:

openclaw channel add telegram

OpenClaw will prompt you for the bot token:

OpenClaw Channel Setup — Telegram
----------------------------------
Enter your Telegram bot token: █

Paste your token and press Enter. OpenClaw validates the token against Telegram’s Bot API (https://api.telegram.org/bot<token>/getMe) and displays the bot’s username if successful:

✓ Token validated. Bot username: @my_openclaw_bot
Channel "telegram" registered successfully.

Next steps:
  1. Configure an Allow List to restrict access
  2. Start the daemon: openclaw start
  3. Open Telegram and send /start to @my_openclaw_bot

If validation fails, double-check that you copied the full token without trailing spaces, and that the token has not been revoked in BotFather.

You can inspect registered channels at any time:

openclaw channel list

Output:

Channel     Status      Bot Username
---------   ---------   ----------------------
telegram    registered  @my_openclaw_bot

Step 3: Configure Security with Allow Lists

This is the most important step. Without an Allow List, anyone who discovers your bot’s username can send it messages and interact with your OpenClaw agent. That means strangers could potentially trigger agent actions on your machine.

Finding Your Telegram User ID

Your Telegram User ID is a numeric string (for example, 391847562). It is different from your username. To find it:

  1. In Telegram, search for @userinfobot.
  2. Start a conversation and send any message (even just /start).
  3. The bot replies with your ID, first name, and language code.
Your info:
Id: 391847562
First: Alex
Language: en

Copy the Id value. This is the number you will add to the Allow List.

Configuring the Allow List

Add your User ID to the Telegram channel’s Allow List:

openclaw channel config telegram --allow-user 391847562

Confirmation:

✓ User ID 391847562 added to telegram Allow List.
Allow List (telegram):
  391847562

You can add multiple User IDs if you want to share access with trusted colleagues:

openclaw channel config telegram --allow-user 847291034

Why This Matters

Telegram bot usernames are often guessable or discoverable through Telegram’s search feature. Without an Allow List, the bot is publicly accessible to anyone. With an Allow List, messages from non-permitted User IDs are silently dropped — the sender receives no response and no error, which avoids revealing that the bot exists and is active.

The Allow List operates at the channel adapter level inside OpenClaw, not at the Telegram API level. This means it functions regardless of whether you have configured Telegram’s own privacy settings.


Step 4: Pair Your Device with DM Pairing

Even with an Allow List in place, OpenClaw requires an additional one-time pairing step for each Telegram account that will use the bot. This creates a cryptographically verified link between a Telegram User ID and your OpenClaw installation, preventing replay attacks and token theft scenarios.

How Pairing Works

When you send your first message to the bot from an Allow-Listed User ID, OpenClaw generates a short numeric pairing code and logs it to the daemon output. You then confirm the pairing from your server terminal using the openclaw pairing approve command. Until you approve, the bot will not process any messages from that account.

Start the Daemon

If the daemon is not already running, start it:

openclaw start

Send /start from Telegram

Open Telegram, find your bot (@my_openclaw_bot), and send /start. The bot will respond:

Pairing required. Your pairing code: 7241
Please ask the administrator to run:
  openclaw pairing approve telegram 7241

Approve the Pairing

On your machine, run:

openclaw pairing approve telegram 7241

Output:

✓ Pairing approved for User ID 391847562 on channel "telegram".
  This device is now authorized to use @my_openclaw_bot.

From this point forward, messages from User ID 391847562 are accepted and forwarded to the OpenClaw agent without any further pairing steps. The pairing is persistent across daemon restarts.

Viewing and Revoking Pairings

To see all active pairings:

openclaw pairing list
Channel     User ID       Status     Paired At
---------   -----------   --------   --------------------
telegram    391847562     active     2026-04-08 09:14:33

To revoke a pairing (for example, if you want to remove access for a specific account):

openclaw pairing revoke telegram 391847562

Security Warning: If you suspect someone has gained unauthorized access to your bot — for instance, if they somehow obtained a valid pairing code before you did — revoke all pairings immediately with openclaw pairing revoke telegram --all, then reconfigure your Allow List. Consider revoking and regenerating your bot token in BotFather as well.


Step 5: Send Your First Message

With the daemon running and pairing complete, you are ready to have your first real conversation through Telegram.

Open Telegram on your phone, navigate to your bot, and type a message. Start with something simple to confirm end-to-end connectivity:

Hello, are you there?

Within a second or two (depending on your network and the LLM backend configured in OpenClaw), you should see a response:

Hello! Yes, I'm here and connected through your OpenClaw agent.
How can I help you today?

Try a slightly more substantive request to confirm the agent is processing correctly:

What's the current date and time on my machine?

OpenClaw’s agent will execute the appropriate tool call and return the result:

The current date and time on your machine is:
Wednesday, April 8, 2026, 09:22:14 UTC+9 (KST)

If you see a response, congratulations — your Telegram bot is fully operational.

What to Do If the Bot Doesn’t Respond

Check the daemon logs for errors:

openclaw logs --tail 50

Common issues and resolutions:

SymptomLikely CauseFix
No response at allDaemon not runningRun openclaw start
”Pairing required” loopPairing not approvedRun openclaw pairing approve telegram <code>
”Unauthorized” in logsUser ID not in Allow ListRun openclaw channel config telegram --allow-user <id>
Token error in logsToken expired or revokedRevoke and regenerate in BotFather

Frequently Asked Questions

What happens if someone else finds my bot?

If someone discovers your bot’s username and sends it a message, OpenClaw checks the sender’s User ID against the Allow List. Since their User ID is not on the list, the message is silently dropped — they receive no response. The bot appears completely inactive to unauthorized users. This is intentional: providing an error message would confirm that the bot is live and potentially invite brute-force attempts.

For additional obscurity, you can disable the bot’s discoverability in BotFather by sending /setprivacy and configuring the privacy mode. However, the Allow List is the primary security mechanism — do not rely solely on obscurity.

Can I connect multiple Telegram accounts?

Yes. Add each User ID to the Allow List and have each person send /start to trigger the pairing flow. You approve each pairing individually:

# Add second user to allow list
openclaw channel config telegram --allow-user 847291034

# After they send /start and receive their code (e.g., 5983):
openclaw pairing approve telegram 5983

Each paired account has an independent conversation context with the OpenClaw agent by default. If you want shared context across accounts, consult the OpenClaw documentation on session scoping — this is covered in the OpenClaw integrations and community guide.

How do I disconnect and reconnect Telegram?

To fully disconnect the Telegram channel (for example, to rotate credentials or troubleshoot), remove the channel:

openclaw channel remove telegram

This revokes all pairings, removes the Allow List, and unregisters the bot token from OpenClaw. The Telegram bot itself continues to exist — you are only removing OpenClaw’s connection to it.

To reconnect, start again from Step 2 of this guide. You do not need to create a new bot in BotFather unless you want a fresh token; you can reuse the existing token.

To temporarily pause the Telegram channel without removing it:

openclaw channel disable telegram
# Later:
openclaw channel enable telegram

This stops polling for new messages without losing your configuration.


Next Steps

You now have a fully configured, secure Telegram bot connected to your OpenClaw agent. From here, consider expanding your setup:

Add more messaging channels. OpenClaw supports multiple channels running simultaneously. You can add Slack for team workflows — Slack integration with OAuth app setup is covered in the next article in the build/openclaw series. WhatsApp integration via the Baileys library is also available for personal use cases.

Explore automation triggers. Beyond responding to messages, OpenClaw agents can be configured to proactively send Telegram messages based on events — for example, notifying you when a pipeline completes or when a monitored metric crosses a threshold.

Review the full integrations landscape. The OpenClaw integrations and community guide covers the ecosystem of available plugins, community-contributed channel adapters, and third-party tool integrations that extend what your agent can do.

Harden your security posture. As you expand access to additional users or channels, revisit your Allow List and pairing configurations regularly. The openclaw pairing list and openclaw channel config telegram --list-users commands give you a complete picture of who has access at any point in time.

Related Articles