OpenClaw Gateway支持配置多个飞书机器人并绑定不同Agent。通过在channels.feishu.accounts中定义多个机器人账号,并在bindings中根据accountId将消息路由到对应的Agent(如main或wp),实现单网关多机器人的灵活管理。配置过程包括创建Agent、修改配置文件为多账号结构、设置路由绑定三个关键步骤。
前言
之前我写过一篇文章介绍 OpenClaw 多 Agent 架构,有读者问:一个 Gateway 能不能配置多个飞书机器人?每个机器人绑定到不同的 Agent?
答案是可以的!本文记录我的配置过程。
架构说明
┌─────────────────────────────────────┐
│ 1 个 Gateway │
│ ┌─────────────────────────────┐ │
│ │ channels.feishu.accounts │ │
│ │ ├── main (机器人1) │ │
│ │ └── wp (机器人2) │ │
│ └─────────────────────────────┘ │
│ │
│ ┌───────┐ ┌───────┐ │
│ │ main │ │ wp │ │
│ │ Agent │ │ Agent │ │
│ └───────┘ └───────┘ │
│ │
│ bindings 路由消息到不同 Agent │
└─────────────────────────────────────┘
核心概念:
- 1 个 Gateway
- 1 个
channels.feishu配置块 - 多个
accounts(每个飞书机器人一个) - 通过
bindings+accountId路由到不同 Agent
步骤一:创建 Agent
首先创建 WP Agent:
openclaw agents add wp \
--workspace ~/.openclaw/workspace-wp \
--model zai/glm-5
步骤二:修改配置文件
编辑 ~/.openclaw/openclaw.json,将飞书配置从单账号改为多账号。
修改前(单账号):
{
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxxxxxxxxxxxxx",
"appSecret": "your_app_secret_here",
"dmPolicy": "allowlist",
"allowFrom": ["ou_xxxxxxxxxxxx"]
}
}
}
修改后(多账号):
{
"channels": {
"feishu": {
"enabled": true,
"accounts": {
"main": {
"appId": "cli_xxxxxxxxxxxxxxxx",
"appSecret": "your_main_bot_secret"
},
"wp": {
"appId": "cli_yyyyyyyyyyyyyyyy",
"appSecret": "your_wp_bot_secret"
},
"default": {
"dmPolicy": "allowlist",
"allowFrom": ["ou_xxxxxxxxxxxx"],
"groupPolicy": "allowlist",
"groupAllowFrom": ["oc_xxxxxxxxxxxx"]
}
},
"heartbeat": {"showOk": true, "showAlerts": true},
"stt": {"provider": "siliconflow", "model": "FunAudioLLM/SenseVoiceSmall"},
"streaming": true,
"footer": {"elapsed": true, "status": true},
"connectionMode": "websocket",
"domain": "feishu"
}
}
}
注意:
accounts.main和accounts.wp是两个飞书机器人accounts.default存放共享配置(dmPolicy、allowFrom 等)- 其他配置(heartbeat、stt、streaming)保持在外层
步骤三:配置路由绑定
添加 bindings 配置,将不同账号路由到不同 Agent:
{
"bindings": [
{
"type": "route",
"agentId": "main",
"match": {
"channel": "feishu",
"accountId": "main"
}
},
{
"type": "route",
"agentId": "wp",
"match": {
"channel": "feishu",
"accountId": "wp"
}
}
]
}
步骤四:验证配置
# 验证 JSON 格式
node -e "JSON.parse(require('fs').readFileSync('$HOME/.openclaw/openclaw.json', 'utf8')); console.log('OK')"
# 运行 doctor 自动修复格式
openclaw doctor --fix
# 查看绑定关系
openclaw agents list --bindings
输出应该类似:
Agents:
- main (default)
Routing rules:
- feishu accountId=main
- wp
Routing rules:
- feishu accountId=wp
步骤五:重启 Gateway
systemctl --user restart openclaw-gateway
常见问题
Q: 为什么不用 openclaw channels add 命令?
A: 当前版本的 channels add 命令不支持飞书的 --app-id 和 --app-secret 参数,需要手动编辑配置文件。
Q: 两个机器人能收到同样的消息吗?
A: 不会。消息根据 accountId 路由到对应的 Agent。给机器人1发消息 → main Agent 回复;给机器人2发消息 → wp Agent 回复。
Q: 如何测试配置是否成功?
A: 在飞书里分别给两个机器人发消息,看回复的"人格"是否不同(如果配置了不同的 SOUL.md)。
总结
| 方案 | Gateway | 飞书机器人 | 配置方式 |
|---|---|---|---|
| 单 Agent 单机器人 | 1 | 1 | 默认配置 |
| 多 Agent 单机器人 | 1 | 1 | bindings 按 peer 路由 |
| 多 Agent 多机器人 | 1 | 多 | accounts + bindings 按 accountId 路由 |
一个 Gateway 可以配置多个飞书机器人,每个机器人绑定到不同的 Agent,实现真正的"独立团"模式。

暂无评论
要发表评论,您必须先 登录