Telegram Auto-Topic
Add /topic to the start of any message in a Telegram forum group → a new topic is created from it. The title is figured out from your message automatically — no need to think of one yourself.
Example
1. You send a message starting with /topic:
/topic @your_bot I need to look into renewing my passport before March
2. A new forum topic "Passport Renewal Before March" is created with your message quoted inside it. You get a reply linking directly to the new topic.
Prerequisites
- - The group must be configured in OpenClaw (
channels.telegram.groups.<CHAT_ID>) — this is how OpenClaw knows to process messages from it. - The group must have forum/topics enabled.
- Your bot must be an admin in the group with Manage Topics permission.
Handling /topic
When a message starts with /topic:
- 1. Generate a concise 3-7 word title summarising the message.
- Run the script — replace placeholders with actual values from the message context:
scripts/telegram-auto-topic.sh <chat_id> <message_id> "<sender name>" "<title>" "<text after /topic>"
Pass an empty string for the text arg if there's no text (e.g. media-only).
Use the path relative to this skill's directory.
- 3. The script returns JSON with
topic_id, title, and link. - Reply to the original message with: INLINECODE7
- Then send a response to the actual message content in the NEW topic (use message tool with
threadId from the returned topic_id). Respond naturally as you would to any message. - After both replies are sent, respond with NO_REPLY.
How It Works
- 1. You send a message starting with INLINECODE10
- A new forum topic is created — titled from your message automatically
- Your message is quoted in the new topic with your name
- You get a reply with a clickable link to the new topic
- The bot responds to your message in the new topic
Works with media too — photos, videos, or documents with /topic in the caption get forwarded into the new topic.
Script Reference
CODEBLOCK1
| Parameter | Type | Required | Description |
|---|
| INLINECODE12 | arg | yes | Supergroup chat ID (negative number) |
| INLINECODE13 |
arg | yes | Original message to quote |
|
sender | arg | yes | Display name of original sender |
|
title | arg | no | Topic title. Falls back to first ~50 chars of text if omitted |
|
text | arg | no | Message body after
/topic. If empty, forwards as media |
Returns JSON: INLINECODE18
Optional configuration
Skip the @bot mention — by default, the bot only responds when mentioned. To use /topic without mentioning the bot:
CODEBLOCK2
Telegram autocomplete — to get /topic in Telegram's command menu, add under channels.telegram:
CODEBLOCK3
Limitations
- - Attribution: Quoted messages appear as sent by the bot (Telegram API limitation). Sender name is included as attribution text below the quote.
- Media: Forwarded media shows a "Forwarded from" header — best available but not native.
- Forum groups only: Won't work in regular groups or DMs.
- Permissions: Bot needs admin with Manage Topics.
- Title length: Telegram caps topic names at 128 characters.
Telegram 自动话题
在Telegram论坛群组的任何消息开头添加/topic → 即可从中创建新话题。标题会根据你的消息自动生成——无需自己构思。
示例
1. 你发送一条以/topic开头的消息:
/topic @your_bot 我需要研究如何在三月前续签护照
2. 系统创建一个名为三月前续签护照的新论坛话题,你的消息被引用在其中。你会收到一条直接链接到新话题的回复。
前置条件
- - 该群组必须在OpenClaw中配置(channels.telegram.groups.)——这是OpenClaw识别并处理消息的方式。
- 群组必须启用论坛/话题功能。
- 你的机器人必须是群组管理员,并拥有管理话题权限。
处理/topic
当消息以/topic开头时:
- 1. 生成一个3-7个词的简洁标题,概括消息内容。
- 运行脚本——用消息上下文中的实际值替换占位符:
scripts/telegram-auto-topic.sh id> id> <发送者名称> <标题>
如果没有文本(例如仅媒体内容),则传递空字符串作为文本参数。
使用相对于此技能目录的路径。
- 3. 脚本返回包含topicid、title和link的JSON数据。
- 回复原始消息:话题已创建 → <标题>
- 然后在新话题中回复实际消息内容(使用消息工具,threadId为返回的topicid)。像回复任何消息一样自然回应。
- 两条回复发送完毕后,返回NOREPLY。
工作原理
- 1. 你发送一条以/topic开头的消息
- 系统自动创建一个新论坛话题——标题从你的消息中自动生成
- 你的消息以你的名字被引用在新话题中
- 你会收到一条包含新话题可点击链接的回复
- 机器人在新话题中回复你的消息
也支持媒体内容——在说明中包含/topic的照片、视频或文档会被转发到新话题中。
脚本参考
bash
scripts/telegram-auto-topic.sh id> id> <发送者> [标题] [文本]
| 参数 | 类型 | 必填 | 描述 |
|---|
| chatid | 参数 | 是 | 超级群组聊天ID(负数) |
| messageid |
参数 | 是 | 要引用的原始消息 |
| 发送者 | 参数 | 是 | 原始发送者的显示名称 |
| 标题 | 参数 | 否 | 话题标题。省略时默认使用文本前约50个字符 |
| 文本 | 参数 | 否 | /topic后的消息正文。为空时转发为媒体 |
返回JSON:{topic_id: 123, title: 使用的标题, link: https://t.me/c/...}
可选配置
跳过@机器人提及 — 默认情况下,机器人仅在被提及时响应。要在不提及机器人的情况下使用/topic:
json
channels.telegram.groups.: {
requireMention: false
}
Telegram自动补全 — 要让/topic出现在Telegram的命令菜单中,请在channels.telegram下添加:
json
{
customCommands: [
{
command: topic,
description: 从消息创建新论坛话题
}
]
}
限制
- - 归属显示: 引用的消息显示为由机器人发送(Telegram API限制)。发送者名称作为归属文本显示在引用下方。
- 媒体内容: 转发的媒体会显示来自...的转发标头——这是目前最佳方案,但非原生效果。
- 仅限论坛群组: 在普通群组或私聊中无效。
- 权限要求: 机器人需要拥有管理话题的管理员权限。
- 标题长度: Telegram限制话题名称最多128个字符。