OpenClaw × 飞书:保姆级接入指南
文章目录
OpenClaw × 飞书:保姆级接入指南
通过命令行快速将 OpenClaw 智能 Agent 接入飞书,实现企业级 AI 助手部署。
为什么选择命令行配置?
相比图形化向导,命令行配置更适合:
- 🖥️ 服务器环境 — 无桌面环境的 Linux 服务器部署
- 🔄 自动化脚本 — 集成到 CI/CD 或配置管理工具
- ⚡ 批量操作 — 快速配置多个账号或环境
前置准备
在开始之前,确保你已经:
- 安装 OpenClaw(如未安装可参考:在 Ubuntu 上快速部署 OpenClaw 完整教程)
- 拥有一个飞书企业账号(或 Lark 国际版账号)
- 具备创建企业自建应用的权限
一、创建飞书应用
1.1 登录飞书开放平台
访问 飞书开放平台(国际版用户请使用 Lark Open Platform)。
1.2 创建企业自建应用
点击「创建企业自建应用」,填写应用名称和描述,上传应用图标。


1.3 获取应用凭证
进入「凭证与基础信息」页面,复制以下关键信息:
- App ID(格式如
cli_xxx) - App Secret(⚠️ 请妥善保管,切勿泄露)

1.4 一键导入权限配置
在「权限管理」页面,点击「批量导入」,粘贴以下 JSON 配置(注:为了方便测试,本次开放权限比较多,请按需适当减少):
{"scopes":{"tenant":["aily:file:read","aily:file:write","application:application.app_message_stats.overview:readonly","application:application:self_manage","application:bot.menu:write","cardkit:card:write","contact:contact.base:readonly","contact:user.employee_id:readonly","corehr:file:download","docs:document.content:read","event:ip_list","im:app_feed_card:write","im:biz_entity_tag_relation:read","im:biz_entity_tag_relation:write","im:chat","im:chat.access_event.bot_p2p_chat:read","im:chat.announcement:read","im:chat.announcement:write_only","im:chat.chat_pins:read","im:chat.chat_pins:write_only","im:chat.collab_plugins:read","im:chat.collab_plugins:write_only","im:chat.managers:write_only","im:chat.members:bot_access","im:chat.members:read","im:chat.members:write_only","im:chat.menu_tree:read","im:chat.menu_tree:write_only","im:chat.moderation:read","im:chat.tabs:read","im:chat.tabs:write_only","im:chat.top_notice:write_only","im:chat.widgets:read","im:chat.widgets:write_only","im:chat:create","im:chat:delete","im:chat:moderation:write_only","im:chat:operate_as_owner","im:chat:read","im:chat:readonly","im:chat:update","im:datasync.feed_card.time_sensitive:write","im:message","im:message.group_at_msg:readonly","im:message.group_msg","im:message.p2p_msg:readonly","im:message.pins:read","im:message.pins:write_only","im:message.reactions:read","im:message.reactions:write_only","im:message.urgent","im:message.urgent.status:write","im:message.urgent:phone","im:message.urgent:sms","im:message:readonly","im:message:recall","im:message:send_as_bot","im:message:send_multi_depts","im:message:send_multi_users","im:message:send_sys_msg","im:message:update","im:resource","im:tag:read","im:tag:write","im:url_preview.update","im:user_agent:read","sheets:spreadsheet","wiki:wiki:readonly"],"user":["aily:file:read","aily:file:write","contact:contact.base:readonly","im:chat.access_event.bot_p2p_chat:read"]}}
1.5 启用机器人能力
进入「应用能力」→「机器人」页面,开启机器人能力并配置名称。

1.6 命令行配置 OpenClaw
1.6.1.安装飞书插件
openclaw plugins install @openclaw/feishu ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ openclaw plugins install @openclaw/feishu 🦞 OpenClaw 2026.2.26 (bc50708) — Your config is valid, your assumptions are not. Downloading @openclaw/feishu… Extracting /tmp/openclaw-npm-pack-J3n6oT/openclaw-feishu-2026.2.25.tgz… Installing to /home/ubuntu/.openclaw/extensions/feishu… Installing plugin dependencies… 08:42:12 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/ubuntu/.openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids. Config warnings: - plugins.entries.feishu: plugin feishu: duplicate plugin id detected; later plugin may be overridden (/home/ubuntu/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts) Config overwrite: /home/ubuntu/.openclaw/openclaw.json (sha256 39d81e12fa7ac493441f7da59893d51ca3f831c15cdb6835505a76b040fc7cf7 -> 0923c52a525f0cb1b39d00380aca43194d148754cbc27324d03c9c97a915169b, backup=/home/ubuntu/.openclaw/openclaw.json.bak) Installed plugin: feishu Restart the gateway to load plugins. 1.6.2 添加飞书渠道
运行以下命令,根据交互式提示完成配置:
openclaw channels add操作步骤:
- 选择渠道类型:Feishu
- 输入 App ID(如
cli_xxx) - 输入 App Secret
- 确认配置完成
ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ openclaw channels add Config warnings:\n- plugins.entries.feishu: plugin feishu: duplicate plugin id detected; later plugin may be overridden (/home/ubuntu/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts) 🦞 OpenClaw 2026.2.26 (bc50708) — Your inbox, your infra, your rules. │ ◇ Config warnings ─────────────────────────────────────────────────────────────────────────╮ │ │ │ - plugins.entries.feishu: plugin feishu: duplicate plugin id detected; later plugin may │ │ be overridden │ │ (/home/ubuntu/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts) │ │ │ ├───────────────────────────────────────────────────────────────────────────────────────────╯ Config warnings:\n- plugins.entries.feishu: plugin feishu: duplicate plugin id detected; later plugin may be overridden (/home/ubuntu/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts) 08:44:00 [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: feishu (/home/ubuntu/.openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids. Config warnings:\n- plugins.entries.feishu: plugin feishu: duplicate plugin id detected; later plugin may be overridden (/home/ubuntu/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts) ┌ Channel setup │ ◇ 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: needs app credentials │ │ IRC: not configured │ │ Google Chat: 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. │ │ 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. │ │ LINE: LINE Messaging API bot for Japan/Taiwan/Thailand markets. │ │ 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 credentials ──────────────────────────────────────────────────────────────╮ │ │ │ 1) Go to Feishu Open Platform (open.feishu.cn) │ │ 2) Create a self-built app │ │ 3) Get App ID and App Secret from Credentials page │ │ 4) Enable required permissions: im:message, im:chat, contact:user.base:readonly │ │ 5) Publish the app or add it to a test group │ │ Tip: you can also set FEISHU_APP_ID / FEISHU_APP_SECRET env vars. │ │ Docs: feishu │ │ │ ├───────────────────────────────────────────────────────────────────────────────────╯ │ ◇ Enter Feishu App ID │ cli_xxxxx │ ◇ Enter Feishu App Secret │ xxxxxxx [info]: ['client ready'] │ ◇ Feishu connection test ────────────────────────────╮ │ │ │ Connection failed: API error: app do not have bot │ │ │ ├─────────────────────────────────────────────────────╯ │ ◇ Which Feishu domain? │ Feishu (feishu.cn) - China │ ◇ Group chat policy │ Open - respond in all groups(requires mention)[info]: ['client ready'] │ ◇ Select a channel │ Finished │ ◇ Selected channels ──────────────────────────────────────────╮ │ │ │ Feishu — 飞书/Lark enterprise messaging. Docs: │ │ feishu │ │ │ ├──────────────────────────────────────────────────────────────╯ │ ◇ Configure DM access policies now? (default: pairing) │ Yes │ ◇ Feishu DM access ─────────────────────────────────────────────────────────────────────────╮ │ │ │ Default: pairing (unknown DMs get a pairing code). │ │ Approve: openclaw pairing approve feishu <code> │ │ Allowlist DMs: channels.feishu.dmPolicy="allowlist" + channels.feishu.allowFrom entries. │ │ Public DMs: channels.feishu.dmPolicy="open" + channels.feishu.allowFrom includes "*". │ │ 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 │ │ │ ├────────────────────────────────────────────────────────────────────────────────────────────╯ │ ◇ Feishu DM policy │ Open (public inbound DMs) │ ◇ Add display names for these accounts? (optional) │ Yes │ ◇ feishu account name (default) │ feishu │ ◇ Bind configured channel accounts to agents now? │ Yes │ ◇ Route feishu account "default" to agent │ main (default) │ ◇ Routing bindings ────────────────╮ │ │ │ Added: feishu accountId=default │ │ │ ├───────────────────────────────────╯ Config warnings: - plugins.entries.feishu: plugin feishu: duplicate plugin id detected; later plugin may be overridden (/home/ubuntu/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts) Config overwrite: /home/ubuntu/.openclaw/openclaw.json (sha256 0923c52a525f0cb1b39d00380aca43194d148754cbc27324d03c9c97a915169b -> a39bc0ee7a65d9649038ffba9170f324d149aa550d84bc31f237fc240188b4cb, backup=/home/ubuntu/.openclaw/openclaw.json.bak) │ └ Channels updated. 1.6.3 重启网关
openclaw gateway restart 1.7. 配置事件订阅(关键步骤)
⚠️ 注意:在配置事件订阅前,请确保已完成 OpenClaw 渠道添加并启动网关。
在「事件订阅」页面:
- 选择 「使用长连接接收事件」(WebSocket 模式)
- 添加事件:
im.message.receive_v1

1.8. 发布应用
进入「版本管理与发布」页面,创建版本并提交审核。企业自建应用通常会自动通过审批。


二、授权与测试
2.1.发送测试消息
在飞书中找到你的机器人(可在「应用」列表中搜索),发送一条消息。

2.2 批准配对码
默认情况下,机器人会回复一个 配对码。在终端执行:
# 查看待审批列表 openclaw pairing list feishu # 批准配对(将 <CODE> 替换为实际配对码) openclaw pairing approve feishu <CODE>批准后,用户即可正常对话。

💡 获取 ID 技巧:通过openclaw logs --follow查看日志,可以获取用户的open_id(格式ou_xxx)和群组chat_id(格式oc_xxx),用于后续高级配置。
三、可选:配置文件手动编辑
如需更精细的控制,可直接编辑配置文件 ~/.openclaw/openclaw.json:
{"channels":{"feishu":{"enabled":true,"dmPolicy":"pairing","accounts":{"main":{"appId":"cli_xxx","appSecret":"your-secret-here","botName":"企业AI助手"}}}}}国际版 Lark 用户需额外配置域名:
{"channels":{"feishu":{"domain":"lark","accounts":{"main":{"appId":"cli_xxx","appSecret":"xxx"}}}}}四、结语
通过命令行方式,你可以在任何环境中快速部署 OpenClaw 飞书机器人。这种方式特别适合自动化脚本和服务器部署,让 AI 助手无缝融入你的工作流。
五、视频教程
如果您觉得文字教程不够直观,欢迎访问我的 B 站频道观看完整视频版部署教程:
视频中我会实时演示每一步操作,详细讲解配置选项的含义,并演示如何在飞书中与机器人进行交互。建议搭配本文一起食用,效果更佳!