OpenClaw 多飞书机器人配置指南:一个 Gateway 运行多个 Agent

AI摘要

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.mainaccounts.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,实现真正的"独立团"模式。

参考

Saiita

我还没有学会写个人说明!

相关推荐

#8 OpenClaw 多渠道管理

OpenClaw是一个支持同时接入飞书、Telegram、钉钉、Discord、WhatsApp等多平台消息渠道的AI助手网关。它通过统一配置实现多渠道管理,允许将不同性格与功能的Agent绑定至特定渠道,并自动适配各平台的消息格式。系统提供群聊防刷屏、静默时段等策略,确保在不同场景下提供恰当、一致的服务体验。

OpenClaw v2026.4.5 发布:内置视频/音乐生成工具、多语言控制面板与 ComfyUI 集成

OpenClaw v2026.4.5是一次重大更新,核心是新增内置视频与音乐生成工具,并集成ComfyUI工作流。控制面板新增12种多语言支持,同时引入了多个新AI提供商与模型。更新包含破坏性变更,移除了旧配置别名,建议升级后运行`openclaw doctor --fix`进行迁移。此外,本次更新还带来了大量稳定性修复、性能优化及移动端功能改进。

OpenClaw v2026.3.31 发布:后台任务系统重构、QQ Bot 通道与全面安全增强

OpenClaw v2026.3.31版本是一次包含破坏性变更的重大更新。核心内容包括后台任务系统重构为统一控制面板、新增QQ Bot通道支持,并全面增强Matrix生态。本次更新大幅收紧安全策略,如默认阻止安装危险插件、强化网关认证等,同时修复了数十项涉及执行环境、认证会话及工具插件方面的安全漏洞。

OpenClaw 配置 GLM-5.1:智谱最新大模型接入教程

智谱AI推出编程能力显著提升的旗舰模型GLM-5.1,支持204800上下文窗口和131072输出Token。文章详细介绍了如何在OpenClaw中通过编辑配置文件手动添加并切换至GLM-5.1模型,包括修改模型定义、设置默认模型及重启网关等步骤。该模型也已支持在Claude Code等主流Coding Agent中使用。

暂无评论