DEV Community

Malcolm Low
Malcolm Low

Posted on • Originally published at malcolmlow.net

Connecting an OpenClaw Bot to a Telegram Group Topic

Originally published on malcolmlow.net

Route OpenClaw agent notifications and responses through a private Telegram group using Topics for clean per-bot threading.


Prerequisites

Item Details
OpenClaw with Telegram bot OpenClaw must already be set up and working with a Telegram bot before proceeding. This guide only covers configuring it to post into a specific group topic.
Telegram account Active account with admin rights on a Telegram group
Telegram group with Topics A Telegram group with the Topics feature enabled
SingIDBot @SingIDBot — a custom bot built by the author, used to retrieve the chat ID and topic thread ID. Responds in Singlish, so don't be surprised by the personality.

Step 1 · Create a Topic for the Bot

With Topics enabled on your group, create a dedicated topic for your OpenClaw bot to keep its messages isolated from other group activity.

Tap the pencil / new topic icon in your group and give it a clear name such as:

OpenClaw-Bot
Enter fullscreen mode Exit fullscreen mode

Note the topic thread ID — you will retrieve this precisely in Step 2 using SingIDBot.

Tip: If the Topics toggle is not visible in your group settings, try adding 4–5 members to the group first. Telegram requires a minimum number of members before the Topics feature becomes available.


Step 2 · Get IDs from SingIDBot

SingIDBot (@SingIDBot) returns the exact numeric IDs that OpenClaw needs: the group's chat ID and the topic's thread ID. See the full SingIDBot setup guide for how it works under the hood.

  1. Add @SingIDBot to your group and grant it member access.
  2. Navigate into your OpenClaw-Bot topic (not the General topic) before sending the command.
  3. Inside the topic, send: /getids
  4. SingIDBot will reply with a block like this:
Chat ID  : -1001234567890
Thread ID: 42
User ID  : 987654321
Enter fullscreen mode Exit fullscreen mode

Copy the Chat ID and Thread ID. You will pass them to OpenClaw in Step 4.


Step 3 · Ask OpenClaw to Build the Config Tool

Rather than editing the .env file manually, ask the OpenClaw agent to write a Python tool that does it for you. The tool only needs the chat ID and topic thread ID — the bot token is already present in the .env from initial setup.

Use this prompt in your OpenClaw chat interface:

Create a Python tool called update_telegram_config that accepts
chat_id and topic_id as arguments and writes the values of
TELEGRAM_CHAT_ID and TELEGRAM_TOPIC_ID into the OpenClaw .env file.
Enter fullscreen mode Exit fullscreen mode

OpenClaw will scaffold the tool, register it, and confirm it is ready to call. Proceed to Step 4 once the agent confirms the tool is available.


Step 4 · Run the Tool and Reload OpenClaw

With the IDs from Step 2 in hand, instruct OpenClaw to run the tool using your actual values:

Run update_telegram_config with:
  chat_id = "-1001234567890"
  topic_id = "42"
Enter fullscreen mode Exit fullscreen mode

Replace the placeholder values with the IDs from Step 2. After the tool executes, reload OpenClaw so the new environment variables are picked up:

# In your terminal (if running OpenClaw locally)
Ctrl+C       # stop the current process
openclaw     # restart
Enter fullscreen mode Exit fullscreen mode

Step 5 · Test the Setup

Navigate into the OpenClaw-Bot topic in your Telegram group and post any message. Wait for your OpenClaw bot to reply.

If the group ID and topic ID have been configured correctly, your OpenClaw bot will respond directly inside the topic. If there is no response, double-check the IDs from Step 2 and rerun Step 4.

Note: By default, OpenClaw bots are configured to not respond to any message in a Telegram topic unless the correct group ID and topic ID are added into the config file. A missing or incorrect ID will result in complete silence from the bot.


SingIDBot Quick Reference

@SingIDBot is a custom Telegram bot built by the author. It does one job well: return the IDs you need for bot configuration. It also speaks Singlish, so expect replies like "Wah, your chat ID here lah" — just read past the flavour text and grab your numbers.

Command What it returns Notes
/getids Chat ID, Thread ID (topic), and your User ID Must be run inside the target topic to get the correct Thread ID

Also tested on Hermes Agent: The same setup process works with the NousResearch Hermes Agent framework. The update_telegram_config tool and environment variable structure are identical — simply run the same steps with Hermes Agent in place of OpenClaw.

Your agent is now wired to a dedicated Telegram topic. Every notification, response, or alert it sends will land in the OpenClaw-Bot thread, keeping it separate from general group activity. To add more agents or tools later, repeat Steps 1–4 with a new topic and a new set of environment variable names.

Top comments (0)