← 返回 Skills 市场
evan966890

飞书开放平台应用自动化配置

作者 evan966890 · GitHub ↗ · v1.0.0
cross-platform ⚠ suspicious
462
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install feishu-app-setup
功能描述
自动化完成飞书开放平台企业自建应用的创建、权限配置、事件订阅、改名和版本发布,简化繁琐操作流程。
使用说明 (SKILL.md)

feishu-app-setup — 飞书开放平台应用自动化配置

用 agent-browser 自动完成飞书企业自建应用的创建、权限配置、事件订阅、改名和版本发布。

在飞书开放平台上配置一个 OpenClaw bot 应用需要大量重复的点击操作。这个技能把整个流程自动化了:创建应用、添加机器人能力、批量导入权限、配置事件订阅、修改应用名称、发布版本——全部通过 agent-browser 在浏览器中自动完成。

前置条件

  • 已安装 agent-browser 技能
  • 已登录飞书开放平台(https://open.feishu.cn)
  • OpenClaw Gateway 正在运行(事件订阅需要活跃的 WebSocket 连接)

连接浏览器

方式一:连接已有浏览器(推荐)

OpenClaw Gateway 运行时通常已启动 Chrome debug 实例。直接连接已登录的浏览器,无需重新登录:

# 连接到已有 Chrome 实例(已有飞书 session)
agent-browser --cdp-endpoint http://localhost:9223 open "https://open.feishu.cn/app"

优势:无需扫码登录,直接可用。适合批量操作。

方式二:启动新浏览器

agent-browser --headed open "https://open.feishu.cn/app"
# 用户扫码登录后,后续操作均可自动化

完整配置流程

创建应用 → 添加机器人能力 → 权限导入 → 事件订阅 → 改名(可选)→ 版本发布 → OpenClaw 配置 → 配对审批

Step 1: 创建应用

agent-browser find role button click --name "创建企业自建应用"
sleep 2

填写表单(React 受控组件)

飞书开放平台使用 React。agent-browser fill @ref 通常可以正常工作,但在 fill 失败时需要回退到原生 setter:

// React 受控 input 的可靠填写方式
const s = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
s.call(inputElement, '目标值');
inputElement.dispatchEvent(new Event('input', {bubbles: true}));

提取凭证

// App ID
const m = document.body.innerText.match(/cli_[a-f0-9]+/);
// App Secret — 先点眼睛图标显示
const eyeBtn = document.querySelectorAll('[data-icon="VisibleOutlined"]');

注意: App Secret 旁边有 3 个图标按钮:复制(CopyOutlined)、显示(VisibleOutlined)、重置(RefreshOutlined)。千万别点重置

Step 2: 添加机器人能力

agent-browser find text "添加应用能力" click
sleep 2
agent-browser eval "
  const btns = [...document.querySelectorAll('button')].filter(b => b.textContent.trim() === '+ 添加' || b.textContent.trim() === '添加');
  if (btns[0]) btns[0].click();
"

Step 3: 权限批量导入

推荐权限集(OpenClaw 所需最小权限)

{
  "scopes": {
    "tenant": [
      "im:message",
      "im:message:send_as_bot",
      "im:message:readonly",
      "im:message.p2p_msg:readonly",
      "im:message.group_at_msg:readonly",
      "im:resource",
      "im:chat.members:bot_access",
      "im:chat.access_event.bot_p2p_chat:read",
      "contact:user.employee_id:readonly",
      "contact:contact.base:readonly",
      "application:application:self_manage",
      "application:application.app_message_stats.overview:readonly",
      "application:bot.menu:write",
      "event:ip_list",
      "aily:file:read",
      "aily:file:write",
      "corehr:file:download"
    ],
    "user": [
      "aily:file:read",
      "aily:file:write",
      "im:chat.access_event.bot_p2p_chat:read"
    ]
  }
}

重要: contact:contact.base:readonly 必须包含,否则 agent 无法读取用户信息。

操作步骤

# 点击"批量导入/导出权限"
agent-browser snapshot -i | grep '批量'
agent-browser click @eXX
sleep 2

# Monaco 编辑器填写:全选 → 粘贴
agent-browser eval "document.querySelector('.monaco-editor textarea').focus()"
agent-browser press Meta+a
sleep 0.3

# 用 ClipboardEvent 粘贴(Monaco 不支持普通 fill)
agent-browser eval "
  const json = JSON.stringify(PERM_JSON, null, 2);
  const ta = document.querySelector('.monaco-editor textarea');
  const dt = new DataTransfer();
  dt.setData('text/plain', json);
  ta.dispatchEvent(new ClipboardEvent('paste', {clipboardData: dt, bubbles: true, cancelable: true}));
"
sleep 1

# 点击"下一步,确认新增权限" → "申请开通"

部分权限(如通讯录相关)会弹出"数据范围"确认对话框,需要额外点击"确认"。

Step 4: 事件订阅(长连接 WebSocket)

先决条件:Gateway 必须先连接

飞书有个鸡生蛋的问题:保存长连接订阅方式时,飞书会检查是否已有活跃的 WebSocket 连接。正确顺序

  1. 先在 openclaw.json 配置应用凭证
  2. 重启 Gateway,让它建立 WebSocket 连接
  3. 然后再到飞书控制台保存订阅方式

否则会报错:code: 10068, msg: "应用未建立长连接"

配置订阅方式

agent-browser open "https://open.feishu.cn/app/$APP_ID/event"
sleep 4
agent-browser eval "document.querySelector('.app-layout__main').scrollTo(0, 500)"
sleep 1

# 点编辑按钮
agent-browser snapshot -i | grep '订阅方式'
agent-browser click @eXX
sleep 1

# 长连接默认选中,直接保存
agent-browser find role button click --name "保存"
sleep 3

添加事件

agent-browser snapshot -i | grep '添加事件'
agent-browser click @eXX
sleep 2

# 用搜索框精确查找(避免在分类列表中翻找选错)
agent-browser snapshot -i | grep 'textbox.*nth=1'
agent-browser fill @eXX "im.message.receive_v1"
sleep 2

# 勾选搜索结果
agent-browser snapshot -i | grep 'checkbox'
agent-browser click @eXX
sleep 1

# 确认添加
agent-browser snapshot -i | grep '确认添加'
agent-browser click @eXX

Step 5: 应用改名

应用名称在 基础信息 → 国际化配置 中修改:

agent-browser open "https://open.feishu.cn/app/$APP_ID/baseinfo"
sleep 3

# 滚动到"国际化配置"区域
agent-browser eval "document.querySelector('.app-layout__main').scrollTo(0, 1000)"
sleep 1

# 点击编辑铅笔图标
agent-browser snapshot -i | grep 'EditOutlined\|编辑'
agent-browser click @eXX
sleep 2

# 清除旧名称并填写新名称
agent-browser snapshot -i | grep 'textbox'
agent-browser fill @eXX "新名称"
sleep 1

# 保存
agent-browser find role button click --name "保存"
sleep 2

注意:改名后必须创建新版本并发布,新名字才会在飞书聊天中生效。

批量改名

APP_IDS=("cli_xxx1" "cli_xxx2" "cli_xxx3")
NAMES=("名字1" "名字2" "名字3")

for i in "${!APP_IDS[@]}"; do
  agent-browser open "https://open.feishu.cn/app/${APP_IDS[$i]}/baseinfo"
  sleep 3
  # 编辑国际化配置 → 填写新名称 → 保存
done

Step 6: 版本发布

# 点"创建版本"
agent-browser find role button click --name "创建版本"
sleep 3

# 填写更新说明(版本号自动递增)
agent-browser snapshot -i | grep 'textbox'
agent-browser fill @eXX "更新应用配置"

# 保存版本
agent-browser find role button click --name "保存"
sleep 3

# 申请发布
agent-browser find role button click --name "申请线上发布"
sleep 2

# 确认发布
agent-browser eval "
  const btn = [...document.querySelectorAll('button')].find(b => b.textContent.trim() === '确定');
  if (btn) btn.click();
"
sleep 2

发布注意事项

  • 企业自建应用通常免审核,提交即上线
  • 发布前可能需要确认数据权限范围(如"飞书人事"相关权限需设为"全部")
  • 发布成功后状态显示 "已发布" + "当前修改均已发布"
  • 改名 + 发布通常配合进行,流程:改名 → 保存 → 创建版本 → 发布

Step 7: OpenClaw 多账号配置

{
  "channels": {
    "feishu": {
      "enabled": true,
      "accounts": {
        "main": { "appId": "cli_xxx", "appSecret": "xxx", "name": "主助手" },
        "agent2": { "appId": "cli_yyy", "appSecret": "yyy", "name": "助手2" }
      }
    }
  },
  "bindings": [
    { "agentId": "main", "match": { "channel": "feishu", "accountId": "main" } },
    { "agentId": "agent2", "match": { "channel": "feishu", "accountId": "agent2" } }
  ]
}

重启 Gateway 使配置生效:

launchctl stop ai.openclaw.gateway && sleep 3 && launchctl start ai.openclaw.gateway

Step 8: 配对审批

用户首次给 bot 发消息时,OpenClaw 返回配对请求。每个用户对每个 bot 需要单独配对一次。

openclaw pairing approve feishu \x3C配对码>

操作模式:snapshot + ref

所有操作的核心模式:用 agent-browser snapshot -i 获取页面元素 ref,用 grep 提取,再用 ref 操作。比 JS 选择器更可靠。

REF=$(agent-browser snapshot -i 2>&1 | grep 'button "保存"' | head -1 | grep -o 'ref=e[0-9]*' | sed 's/ref=//')
if [ -n "$REF" ]; then
  agent-browser click @$REF
fi

踩坑记录

问题 原因 解决
保存订阅方式报 10068 Gateway 未连接 先配 openclaw.json → 重启 → 再保存
添加事件选错 分类列表太长 用搜索框精确搜索 im.message.receive_v1
React input fill 无效 受控组件问题 用原生 setter + dispatchEvent
Monaco 编辑器无法 fill 非标准 input 用 ClipboardEvent paste
权限不足报错 contact:contact.base:readonly 加到权限 JSON 中
权限变更后仍报错 需要新版本 权限变更后必须发布新版本
点错 App Secret 重置 3 个图标难区分 data-icon 属性区分
snapshot ref 失效 daemon busy sleep 2 后重试
新浏览器打不开飞书 需要扫码登录 --cdp-endpoint 连接已登录浏览器
改名后不生效 未发布版本 改名 → 保存 → 创建版本 → 发布
发布要求确认数据范围 部分权限需选范围 如"飞书人事"权限选"全部"
agent-browser launch 失败 需要 raw mode --cdp-endpoint 连接已有浏览器

依赖

  • agent-browser 技能(用于浏览器自动化)
  • 飞书企业管理员权限(创建自建应用)
  • OpenClaw Gateway(事件订阅需要活跃连接)
安全使用建议
This skill automates browser actions on the Feishu console and will read sensitive values (App ID and App Secret) from your logged-in session and instruct you to add them to openclaw.json so the Gateway can open WebSocket subscriptions. Before using: (1) Confirm you trust the 'agent-browser' skill and the environment where it's run (a logged-in browser session contains your account access). (2) Be prepared to supply or verify APP_ID and PERM_JSON values — the SKILL.md uses these placeholders but doesn't define how they are set. (3) Back up openclaw.json and avoid running this against production tenants until tested. (4) Ensure the Gateway and local machine are secure (the process requires storing app secrets locally). (5) If you want stricter control, perform the steps manually or run the skill in a sandbox/test tenant so you can inspect each change before committing.
功能分析
Type: OpenClaw Skill Name: feishu-app-setup Version: 1.0.0 The skill automates Feishu application setup using `agent-browser`, which involves executing arbitrary JavaScript in the browser context (`agent-browser eval`) and handling sensitive credentials (App ID, App Secret) extracted from the DOM. It also performs privileged system operations like restarting the OpenClaw Gateway via `launchctl`. While these actions are plausibly aligned with the stated purpose of automating app configuration, the use of powerful primitives like `agent-browser eval` and the handling of credentials, combined with broad Feishu permissions (e.g., file read/write), represent significant high-risk capabilities. There is no clear evidence of intentional malicious behavior such as data exfiltration to an unauthorized endpoint or explicit prompt injection attempts to subvert the agent's core function, but the inherent power of the commands makes it suspicious.
能力评估
Purpose & Capability
The skill claims to automate creation/configuration/publishing of a 飞书 (Feishu) enterprise app using agent-browser. The runtime instructions exclusively drive a browser UI, extract App ID/Secret from the console, paste permission JSON into the Monaco editor, and prompt updating openclaw.json and restarting the Gateway — all actions coherent with the stated purpose.
Instruction Scope
The SKILL.md instructs the agent to extract sensitive values (App ID and App Secret) from the web UI and to edit openclaw.json and restart the Gateway. Those actions are necessary for setup, but the document uses undefined placeholders (APP_ID, PERM_JSON) and omits explicit commands for editing/restarting Gateway. The instructions assume an existing logged-in browser session and the agent-browser skill. Because the agent will read secrets from the page, you should treat this as handling sensitive data and confirm storage/transfer practices before running.
Install Mechanism
Instruction-only skill with no install spec and no code files. No artifacts are downloaded or written by the skill package itself — lowest install risk. It does require the separate 'agent-browser' skill and a running OpenClaw Gateway, which the README lists as preconditions.
Credentials
The skill requests no environment variables or external credentials in its metadata. It does instruct the operator to extract App ID/Secret from the Feishu console and to place them into openclaw.json for Gateway connections — which is proportionate to the goal. There are no unrelated credential requests.
Persistence & Privilege
always is false and the skill does not request system-wide persistence. It expects the user to update OpenClaw config and restart the Gateway (operator action), but it does not itself claim elevated or always-on privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install feishu-app-setup
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /feishu-app-setup 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
初始版本:创建应用、权限导入、事件订阅、改名、版本发布全流程自动化
元数据
Slug feishu-app-setup
版本 1.0.0
许可证
累计安装 0
当前安装数 0
历史版本数 1
常见问题

飞书开放平台应用自动化配置 是什么?

自动化完成飞书开放平台企业自建应用的创建、权限配置、事件订阅、改名和版本发布,简化繁琐操作流程。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 462 次。

如何安装 飞书开放平台应用自动化配置?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install feishu-app-setup」即可一键安装,无需额外配置。

飞书开放平台应用自动化配置 是免费的吗?

是的,飞书开放平台应用自动化配置 完全免费(开源免费),可自由下载、安装和使用。

飞书开放平台应用自动化配置 支持哪些平台?

飞书开放平台应用自动化配置 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 飞书开放平台应用自动化配置?

由 evan966890(@evan966890)开发并维护,当前版本 v1.0.0。

💬 留言讨论