使用 openclaw directory 快速查找頻道 ID
每次要在不同通訊平台發送訊息時,最麻煩的就是找那個長到不行的 ID。手動翻找 API 回傳結果或是從網頁原始碼裡挖 ID 既浪費時間又容易出錯,這通常是開發自動化工具時最讓人煩躁的環節。
openclaw directory 指令就是為了幫你解決這個問題。它能幫你快速找出聯絡人(peers)、群組(groups)或你自己的 ID,讓你直接複製到其他指令中使用。
需要準備的東西
Section titled “需要準備的東西”- 已安裝並設定好的 openclaw 環境
- 至少一個已配置的 channel(如 Slack, WhatsApp, Telegram 等)
要在 5 分鐘內學會查找 ID 並發送訊息,你可以按照以下步驟操作:
-
查找聯絡人 ID: 使用
peers list並配合--query關鍵字搜尋。Terminal window openclaw directory peers list --channel slack --query "U0" -
發送訊息: 將上一步取得的 ID 填入
--target參數。Terminal window openclaw message send --channel slack --target user:U012ABCDEF --message "hello"
常用 Flags
Section titled “常用 Flags”--channel <name>: 指定 channel 的 ID 或別名(若只設定一個 channel 則會自動選擇)。--account <id>: 指定帳號 ID(預設為該 channel 的預設帳號)。--json: 以 JSON 格式輸出,適合寫 script 時使用。
各頻道的 ID 格式
Section titled “各頻道的 ID 格式”不同頻道使用的 ID 格式各不相同,你可以參考以下清單:
- WhatsApp:
+15551234567(個人),1234567890-1234567890@g.us(群組) - Telegram:
@username或數字 ID;群組皆為數字 ID - Slack:
user:U…或channel:C… - Discord:
user:<id>或channel:<id> - Matrix (plugin):
user:@user:server,room:!roomId:server, 或#alias:server - Microsoft Teams (plugin):
user:<id>或conversation:<id> - Zalo (plugin): user id (Bot API)
- Zalo Personal / zalouser (plugin): 來自
zca的 thread id (me,friend list,group list)
更多查找指令
Section titled “更多查找指令”查找自己 (“me”)
Section titled “查找自己 (“me”)”如果你需要知道目前登入帳號的 ID:
openclaw directory self --channel zalouser查找聯絡人 (Peers)
Section titled “查找聯絡人 (Peers)”你可以限制回傳數量或進行關鍵字搜尋:
openclaw directory peers list --channel zalouser --limit 50openclaw directory peers list --channel zalouser --query "name"查找群組 (Groups)
Section titled “查找群組 (Groups)”除了列出群組,你也可以查看特定群組的成員:
openclaw directory groups list --channel zalouser --query "work"openclaw directory groups members --channel zalouser --group-id <id>- 找不到特定的聯絡人或群組:
對於許多頻道來說,
directory的結果是基於你的設定檔(如 allowlists 或已設定的群組),而不是即時向平台進行全域搜尋。請檢查你的設定檔是否已包含該對象。 - 輸出格式不方便處理:
預設輸出是用 tab 分隔
id與name。如果你需要自動化處理,請加上--jsonflag。
如果你在設定過程遇到任何問題,可以詢問 AI Setup Assistant。
OpenClaw Expert
還是卡住了?
如果這篇文件沒有解決你的情境,直接問 OpenClaw Expert,拿到可執行步驟。