时间:2026-03-16 19:09
人气:
作者:admin
本文介绍了基于飞书的多Agent系统架构设计,通过OpenClaw Gateway实现飞书应用与AI Agent的对接。系统采用多Agent架构,每个飞书机器人对应独立的AI Agent,拥有专属的工作空间、知识库和模型配置。
本文可以参考的内容:
隔离性说明:
# 添加agent
openclaw agents add finance_agent
#openclaw agents add code_agent
# 设置身份
openclaw agents set-identity --agent code_agent --name "全栈开发专家"
#openclaw agents set-identity --agent main --name "OpenClaw" --emoji "????" --avatar avatars/openclaw.png
# 查看agents 列表
openclaw agents list
安装过程
cobrew@DESKTOP-9449JCG:~$ openclaw agents add finance_agent
?? OpenClaw 2026.3.13 (61d171a) ? Your AI assistant, now without the $3,499 headset.
┌ Add OpenClaw agent
│
◇ Workspace directory
│ /home/cobrew/.openclaw/workspace-finance_agent
│
◇ Copy auth profiles from "main"?
│ Yes
│
◇ Auth profiles ─────────────────────?
│ │
│ Copied auth profiles from "main". │
│ │
├─────────────────────────────────────?
│
◇ Configure model/auth for this agent now?
│ Yes
│
◇ Model/auth provider
│ Xiaomi
│
◇ How do you want to provide this API key?
│ Paste API key now
│
◇ Enter Xiaomi API key
│ sk-cidvhi74xqwlq388the6i9ds0mfru4qn0llzpux1hx54idq8
│
◇ Model configured ─────────────────────────────────────────────────────?
│ │
│ Default model set to xiaomi/mimo-v2-flash for agent "finance_agent". │
│ │
├────────────────────────────────────────────────────────────────────────?
│
◇ Model check ──────────────────────────────────────────────────────────────────────────────?
│ │
│ Model not found: xiaomi/mimo-v2-flash. Update agents.defaults.model or run /models list. │
│ │
├────────────────────────────────────────────────────────────────────────────────────────────?
│
◇ Channel status ────────────────────────────?
│ │
│ Telegram: needs token │
│ WhatsApp (default): not linked │
│ Discord: needs token │
│ Slack: needs tokens │
│ Signal: needs setup │
│ signal-cli: missing (signal-cli) │
│ iMessage: needs setup │
│ imsg: missing (imsg) │
│ IRC: not configured │
│ Google Chat: not configured │
│ LINE: not configured │
│ Feishu: install plugin to enable │
│ Google Chat: install plugin to enable │
│ Nostr: install plugin to enable │
│ Microsoft Teams: install plugin to enable │
│ Mattermost: install plugin to enable │
│ Nextcloud Talk: install plugin to enable │
│ Matrix: install plugin to enable │
│ BlueBubbles: install plugin to enable │
│ LINE: install plugin to enable │
│ Zalo: install plugin to enable │
│ Zalo Personal: install plugin to enable │
│ Synology Chat: install plugin to enable │
│ Tlon: install plugin to enable │
│ │
├─────────────────────────────────────────────?
│
◇ Configure chat channels now?
│ No
Config overwrite: /home/cobrew/.openclaw/openclaw.json (sha256 4b6fcbb9743eb0a8611264043008a59e472a4763a3a9a0a6fc7d5814cbe385ff -> 96c54ca4424a3515bc743203fa8e6ef23580613b630be1f06dad8cdf09c6137b, backup=/home/cobrew/.openclaw/openclaw.json.bak)
Updated ~/.openclaw/openclaw.json
Workspace OK: ~/.openclaw/workspace-finance_agent
Sessions OK: ~/.openclaw/agents/finance_agent/sessions
│
└ Agent "finance_agent" ready.
cobrew@DESKTOP-9449JCG:~$
配置过程
cobrew@DESKTOP-9449JCG:~$ openclaw agents add code_agent
???? OpenClaw 2026.3.13 (61d171a) — WhatsApp automation without the "please accept our new privacy policy".
11:32:30 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.
11:32:57 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
11:32:57 [plugins] feishu_chat: Registered feishu_chat tool
11:32:57 [plugins] feishu_wiki: Registered feishu_wiki tool
11:32:57 [plugins] feishu_drive: Registered feishu_drive tool
11:32:57 [plugins] feishu_bitable: Registered bitable tools
┌ Add OpenClaw agent
│
◆ Workspace directory
│ /home/cobrew/.openclaw/workspace-code_agent█
└
11:32:58 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.
11:32:58 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
11:32:58 [plugins] feishu_chat: Registered feishu_chat tool
◇ Workspace directory
│ /home/cobrew/.openclaw/workspace-code_agent
│
◇ Copy auth profiles from "main"?
│ No
│
◇ Configure model/auth for this agent now?
│ Yes
12:00:47 [agents/auth-profiles] inherited auth-profiles from main agent
│
◇ Model/auth provider
│ Qwen
12:01:29 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.
12:01:29 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
12:01:29 [plugins] feishu_chat: Registered feishu_chat tool
12:01:29 [plugins] feishu_wiki: Registered feishu_wiki tool
12:01:29 [plugins] feishu_drive: Registered feishu_drive tool
12:01:29 [plugins] feishu_bitable: Registered bitable tools
12:01:29 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.
12:01:29 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
12:01:29 [plugins] feishu_chat: Registered feishu_chat tool
12:01:29 [plugins] feishu_wiki: Registered feishu_wiki tool
12:01:29 [plugins] feishu_drive: Registered feishu_drive tool
12:01:29 [plugins] feishu_bitable: Registered bitable tools
│
◓ Starting Qwen OAuth…│
◇ Qwen OAuth ─────────────────────────────────────────────────────────────────────────╮
│ │
│ Open https://chat.qwen.ai/authorize?user_code=EFVW6ZPM&client=qwen-code to approve │
│ access. │
│ If prompted, enter the code EFVW6ZPM. │
│ │
├──────────────────────────────────────────────────────────────────────────────────────╯
◇ Qwen OAuth failed
│
◇ Qwen OAuth ────────────────────────────────────────────────────────────────╮
│ │
│ If OAuth fails, verify your Qwen account has portal access and try again. │
│ │
├─────────────────────────────────────────────────────────────────────────────╯
Error: Qwen OAuth timed out waiting for authorization.
cobrew@DESKTOP-9449JCG:~$ openclaw agents add code_agent
???? OpenClaw 2026.3.13 (61d171a) — Less clicking, more shipping, fewer "where did that file go" moments.
12:17:40 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.
^[[B^[[B^[[B^H^H12:18:08 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
12:18:08 [plugins] feishu_chat: Registered feishu_chat tool
12:18:08 [plugins] feishu_wiki: Registered feishu_wiki tool
12:18:08 [plugins] feishu_drive: Registered feishu_drive tool
12:18:08 [plugins] feishu_bitable: Registered bitable tools
┌ Add OpenClaw agent
│
◆ Workspace directory
│ /home/cobrew/.openclaw/workspace-code_age█
└
12:18:08 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.
12:18:08 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
12:18:08 [plugins] feishu_chat: Registered feishu_chat tool
◇ Workspace directory
│ /home/cobrew/.openclaw/workspace-code_age
│
◇ Configure model/auth for this agent now?
│ Yes
│
◇ Model/auth provider
│ Z.AI
│
◇ Z.AI auth method
│ Coding-Plan-CN
12:19:36 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.
12:19:36 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
12:19:36 [plugins] feishu_chat: Registered feishu_chat tool
12:19:36 [plugins] feishu_wiki: Registered feishu_wiki tool
12:19:36 [plugins] feishu_drive: Registered feishu_drive tool
12:19:36 [plugins] feishu_bitable: Registered bitable tools
│
◇ How do you want to provide this API key?
│ Paste API key now
│
◇ Enter Z.AI API key
│ f01d03bbba004f51b1156ce8e6e0b1e7.IuFYrilgMWF3EfuO
│
◇ Model configured ───────────────────────────────────────╮
│ │
│ Default model set to zai/glm-5 for agent "code_agent". │
│ │
├──────────────────────────────────────────────────────────╯
[info]: [ 'client ready' ]
│
◇ Channel status ───────────────────────────────────────────╮
│ │
│ Telegram: needs token │
│ WhatsApp (default): not linked │
│ Discord: needs token │
│ Slack: needs tokens │
│ Signal: needs setup │
│ signal-cli: missing (signal-cli) │
│ iMessage: needs setup │
│ imsg: missing (imsg) │
│ Feishu: connected as ou_9ee6b7fc6c91266a64a638548c91a4b1 │
│ IRC: not configured │
│ Google Chat: not configured │
│ LINE: not configured │
│ Google Chat: install plugin to enable │
│ Nostr: install plugin to enable │
│ Microsoft Teams: install plugin to enable │
│ Mattermost: install plugin to enable │
│ Nextcloud Talk: install plugin to enable │
│ Matrix: install plugin to enable │
│ BlueBubbles: install plugin to enable │
│ LINE: install plugin to enable │
│ Zalo: install plugin to enable │
│ Zalo Personal: install plugin to enable │
│ Synology Chat: install plugin to enable │
│ Tlon: install plugin to enable │
│ │
├────────────────────────────────────────────────────────────╯
│
◇ Configure chat channels now?
│ Yes
│
◇ How channels work ───────────────────────────────────────────────────────────────────────╮
│ │
│ DM security: default is pairing; unknown DMs get a pairing code. │
│ Approve with: openclaw pairing approve <channel> <code> │
│ Public DMs require dmPolicy="open" + allowFrom=["*"]. │
│ Multi-user DMs: run: openclaw config set session.dmScope "per-channel-peer" (or │
│ "per-account-channel-peer" for multi-account channels) to isolate sessions. │
│ Docs: channels/pairing │
│ │
│ Telegram: simplest way to get started — register a bot with @BotFather and get going. │
│ WhatsApp: works with your own number; recommend a separate phone + eSIM. │
│ Discord: very well supported right now. │
│ IRC: classic IRC networks with DM/channel routing and pairing controls. │
│ Google Chat: Google Workspace Chat app with HTTP webhook. │
│ Slack: supported (Socket Mode). │
│ Signal: signal-cli linked device; more setup (David Reagans: "Hop on Discord."). │
│ iMessage: this is still a work in progress. │
│ LINE: LINE Messaging API webhook bot. │
│ Feishu: 飞书/Lark enterprise messaging. │
│ Nostr: Decentralized protocol; encrypted DMs via NIP-04. │
│ Microsoft Teams: Bot Framework; enterprise support. │
│ Mattermost: self-hosted Slack-style chat; install the plugin to enable. │
│ Nextcloud Talk: Self-hosted chat via Nextcloud Talk webhook bots. │
│ Matrix: open protocol; install the plugin to enable. │
│ BlueBubbles: iMessage via the BlueBubbles mac app + REST API. │
│ Zalo: Vietnam-focused messaging platform with Bot API. │
│ Zalo Personal: Zalo personal account via QR code login. │
│ Synology Chat: Connect your Synology NAS Chat to OpenClaw with full agent capabilities. │
│ Tlon: decentralized messaging on Urbit; install the plugin to enable. │
│ │
├───────────────────────────────────────────────────────────────────────────────────────────╯
│
◇ Select a channel
│ Feishu/Lark (飞书)
│
◇ Feishu already configured. What do you want to do?
│ Skip (leave as-is)
│
◇ Select a channel
│ Finished
Config overwrite: /home/cobrew/.openclaw/openclaw.json (sha256 3cc26d0b17d542823fedb8662b250743f82ce326e4de4b9db560b1c8dc384214 -> 41694ced5740b6ed5d8fe59f820a8468e1a2e9f266cbbfbc014407f89a82a53c, backup=/home/cobrew/.openclaw/openclaw.json.bak)
Updated ~/.openclaw/openclaw.json
Workspace OK: ~/.openclaw/workspace-code_age
Sessions OK: ~/.openclaw/agents/code_agent/sessions
│
└ Agent "code_agent" ready.
cobrew@DESKTOP-9449JCG:~$

这边和一个 agent 的配置大不相同,参照下方修改配置
每个模型设置单独的 id、名称、 模型、工作目录,anget 目录
{
"agents": {
"list": [{
"id": "main",
"name": "main",
"model": "moonshot/kimi-k2.5",
"workspace": "/home/cobrew/.openclaw/workspace",
"agentDir": "/home/cobrew/.openclaw/agents/main/agent"
},
{
"id": "finance_agent",
"name": "finance_agent",
"workspace": "/home/cobrew/.openclaw/workspace-finance_agent",
"agentDir": "/home/cobrew/.openclaw/agents/finance_agent/agent",
"model": "xiaomi/mimo-v2-flash"
},
{
"id": "code_agent",
"name": "code_agent",
"workspace": "/home/cobrew/.openclaw/workspace-code_age",
"agentDir": "/home/cobrew/.openclaw/agents/code_agent/agent",
"model": "zai/glm-4.7-flashx",
"identity": {
"name": "全栈开发专家"
}
}
]
}
}
这边要在同一个飞书后台创建 3 个单独的应用,将每个应用的appId、appSecret 单独配置。这个目前手动修改配置文件 openclaw.json 比较快,保存后会自动重新加载配置。配置如下:
{
"channels": {
"feishu": {
"enabled": true,
"connectionMode": "websocket",
"domain": "feishu",
"accounts": {
"main":{
"appId": "cli_a93d167a33b95cb3",
"appSecret": "w73FL9tgnOTwmuGShmDdDeGG55tKm7WC",
"requireMention": true,
"groupPolicy": "open"
},
"code_agent": {
"appId": "cli_a924314b79f8dcb6",
"appSecret": "rjsPr5p8FSrLEEv1HAirrd80x3JEXA4g",
"requireMention": false,
"groupPolicy": "open"
},
"finance_agent": {
"appSecret": "XlZu4FlK1KwfIokiWeeRhdWvSoQ8EAc8",
"appId": "cli_a93de95e8a7a9ccd",
"requireMention": true,
"groupPolicy": "open"
}
}
}
}
}
|
参数名称 |
说明 |
|
requireMention |
true: 机器人只响应被 @ 的消息,群里普通发言不会触发 false: 机器人无需被 @,群里所有消息都会尝试响应 |
|
accounts.agentId |
agentId 要和agents 中配置的 ID 对应 |
方式一:使用命令绑定
# 绑定 agent 到指定飞书账号
openclaw agents bind --agent <agentId> --bind feishu:<accountId>
# 示例
openclaw agents bind --agent main --bind feishu:main
openclaw agents bind --agent code_agent --bind feishu:code_agent
openclaw agents bind --agent finance_agent --bind feishu:finance_agent
# 查看绑定结果
openclaw agents bindings
方式二:直接改配置文件
{
"bindings": [{
"type": "route",
"agentId": "main",
"match": {
"channel": "feishu",
"accountId": "main"
}
},
{
"type": "route",
"agentId": "finance_agent",
"match": {
"channel": "feishu",
"accountId": "finance_agent"
}
},
{
"type": "route",
"agentId": "code_agent",
"match": {
"channel": "feishu",
"accountId": "code_agent"
}
}
]
}
配对授权:
# 重启openclaw,新版openclaw会自己重启,重新加载配置文件
openclaw gateway restart
# 测试
# 为每个机器人配对授权
openclaw pairing approve feishu XXXX


创建群聊的步骤:
1、在飞书客户端,创建群组
2、 将机器人添加入群
3、群聊测试(有的是要@机器人才能对话,有的不需要)




群聊测试:


既然是多 agents,那么每个 agents 需要的 skills 也是不同的,
方式一:通过clawhub 安装,核心是添加--dir 参数指向 agent 自己的 skills 安装目录
# code_agent
clawhub install Self-Improving --dir /home/cobrew/.openclaw/workspace-code_age/skills
clawhub install skill-scanner --dir /home/cobrew/.openclaw/workspace-code_age/skills
clawhub install skill-vetter --dir /home/cobrew/.openclaw/workspace-code_age/skills
clawhub install tavily-search-1-0-0 --dir /home/cobrew/.openclaw/workspace-code_age/skills
clawhub install brave-api-search --dir /home/cobrew/.openclaw/workspace-code_age/skills
clawhub install qmd --dir /home/cobrew/.openclaw/workspace-code_age/skills
clawhub install --dir /home/cobrew/.openclaw/workspace-code_age/skills
clawhub install --dir /home/cobrew/.openclaw/workspace-code_age/skills
# finance_agent
clawhub install Self-Improving --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install skill-scanner --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install tavily-search-1-0-0 --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install stock-screener-cn --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install fundamental-stock-analysis --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install china-stock-analysis --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install skill-vetter --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install brave-api-search --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install qmd --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
clawhub install --dir /home/cobrew/.openclaw/workspace-finance_agent/skills
#clawhub install stock-analysis --dir /home/cobrew/.openclaw/workspace-finance_agent/skills

方式二:让 agent 自己安装

现象:新配置的 agent 机器人和飞书能建立长链接,配置没有报错,但是和机器人对话,机器人没有反应

原因:没有配置机器人事件。添加事件:接受消息,然后发布版本再测试


我明明使用的是zai/glm-4.7-flashx,但是却调用了 kimi-k2.5


解决办法:直接让小龙虾代劳


# 查看所有可用模型
openclaw models list
# 查看特定提供商模型
openclaw models list --provider deepseek
openclaw models list --provider zai
openclaw models list --provider openai
# 查看 Agent 详情(含当前模型)
openclaw agents describe main
openclaw agents describe coding
# 查看实时日志
openclaw logs --follow
# 查看配对列表(用于私聊授权)
openclaw pairing list feishu
openclaw pairing approve feishu <CODE>