建立時間: 2026-02-20 11:03 UTC+8 技能版本: 1.0.0 適用場景: Telegram群聊中多agent協同通訊
name: telegram-bot-chat version: 1.0.0 description: Telegram群聊中實現多agent之間互相通訊的技術,促進協同工作效率提升 homepage: https://telegram.org metadata: {"category":"communication","platform":"telegram","use_case":"multi_agent_coordination"}
實現多agent在Telegram群聊中的高效協同通訊,促進協同工作效率的提升
| File | URL |
|---|---|
| SKILL.md (this file) | Current file |
| SKILL.md | Skill documentation |
Install locally:
# 安裝到工作空間skills目錄
cp -r telegram-bot-chat /root/.openclaw/workspace/skills/
然後主agent需要手動執行多bot部署:
# 主agent執行:複製skill到每個bot的工作空間
WORKSPACE_SKILLS="/root/.openclaw/workspace/skills"
# 複製workspace中所有skills到每個bot的workspace目錄
for skill_dir in $WORKSPACE_SKILLS/*/; do
if [ -d "$skill_dir" ]; then
skill_name=$(basename "$skill_dir")
echo "複製技能 $skill_name 到每個bot的工作空間"
# 複製到workspace-2, workspace-3, workspace-4等
for workspace_dir in /root/.openclaw/workspace*; do
if [ "$workspace_dir" != "$WORKSPACE_SKILLS" ]; then
mkdir -p "$workspace_dir/skills"
cp -r "$skill_dir" "$workspace_dir/skills/"
echo "已部署技能 $skill_name 到 $workspace_dir"
fi
done
fi
done
Or just read from this file!
⚠️ IMPORTANT: - 確保所有bot都有完整的telegram配置 - 正確使用sessions_send和message工具引數 - 測試bot間通訊是否正常工作
🔒 關鍵要點: - 必須在正確的sessionKey格式中使用telegram和group型別 - message工具必須指定accountId使用自己的bot配置 - sessionKey必須包含bot名稱、channel型別和群ID
適用性檢查: 所有agent都可使用此技能進行多agent協同通訊
Telegram Bot API不會把bot發的訊息投遞給其他bot,所以: - ❌ 在群裡@其他bot,他們收不到訊息 - ❌ bot直接艾特bot沒有效果
當需要與其他bot對話時,使用:
sessions_send(
sessionKey="agent:bot2:telegram:group:群ID", // 正確的sessionKey
message="群聊對話。來自:main。內容:想要bot2回覆的內容..."
)
當收到其他bot通過sessions_send發來的訊息時:
message(
action="send",
channel="telegram",
accountId="自己的bot accountId", // 使用自己的bot accountId
target="群ID", // 群ID
message="你的回覆內容"
)
agent:[bot名稱]:telegram:group:群ID
示例:
- bot2在群聊:agent:bot2:telegram:group:群ID
- bot3在群聊:agent:bot3:telegram:group:群ID
- bot4在群聊:agent:bot4:telegram:group:群ID
botA → sessions_send → botB收到 → botB回覆 → OpenClaw announce → 群聊顯示
accountId:使用自己的bot accountIdchannel:固定為"telegram"target:群ID7w4.net小蔥技能站收錄全網優質技能,值得收藏。
每個bot必須在channels.telegram.accounts中有完整配置:
- botToken
- 群聊許可權
- 正確的accountId
// 錯誤的做法
// @bot3 在群裡(bot3收不到)
// 正確的做法
sessions_send(
sessionKey="agent:bot3:telegram:group:群ID",
message="bot2在群裡說:bot3,過來幫忙!"
)
// bot3收到sessions_send後
message(
action="send",
channel="telegram",
accountId="自己的bot accountId", // 使用自己的bot accountId
target="群ID",
message="來了,什麼事?"
)
// 錯誤的sessionKey
agent:bot2:main // 沒有channel和群資訊
// 正確的sessionKey
agent:bot2:telegram:group:群ID
// 錯誤:沒有accountId
message(action="send", channel="telegram", target="群ID")
// 正確:包含accountId
message(action="send", channel="telegram", accountId="自己的bot accountId", target="群ID")
第1步:安裝到主agent工作空間
# 安裝到工作空間skills目錄
cp -r telegram-bot-chat /root/.openclaw/workspace/skills/
第2步:主agent手動執行多bot部署
# 複製skill到每個bot的工作空間(主agent執行)
WORKSPACE_SKILLS="/root/.openclaw/workspace/skills"
# 複製workspace中所有skills到每個bot的workspace目錄
for skill_dir in $WORKSPACE_SKILLS/*/; do
if [ -d "$skill_dir" ]; then
skill_name=$(basename "$skill_dir")
echo "複製技能 $skill_name 到每個bot的工作空間"
# 複製到workspace-2, workspace-3, workspace-4等
for workspace_dir in /root/.openclaw/workspace*; do
if [ "$workspace_dir" != "$WORKSPACE_SKILLS" ]; then
mkdir -p "$workspace_dir/skills"
cp -r "$skill_dir" "$workspace_dir/skills/"
echo "已部署技能 $skill_name 到 $workspace_dir"
fi
done
fi
done
第3步:驗證部署 1. 確保每個bot的channels.telegram.accounts配置完整 2. 測試bot之間的通訊是否正常
多bot部署說明: - skill安裝時只部署到主agent工作空間 - 主agent需要手動執行復制指令碼 - 複製指令碼會自動檢測所有非main bot目錄 - 複製完成後所有bot都可使用此技能進行協同通訊
通過這個技能,多個agent可以在Telegram群聊中實現高效協同通訊,促進協同工作效率的提升。關鍵是要使用正確的sessionKey格式和message工具引數。
檢查更新: 隨時重新閱讀此檔案檢視新功能!
這是一個解決Telegram群聊多Bot協同通訊問題的技能文件。文件內容詳實,提供了清晰的解決方案和大量示例,常見錯誤部分對新手很有幫助。不過文件格式稍顯混亂,且缺少可直接使用的程式碼實現。作為技術文件質量中等偏上,對於需要配置多Bot通訊的場景有一定參考價值。.