OpenClaw Telegram多Agents配置指南

OpenClaw Telegram多Agents配置指南

问题背景

在建立OpenClaw的多agents系统时,如果没有正确设置匹配的channel,agents无法同时在线。核心问题是:每个agent需要绑定到独立的Telegram channel账户

解决方案

1. 创建多个Telegram Channels

首先为每个agent创建独立的Telegram channel账户:

1
2
3
4
5
6
7
8
# 创建coding账户(注意:必须指定account名字,否则会覆盖default)
openclaw channels add --channel telegram --token YOUR_BOT_TOKEN --account coding

# 创建search账户
openclaw channels add --channel telegram --token YOUR_BOT_TOKEN --account search

# 查看所有channels
openclaw channels list

关键提示--account参数必须指定,否则会覆盖默认配置。

2. 验证Channel状态

创建后检查channel状态:

1
openclaw channels status --probe

预期输出应显示:

  • Telegram coding: configured, token=config, enabled
  • Telegram default: configured, token=config, enabled
  • Telegram search: configured, token=config, enabled

3. 绑定Agents到Channels

查看所有可用的agents:

1
openclaw agents list

绑定agent到对应的channel:

1
2
3
4
5
# 绑定searcher agent到search channel
openclaw agents bind --agent searcher --bind Telegram:search

# 绑定其他agent到coding channel
openclaw agents bind --agent your-agent-name --bind Telegram:coding

解除绑定:

1
openclaw agents unbind --agent searcher --bind Telegram:search

4. 重启并验证

应用配置更改:

1
2
3
4
5
6
7
8
# 重启gateway
openclaw gateway restart

# 验证绑定状态
openclaw agents list --bindings

# 检查channel状态
openclaw channels status --probe

权限配置

解决Doctor警告

创建channel后可能会看到以下警告:

1
2
Doctor warnings:
- channels.telegram.groupPolicy is "allowlist" but groupAllowFrom (and allowFrom) is empty

解决方案

  1. 方法一:添加允许的发送者ID

    • 编辑配置文件,添加你的Telegram用户ID
  2. 方法二:设置为开放策略(不推荐用于生产环境)

    • 修改groupPolicy为"open"

配对(Pairing)流程

用户配对请求

当用户首次连接时,会收到配对请求:

1
2
3
4
5
6
OpenClaw: access not configured.
Your Telegram user id: 7650307948
Pairing code: TSP6ME62

Ask the bot owner to approve with:
openclaw pairing approve telegram TSP6ME62

管理员批准配对

查看待处理的配对请求:

1
openclaw pairing list

批准配对:

1
openclaw pairing approve telegram TSP6ME62

最佳实践

  1. 命名规范:使用有意义的account名称(如codingsearchassistant
  2. 安全配置:生产环境使用allowlist策略
  3. 测试流程:创建channel → 绑定agent → 重启gateway → 验证状态 → 测试功能
  4. 故障排除
    • Agent不在线:检查绑定状态和channel配置
    • 消息不响应:验证配对状态和权限配置
    • 群组消息被忽略:检查groupAllowFrom配置

相关命令参考

命令 功能
openclaw channels add 添加channel
openclaw channels list 列出channels
openclaw agents bind 绑定agent
openclaw agents list --bindings 查看绑定状态
openclaw pairing list 查看配对请求
openclaw pairing approve 批准配对
openclaw gateway restart 重启服务

适用版本:OpenClaw 2026.3.1+