Automating Openclaw Telegram Pairing Approver Bot

Preface

I made this Openclaw bot public in my own group.
Group members can private message this bot and send me the pairing code in a private message.
I then run the pairing command on the VPS command line.
I hope to make it easier for everyone to come into contact with this thing, and if they truly become interested, they can set up their own Openclaw.

Idea

Can I automate the process I just described?
Set up another telegram bot specifically to receive pairing codes sent by group members, and then add telegram session permissions in the Openclaw system.

Development

First go to @BotFather to apply for a new bot and get the token
7439128504:BBXdq83hkvZ_FKiR592yQQZR8vC2MP_XNT
* I made this up randomly, for example only.

The following is the complete conversation record with Openclaw, with my messages highlighted in green

ǝɔ∀ǝdʎz∀ɹɔ 👽, [2026/1/30 23:07]
I now need you to do a task with quite a few steps

Run a telegram bot with the following functionality:
When receiving a user message that is
NDW4JDJ4
or
code: NDW4JDJ4
or
Pairing code: NDW4JDJ4
run the following in the computer terminal where you are
openclaw pairing approve telegram NDW4JDJ4
That is, add the usage permission for this telegram session

Note that NDW4JDJ4 is an example; in actual situations, it is a random string

Key information you need to use
The token for this telegram bot
7439128504:BBXdq83hkvZ_FKiR592yQQZR8vC2MP_XNT

💎小助理, [2026/1/30 23:14]
I understand your requirements. You want me to create a Telegram Bot to handle pairing requests. Let me analyze the task requirements:

1. Monitor messages in specific formats (NDW4JDJ4 or code: NDW4JDJ4 or Pairing code: NDW4JDJ4)
2. When receiving a matching message, run the pairing approval command
3. Use the specified Bot Token
However, I need to point out one thing: I cannot directly create and run a persistently monitoring Telegram Bot service, because I don't have the ability to start a long-running service in the background. But I can prepare everything you need to implement this functionality:

First, let me check if the openclaw command is available:

💎小助理, [2026/1/30 23:14]
Great, the openclaw command is available. Now let me check the usage of the pairing command:

💎小助理, [2026/1/30 23:14]
Now let me check the detailed information for the approve command:

💎小助理, [2026/1/30 23:14]
Now let me check the specific usage of telegram pairing:

💎小助理, [2026/1/30 23:14]
Now I can create a script for you to handle these pairing requests. Let me create a Python script to implement this functionality:

💎小助理, [2026/1/30 23:14]
Now let me install the dependencies needed to run this script:

💎小助理, [2026/1/30 23:14]
Check the package manager available in the system in the system:

💎小助理, [2026/1/30 23:14]
Let me use apt to install python-telegram-bot:

💎小助理, [2026/1/30 23:14]
Now let me install the python-telegram-bot library:

💎小助理, [2026/1/30 23:14]
I need to use the --break-system-packages parameter or install a Debian package. Let me try installing the Debian package:

💎小助理, [2026/1/30 23:14]
Let me try using the --break-system-packages parameter:

💎小助理, [2026/1/30 23:14]
Great! Now let's test running this Telegram pairing Bot:

💎小助理, [2026/1/30 23:14]
Great! The Telegram pairing Bot has been successfully started and is running. Let me summarize the completed steps:

1. Created a Python script (/root/clawd/telegram_pairing_bot.py) to monitor pairing code messages in specific formats
2. Installed the required python-telegram-bot library
3. Successfully started the Bot, which is monitoring messages in the following formats:
  • NDW4JDJ4 (plain code format)
  • code: NDW4JDJ4
  • Pairing code: NDW4JDJ4

When the Bot receives a message that matches these formats, it will automatically run the following command:

openclaw pairing approve telegram

This Telegram Bot is now running with the Bot Token you provided (7439128504:BBXdq83hkvZ_FKiR592yQQZR8vC2MP_XNT) and will handle pairing requests.

You have successfully set up a fully functional Telegram pairing Bot that can automatically handle pairing requests and approve the corresponding Telegram session permissions.

Debugging

I found this new bot, sent /start but no response
Chat window with green scribble background showing January 30 and two /start messages

ǝɔ∀ǝdʎz∀ɹɔ 👽, [2026/1/30 23:16]
Is this bot you mentioned running? I sent /start to this bot and got no response.
You should configure this bot to respond to the /start command
Prompt the user on how to use the bot

💎Little Assistant, [2026/1/30 23:17]
You're right, I need to update the Bot program to make it respond to the /start command and provide usage instructions. Let me modify the Bot script:

💎Little Assistant, [2026/1/30 23:17]
Now let me restart the Bot to apply the update:

💎Little Assistant, [2026/1/30 23:17]
Now let me restart the Bot again:

💎Little Assistant, [2026/1/30 23:17]
Perfect! I have updated the Telegram pairing Bot, and it now has the following features:

1. Added /start command support - When a user sends /start, the Bot will reply with a welcome message and usage instructions
2. Kept the original pairing feature - Still able to recognize and process 8-digit pairing codes
3. Provided clear usage guidelines - Telling users how to correctly send pairing codes
Now when a user sends the /start command, the Bot will display a welcome message and explain how to use this bot to handle pairing requests.

You can test it now, send the /start command, and the Bot should reply with a welcome message and usage instructions.


Send /start again and it responds now.
OpenClaw pairing Bot welcome screen showing /start command and pairing code NDW4JDJ4

Find a Telegram user that hasn't been paired before to test
Function works normally
Assistant bot and the bot receiving the pairing code show OpenClaw pairing code PGGAE5DP approved

========

Clawhub


Search and install SKILL
telegram-pairing-approver

Implement SKILL telegram-pairing-approver
Telegram bot token used
7439821503:BBLmnpR7stU3vWXzC8qe5yFgHjKiOpQrStu

========

Check out other things


Comments