玩了一個禮拜的openclaw,每每它的設定 (openclaw.json)都能讓人驚喜,
今天就來設定2個main agent,讓它們可以在Telegram群組相互對話,看它們對話有時充滿驚喜。
設定方式如下:
1.啟動 openclaw ( moltbot gateway --verbose)
2.進入chat room (http://127.0.0.1:18789/chat?session=agent%3Amain%3Amain)
3.跟目前主要的Agent對話: (小智,你能設定另一個也是主 agent,名稱為 "小民",且也在telegram建立你可以跟他互談的群組)。

4.可看到我的主Agent:小智,開始在 openclaw.json 設定檔作業
它主要在Agents 區段區段增加了:
"list": [
{
"id": "main",
"name": "小智",
"workspace": "C:\\Users\\User\\clawd"
},
{
"id": "xiaomin",
"name": "小民",
"workspace": "C:\\Users\\User\\clawd\\xiaomin"
}
]
"bindings": [
{
"agentId": "main",
"match": {
"channel": "telegram",
"accountId": "main"
}
},
{
"agentId": "xiaomin",
"match": {
"channel": "telegram",
"accountId": "xiaomin"
}
},
{
"agentId": "main",
"match": {
"channel": "telegram",
"accountId": "main",
"peer": {
"kind": "group",
"id": "-xxxxxxx"
}
}
},
{
"agentId": "xiaomin",
"match": {
"channel": "telegram",
"accountId": "xiaomin",
"peer": {
"kind": "group",
"id": "-xxxxxxxx"
}
}
}
],
"telegram": {
"enabled": true,
"dmPolicy": "pairing",
"groupPolicy": "allowlist",
"streamMode": "partial",
"accounts": {
"main": {
"enabled": true,
"dmPolicy": "pairing",
"botToken": "852xxxxx:AAGuSQ1VCYYrvXSxxxxx",
"groups": {
"-xxxxxxxxxxx": {
"requireMention": false,
"enabled": true
}
},
"groupPolicy": "allowlist",
"streamMode": "block"
},
"xiaomin": {
"enabled": true,
"dmPolicy": "pairing",
"botToken": "808xxxxxxx:AAFm2FN--yxArsnOoYURRI5xxxxxxx",
"groups": {
"-xxxxxxxxxx": {
"requireMention": false,
"enabled": true
}
},
"groupPolicy": "allowlist",
"streamMode": "block"
}
}
},

5.至telegram 一樣再建一個Bot,然後將 bot token 貼給 main agent:小智

6.main agent:小智 開始建立openclaw.json設定檔關於 小民的細節和建立他的個性檔案 (如 soul.md.......)

7.至Telegram 設定群組
在 Telegram 建立群組非常直覺,不過要讓 OpenClaw 的兩個 Agent 順利在裡面對話,有幾個「隱藏設定」必須處理。
以下是操作步驟:
第一步:建立基礎群組 (手機/電腦版皆可)
- 開啟 Telegram,點擊通訊錄圖示或側邊欄選單。
- 選擇 「New Group」(新建群組)。
- 加入成員:你必須至少先邀請一個「真人朋友」或「機器人」進去才能建立。
- 建議:直接搜尋並邀請你為 OpenClaw 申請的那兩個 Bot 加入。
- 命名群組:設定群組名稱(例如:OpenClaw 實驗室)並點擊完成。
第二步:關鍵設定(針對 Agent 對話)
這一步最重要,如果不設定,你的兩個機器人可能「互看不見」。
- 將 Bot 設為管理員 (Admin):
- 點擊群組頭像 -> 點擊編輯 (Edit) -> 點擊 Administrators。
- 把你的兩個 Bot 都加進管理員名單,並給予 「Send Messages」 權限。
- 關閉「隱私模式」 (Privacy Mode):
- 這需要在 @BotFather 那邊設定。
- 對 @BotFather 輸入 /mybots -> 選擇你的 Bot -> Bot Settings -> Group Privacy -> 點擊 Turn off。
- 原因:如果 Privacy Mode 是開啟的,機器人只能看到標註(@)它的訊息,無法「主動監聽」另一個機器人的對話。
第三步:獲取群組 ID (Chat ID)
OpenClaw 的設定檔通常需要知道 chat_id 才能精準發送訊息。
- 在該群組內隨便發一條訊息。
- 邀請一個名為
@username_to_id_bot的機器人進群,或者將訊息轉發給它,它會告訴你一串數字(通常群組 ID 是以 - 開頭的,例如-100123456789)。 - 將這串 ID 填入你 OpenClaw 的
target_group_id或相關設定中。
💡 專業提示
如果你的群組是 私有群組 (Private Group),記得確認兩個 Bot 都已經在成員名單內。如果它們在群組內沒反應,通常是因為 @BotFather 的 Group Privacy 沒關掉,導致它們對彼此「視而不見」。
8.重要的一步: 在跟 第一個 main agent,告知,已有group chat id,請他將 他和小民一起加入此群組:


9.快樂 三方溝通玩耍
呆萌的2個Agent的對話畫面如下:














