approval_gate hook).
This guide walks through the end-to-end setup. It assumes FIM One is reachable at a stable HTTPS origin — call this API_BASE_URL (e.g. https://one.yourdomain.com).
1. 创建飞书应用
- 前往 飞书开放平台,点击为企业创建自定义应用。
- 为应用命名、上传图标并添加简短描述 — 您组织的最终用户将在卡片上看到这些信息。
- 在凭证与基本信息页面,复制 App ID 和 App Secret。您将在第 4 步将它们粘贴到 FIM One 中。
2. 授予权限
在 Permissions & Scopes 下,启用以下作用域并提交权限版本:3. Enable event subscriptions (leave the Request URL blank for now)
Open Event Subscriptions, but don’t fill in the Request URL yet — you get it from FIM One in step 5. Subscribe the following events:card.action.trigger— Approve / Reject button clicks
4. Add the Channel in FIM One
- Sign in as an Org Owner or Admin.
- Go to Organization Settings → Channels → New Channel.
-
Pick Feishu as the type, then fill in:
- Click Browse chats — FIM One calls Feishu with your credentials and lists every group the bot is currently a member of.
- Pick the group chat you want to route to, click Save.
5. 向飞书注册回调 URL
保存后,FIM One 在频道详情面板上显示一个回调 URL,格式如下:url_verification 挑战;FIM One 会自动应答。
6. 发送测试消息
回到 FIM One 频道详情面板,点击发送测试消息。一条简短的纯文本消息(FIM One test message from <your email>)应该在一秒内出现在目标群组中。
如果没有出现:
- 401 / 403 — 重新检查 App Secret,重新启用第 2 步中的权限范围,并重新发布权限版本。
- 静默失败 — 确认机器人确实在群组中(第 4 步选择器)且频道行上的
is_active为 true。 - 第 5 步验证失败 — 确认
API_BASE_URL是 HTTPS 且可公开访问;飞书拒绝非 HTTPS 请求 URL。
7. Wire up an agent (optional — approvals)
To gate tool calls behind group approval:- On the tool / connector action, flip Requires confirmation on.
- In the agent editor’s Approval section, pick this channel as the Approval channel and set the mode to Auto or Channel only. The gate is attached to every agent automatically; no hook configuration is needed.
- Set the Approver scope (initiator, agent owner, or any org member). Approvers must have linked their Feishu account to their FIM One user, otherwise their click is ignored.
故障排除
在没有选择器的情况下查找 chat_id
浏览聊天 UI 是推荐的流程。如果您需要原始 ID(例如用于脚本编写中的 POST /api/channels 调用),有三个备选方案:
a. 直接对 Feishu 使用 curl
items[].chat_id(前缀为 oc_)都是一个候选项。
b. Feishu API 浏览器
在 Feishu 开放平台控制台中,打开 开发者工具 → API 浏览器,找到 /open-apis/im/v1/chats,选择 tenant_access_token 身份验证,然后点击调用。Feishu 会为您生成 token — 无需使用 shell。
c. 从 Feishu 客户端复制
在 Feishu 桌面或移动客户端中,打开群组 → 群组设置 → 群组信息,某些版本会显示复制群组 ID 选项。可用性取决于客户端版本和管理员设置的权限,因此这是最不可靠的备选方案。
卡片点击无法到达 FIM One(错误 200340)
如果在 Feishu 客户端中点击卡片上的批准或拒绝按钮产生出错了,请稍后重试 code: 200340,请按以下步骤排查:
card.action.trigger必须已订阅(第 3 步)。如果你在订阅前启用了审批门,请在 Feishu 控制台中点击重新订阅。- 重新保存回调 URL。 Feishu 有时会缓存陈旧的订阅状态,即使重启也会保留——即使 URL 验证握手仍然通过,事件路由也可能会无声地停止。打开 Feishu 开放平台的事件订阅页面,重新输入完全相同的回调 URL,然后再次点击保存 / 验证。URL 将在一个往返中重新验证,下次按下按钮时实时按钮点击将开始流动。当频道昨天还能工作但今天停止工作且没有代码更改时,这是最常见的修复方法。
- 检查 Feishu 开放平台中的事件调试器(
事件与回调 → 事件调试)。每次按钮按下都应该出现在那里,并显示投递状态(2xx/4xx/未投递)。如果你看到未投递,Feishu 本身在发送前就拒绝了事件——通常是缺少作用域或订阅被禁用。 - 作用域检查。 在
权限管理中,确保应用具有im:message和你的租户所需的任何card相关作用域。缺少作用域会导致订阅在 UI 中显示为绿色,但事件在投递时被无声地丢弃。