openclaw directory

查询渠道的联系人、群组和自身 ID,主要用于获取可传入 openclaw message send --target 的 ID。

通用 flags

  • --channel <name> — 渠道 id/别名(多渠道时必填)
  • --account <id> — 账号 id(默认使用渠道默认账号)
  • --json — JSON 输出(脚本推荐)

子命令

self — 查询自身

openclaw directory self --channel zalouser

peers — 查询联系人/用户

openclaw directory peers list --channel zalouser
openclaw directory peers list --channel zalouser --query "name"
openclaw directory peers list --channel zalouser --limit 50

groups — 查询群组

openclaw directory groups list --channel zalouser
openclaw directory groups list --channel zalouser --query "work"
openclaw directory groups members --channel zalouser --group-id <id>

各渠道 ID 格式

渠道ID 格式
WhatsApp+15551234567(DM)、xxx@g.us(群组)、xxx@newsletter(频道)
Telegram@username 或数字 chat id
Slackuser:U… / channel:C…
Discorduser:<id> / channel:<id>
Matrixuser:@user:server、room:!roomId:server
Microsoft Teamsuser:<id> / conversation:<id>

典型工作流

# 1. 查找 Slack 用户 ID
openclaw directory peers list --channel slack --query "U0"
 
# 2. 用查到的 ID 发消息
openclaw message send --channel slack --target user:U012ABCDEF --message "hello"

注意事项

  • 许多渠道的结果来自配置的 allowlist,而非实时目录查询
  • 已安装的渠道插件可能不支持 directory,此时命令报告不支持而非报错
  • 默认输出为 id(有时含 name),以 tab 分隔;脚本使用 --json

相关链接