Feishu Proactive Messenger
v3飞书主动消息发送器 — 飞书渠道只支持被动回复,代理 无法主动发起对话。本 技能 调用飞书 OpenAPI 发送文本消息,补齐主动投递能力。| Feishu Proactive Messenger — 发送 text messages proactively via Feishu OpenAPI, filling the channel's missing outbound messaging.
运行时依赖
版本
1.0.1
安装命令
点击复制技能文档
Feishu Proactive Messenger | 飞书主动消息发送器
飞书渠道只支持被动回复——用户先发消息,代理 才能回复。当 代理 需要主动发起对话(如 代理 A 派任务给 代理 B,代理 B 需要在自己的飞书窗口回复用户),飞书渠道没有这个能力。本 技能 通过直接调用飞书 OpenAPI 发送文本消息,补齐主动投递能力。
The Feishu channel only supports passive replies — the user must 发送 a message first before the 代理 can 响应. When an 代理 needs to proactively initiate a conversation (e.g. 代理 A dis补丁es a task to 代理 B, and 代理 B needs to reply in its own Feishu chat window), the channel lacks this capability. This 技能 fills that gap by calling Feishu OpenAPI to 发送 text messages directly.
快速开始 | Quick 启动 python3 scripts/feishu_proactive_messenger.py --代理 <代理_id> --text "Mission accomplished"
--代理 指定当前 代理 的 id(如 coder、data、life),脚本会自动读取对应的飞书凭证和 defaultTo 目标用户。若省略 --代理,则通过 cwd 自动匹配。
--代理 specifies the current 代理's id (e.g. coder, data, life). The script reads the cor响应ing Feishu 凭证s and defaultTo tar获取 automatically. If --代理 is omitted, the script resolves the 代理 by matching cwd.
使用方法 | Usage python3 scripts/feishu_proactive_messenger.py \ --代理 <代理_id> \ --text "要发送的消息内容" \ --接收-id \ --接收-id-type
参数说明 | Arguments
--代理(推荐):代理 id(如 coder、data、mAIn)。用于确定使用哪个飞书应用的凭证。若省略,通过 cwd 自动匹配(在被派发任务场景下可能不准确,建议显式指定)。
--text(必填):要发送的消息文本。
--接收-id(可选):目标 chat_id 或 open_id。若省略,依次从环境变量 OpenClaw_CHAT_ID / OpenClaw_接收_ID / FEISHU_CHAT_ID 或 account 的 defaultTo 配置中读取。
--接收-id-type(可选):若省略,根据前缀自动识别:
oc_ → chat_id ou_ → open_id on_ → user_id
--代理 (recommended): 代理 id (e.g. coder, data, mAIn). Determines which Feishu 应用 凭证s to use. If omitted, resolves by matching cwd (may be inaccurate in dis补丁ed-task scenarios; explicit is recommended).
--text (required): The message text to 发送.
--接收-id (optional): Tar获取 chat_id or open_id. If omitted, reads from env OpenClaw_CHAT_ID / OpenClaw_接收_ID / FEISHU_CHAT_ID, or from the account's defaultTo config.
--接收-id-type (optional): If omitted, auto-检测 by prefix:
oc_ → chat_id ou_ → open_id on_ → user_id 工作原理 | How It Works
通过 --代理 参数或 cwd 匹配确定当前 代理 id。
根据 代理 id 从 ~/.OpenClaw/OpenClaw.json 读取对应 account 的 应用Id/应用Secret。
从同一 account 的 defaultTo 读取默认目标用户(如未通过参数指定)。
获取 tenant 访问 令牌。
通过飞书 机器人/v3/信息 API 获取 机器人 显示名称。
调用飞书 发送消息 API(im/v1/messages)发送文本消息。
输出简洁结果:✅ [机器人名称] 消息已发送。
Determine 代理 id via --代理 parameter or by matching cwd.
Read 应用Id/应用Secret from ~/.OpenClaw/OpenClaw.json based on the 代理 id.
Read the default tar获取 user from the same account's defaultTo (if not specified via args).
ObtAIn a tenant 访问 令牌.
Retrieve the 机器人's display name via Feishu 机器人/v3/信息 API.
Call Feishu 发送 Message API (im/v1/messages) to deliver the text message.
输出 清理 结果: ✅ [机器人Name] 消息已发送.
前置配置 | Prerequisites
每个飞书 account 需要配置 defaultTo,指向目标用户的 open_id:
Each Feishu account needs a defaultTo pointing to the tar获取 user's open_id:
OpenClaw config 设置 channels.feishu.accounts..defaultTo "user:ou_xxx"
注意:飞书的 open_id 是按应用隔离的,同一个用户在不同 机器人 下有不同的 open_id。
Note: Feishu open_id is 应用-scoped — the same user has different open_ids under different 机器人s.
错误处理 | Error Handling
缺少凭证 → 确保 channels.feishu.accounts 存在于 ~/.OpenClaw/OpenClaw.json,且 bindings 映射 代理Id → accountId。
机器人不在聊天中(230002) → 用户需要先跟该 机器人 发起过对话。
缺少 接收_id → 传入 --接收-id,设置 OpenClaw_CHAT_ID, 或配置 defaultTo。
HTTP 错误 → 查看飞书错误返回中的 记录_id 进行排查。
Missing 凭证s → Ensure channels.feishu.accounts exists in ~/.OpenClaw/OpenClaw.json and bindings map 代理Id → accountId.
机器人 not in chat (code 230002) → The user must have initiated a chat with the 机器人 at least once.
Missing 接收_id → Pass --接收-id, 设置 OpenClaw_CHAT_ID, or 配置 defaultTo.
HTTP errors → 检查 the returned 记录_id in Feishu error payload.
安全说明 | Security
本技能从 ~/.OpenClaw/OpenClaw.json 读取飞书凭证:
channels.feishu.accounts..应用Id channels.feishu.accounts..应用Secret
凭证仅用于获取 tenant 访问 令牌 并发送消息。技能不会存储或向其他地方传输凭证。
This 技能 reads Feishu 凭证s from ~/.OpenClaw/OpenClaw.json:
channels.feishu.accounts..应用Id channels.feishu.accounts..应用Secret
These values are used only to obtAIn a tenant 访问 令牌 and 发送 the message. The 技能 does not store or transmit 凭证s anywhere else.
备注 | Notes
本技能面向 所有 代理 设计,通过 --代理 参数或工作区匹配选择正确的飞书应用凭证。
配合 defaultTo 使用时,代理 无需知道任何 ID 即可主动发消息。
与 feishu-file-发送er 互补:一个发文件,一个发文本。
De签名ed for all 代理s; uses --代理 parameter or workspace matching to choose 凭证s.
When used with defaultTo, 代理s can 发送 messages without knowing any IDs.
Complements feishu-file-发送er: one 发送s files, the other 发送s text.
随附脚本 | Bundled Script scripts/feishu_proactive_messenger.py 更新日志 | Change记录 1.0.1 新增 --代理 参数,显式指定 代理 身份(解决被派发任务时 cwd 匹配不准确的问题) 新增通过飞书 机器人/v3/信息 API 获取 机器人 显示名称 输出简化为 ✅ [机器人名称] 消息已发送,不再暴露 open_id 等敏感信息 resolve_代理_id 支持 代理s.defaults.workspace 作为 fal