← Back to Skills Marketplace
skyfate

FeiShu Robot @ Protocol

by Leng<o(YoY)o> · GitHub ↗ · v0.2.1 · MIT-0
cross-platform ⚠ suspicious
293
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install feishu-robot-protocol
Description
定义飞书机器人身份消息协议,实现多机器人间统一发送者身份识别和用户身份消息回复,支持群组用户映射管理和定时更新。
README (SKILL.md)

Skill: 飞书机器人身份消息协议 v2

概述

本技能定义了飞书机器人之间的双层消息通信协议,解决机器人之间无法相互@触发 mention 事件的问题。

核心概念

1. 双层消息机制

机器人主动 @另一个机器人(或多人)时,需要发送两条消息:

格式说明【发送者->接收者1,接收者2...】

  • -> 前面是发信人
  • -> 后面是收信人,多个用逗号分隔

多人场景

  • 第一条:【发送者->接收者1,接收者2...】
  • 第二条:@所有接收者

示例(@两个人)

  • 第一条:\x3Cat user_id="ou_A">A\x3C/at>\x3Cat user_id="ou_B">B\x3C/at> 【发送者->A,B】
  • 第二条:\x3Cat user_id="ou_A">A\x3C/at>\x3Cat user_id="ou_B">B\x3C/at> [图钉]【发送者->A,B】[图钉]

第1步:用机器人身份发送(message 工具)

\x3Cat user_id="接收者ID">接收者\x3C/at> 📌【发送者->接收者】📌
消息正文
  • message 工具只支持 emoji 📌,不支持 [图钉] 占位符
  • 群里所有人都能看到是机器人发的
  • 有【】格式标识发送者和接收者

第2步:用用户身份发送(feishu_im_user_message send) 两种格式可选:

格式1:富文本 post

内容:{"zh_cn":{"content":[[{"tag":"at","user_id":"ou_接收者ID","name":"接收者"},{"tag":"text","text":" 📌【发送者->接收者】或【发送者->接收者1,接收者2...】📌"}]]}}
格式:post(必须使用 emoji 📌,[图钉] 不会显示)

格式2:纯文本 text(推荐)

内容:\x3Cat user_id="ou_接收者ID">接收者\x3C/at> [图钉]【发送者->接收者】或【发送者->接收者1,接收者2...】[图钉]
格式:text(使用飞书占位表情 [图钉] 或 emoji 📌 都可以)
  • 优先使用此格式(第二条消息)
  • 如果发送失败,再使用富文本 post 格式
  • 第一条消息根据情况自行决定(可text可post)
  • 触发 mention 事件
  • 被 @的机器人收到通知

2. 用户名-ID 映射表

维护映射文件,按群分组记录用户名和用户 ID 的对应关系。

文件位置: ~/.openclaw/workspace/feishu-user-map.md

格式:

## 群组:龙虾池塘 (chat_id)

| 用户名 | 用户ID (open_id) | 类型 | 更新时间 |
|--------|------------------|------|----------|
| saber | ou_xxx | bot | 2026-03-14T09:00:00+08:00 |
| Excalibur | ou_xxx | bot | 2026-03-14T09:00:00+08:00 |
| Qilin | ou_xxx | bot | 2026-03-14T09:00:00+08:00 |

## 全局配置

- **ID过期时间**:21600 秒(6小时)

3. 消息格式

第1条(机器人身份):

\x3Cat user_id="接收者ID">接收者\x3C/at> 📌【发送者->接收者】📌
消息正文
  • message 工具只支持 emoji 📌,不支持 [图钉] 占位符

第2条(用户身份):

{"zh_cn":{"content":[[{"tag":"at","user_id":"ou_qilin","name":"Qilin"},{"tag":"text","text":" 📌【发送者->Qilin】📌"}]]}}

发送消息流程

主动 @另一个机器人

  1. 第1步(机器人身份):
// 使用 message 工具发送
await message({
    action: 'send',
    channel: 'feishu',
    message: '\x3Cat user_id="接收者ID">接收者\x3C/at> 【发送者->接收者】或【发送者->接收者1,接收者2...】\
消息正文',
    target: 'chat:群ID'
});
  1. 第2步(用户身份,用 feishu_im_user_message 发送富文本):
// 使用 feishu_im_user_message 发送富文本
// 注意:[📌] 用 emoji 字符 📌 代替
await feishu_im_user_message({
    action: 'send',
    msg_type: 'post',
    content: '{"zh_cn":{"content":[[{"tag":"at","user_id":"ou_接收者ID","name":"接收者"},{"tag":"text","text":" 📌【发送者->接收者】或【发送者->接收者1,接收者2...】📌"}]]}}',
    receive_id: '群ID',
    receive_id_type: 'chat_id'
});

接收者处理流程

当收到 mention 事件时:

1. 解析发送者

优先检查: 是否有符合以下条件的消息?

  • 内容包含 @接收者📌【发送者->接收者】或【发送者->接收者1,接收者2...】📌
  • 是用户发送的(sender_type = user)
  • msg_type 是 post
  • 有引用(reply_to 字段)

如果有: 解析引用指向的第一条消息,获取【】里的发送者

如果没有: 往上回溯,找到最近一条满足:

  • 【发送者->接收者】或【发送者->接收者1,接收者2...】格式匹配
  • 发送者是当前消息的发送者

2. 回复(也是两步)

第1步(机器人身份):

\x3Cat user_id="原发送者ID">原发送者\x3C/at> 【接收者->原发送者】
回复内容

第2步(用户身份):

{"zh_cn":{"content":[[{"tag":"at","user_id":"ou_原发送者ID","name":"原发送者"},{"tag":"text","text":" 📌【接收者->原发送者】📌"}]]}}
(引用第1条消息)

示例

场景:saber让 Excalibur 找 Qilin 讨论

发送方(saber):

  1. 第1条(Excalibur 机器人):

    \x3Cat user_id="ou_qilin">Qilin\x3C/at> 【Excalibur->Qilin】
    saber有事找你
    
  2. 第2条(saber用户):

    {"zh_cn":{"content":[[{"tag":"at","user_id":"ou_qilin","name":"Qilin"},{"tag":"text","text":" 📌【Excalibur->Qilin】📌"}]]}}
    (引用第1条)
    

接收方(Qilin):

  1. 收到 mention 事件

  2. 找到第2条消息(post格式),包含 @Qilin📌【Excalibur->Qilin】📌

  3. 解析引用,找到第1条,获取发送者是 Excalibur

  4. 回复:

    • 第1条(Qilin 机器人):

      \x3Cat user_id="ou_excalibur">Excalibur\x3C/at> 【Qilin->Excalibur】
      好的,什么事?
      
    • 第2条(Qilin 用户):

      {"zh_cn":{"content":[[{"tag":"at","user_id":"ou_excalibur","name":"Excalibur"},{"tag":"text","text":" 📌【Qilin->Excalibur】📌"}]]}}
      (引用第1条)
      

映射表管理

ID过期刷新机制

配置参数:

  • ID过期时间(秒):默认 21600 秒(6小时)
  • 可在 feishu-user-map.md 中修改

刷新逻辑:

  1. 每次使用映射表时,检查每条记录的"更新时间"
  2. 如果当前时间与更新时间之差 > 过期时间,则重新获取该用户ID
  3. 重新获取方式:从最近的消息历史中查找该用户发送的消息,从 mentions 字段获取最新ID

刷新时机:

  • 发送消息前检查接收者ID是否过期
  • 收到消息时检查发送者ID是否过期

手动触发

在群里发送:查看并记录群的成员名称列表 [数量]

查询函数

// 根据群组和用户名查找信息
function getUserInfoByGroup(chatId, username) {
    const groupMap = loadUserMapByGroup(chatId);
    return groupMap[username];  // 返回 { id: "ou_xxx", type: "user|bot", updatedAt: "ISO时间" }
}

// 根据群组和ID查找用户名
function getUserNameByGroup(chatId, userId) {
    const groupMap = loadUserMapByGroup(chatId);
    for (const [name, info] of Object.entries(groupMap)) {
        if (info.id === userId) return name;
    }
    return null;
}

// 检查ID是否过期,过期则刷新
async function getUserIdWithRefresh(chatId, username) {
    const userInfo = getUserInfoByGroup(chatId, username);
    if (!userInfo) return null;

    const expireSeconds = getExpireSeconds(); // 默认21600
    const now = new Date();
    const updated = new Date(userInfo.updatedAt);
    const diffSeconds = (now - updated) / 1000;

    if (diffSeconds > expireSeconds) {
        // ID过期,需要刷新
        const newId = await refreshUserIdFromHistory(chatId, username);
        if (newId) {
            updateUserId(chatId, username, newId);
            return newId;
        }
    }
    return userInfo.id;
}

// 从历史消息中刷新用户ID
async function refreshUserIdFromHistory(chatId, username) {
    // 获取最近的消息,找到该用户发送的消息
    const messages = await feishu_im_user_get_messages({
        chat_id: chatId,
        page_size: 50
    });

    for (const msg of messages) {
        if (msg.sender.name === username && msg.mentions) {
            for (const mention of msg.mentions) {
                if (mention.name === username) {
                    return mention.id;
                }
            }
        }
    }
    return null;
}

⚠️ 重要前提

本 skill 中所有示例都是示例,不能直接使用!

  • ❌ 不能直接用 ou_接收者ID 这个值
  • ❌ 不能直接用 接收者 这个名字
  • ✅ 必须替换为实际的值(从 feishu-user-map.md 或 mentions 获取)

注意事项

  1. 必须使用 user_id(不是 id)在 @标签中
  2. @标签中必须用 ou_xxx,不能用名字(机器人身份无法解析名字)
  3. @标签中 ou_xxx 不能为空,必须按以下优先级获取:
    • 优先从 feishu-user-map.md 查找
    • 如果找不到,回溯群里历史消息获取真实 ID
    • 绝对不能留空!
    • 绝对不能直接用 skill 样例中的值!
  4. 回复规则:
    • 如果消息中有 [图钉]【发送者->接收者】[图钉] 或 📌【发送者->接收者】📌 标记,解析【】并回复给【】中的发送者
    • 如果没有标记,按正常逻辑回复@你的人
  5. 第二条消息必须有占位符:[图钉] 或 📌(判断时需同时兼容占位符和 emoji 📌)
  6. 回复时也是两步:机器人身份 + 用户身份 reply
  7. 解析发送者时优先找有引用的用户消息
  8. 如果找不到匹配的引用消息,再回溯查找
  9. 定期刷新ID,防止ID过期导致@失败
Usage Guidance
What to check before installing: - Confirm your OpenClaw runtime provides the Feishu primitives referenced (message, feishu_im_user_message, feishu_im_user_get_messages) and that those calls are already authenticated by the platform; the skill does not declare or request Feishu API keys itself. - Be aware the skill reads recent group message history and extracts mention IDs, then writes a mapping file to ~/.openclaw/workspace/feishu-user-map.md. This file contains user IDs and timestamps — treat it as sensitive (set restrictive file permissions, review contents periodically, and clean on uninstall if needed). - The examples in SKILL.md are placeholders; you must replace names/IDs with real values. Test in a controlled/staging group before enabling in production. - If organization policy restricts automated collection of user identifiers or message history, do not enable this skill without approval. - If you want stronger guarantees, ask the author/runtime provider how auth is handled and whether the mapping file is encrypted or access-controlled.
Capability Analysis
Type: OpenClaw Skill Name: feishu-robot-protocol Version: 0.2.1 The skill implements a complex 'two-layer' communication protocol designed to bypass Feishu (Lark) platform restrictions that prevent bots from mentioning each other. It requires high-privilege capabilities, specifically the ability to send messages as a user (`feishu_im_user_message`) and harvest user IDs from message history (`feishu_im_user_get_messages`). It also maintains a local database of user/bot mappings in `~/.openclaw/workspace/feishu-user-map.md`. While these actions are aligned with the stated purpose, the use of user-level impersonation and automated data harvesting from chat history represents a significant and potentially risky permission set.
Capability Assessment
Purpose & Capability
The skill describes a message/mention protocol between Feishu robots and its instructions map directly to that purpose (sending two messages, parsing mentions, maintaining a user-id map). No unrelated capabilities, binaries, or external services are requested.
Instruction Scope
Instructions explicitly tell the agent to read recent group message history (via feishu_im_user_get_messages or equivalent), parse mentions, and write/update a local mapping file (~/.openclaw/workspace/feishu-user-map.md). Those actions are necessary for the stated purpose, but they involve reading message content and mentions (sensitive data) and rely on platform-provided Feishu I/O functions.
Install Mechanism
No install spec or external downloads; this is instruction-only so nothing is written to disk by an install step. Risk from installation mechanism is minimal.
Credentials
The skill declares no environment variables or credentials. That is consistent if the OpenClaw runtime already provides feishu_im_user_message / get_messages primitives and the agent's Feishu integration handles auth. If those platform primitives are not present, the SKILL.md assumes access to Feishu APIs but does not declare required credentials—verify the runtime supplies these APIs and the necessary tokens. Also note the skill will collect and store user IDs and timestamps in a local file (privacy consideration).
Persistence & Privilege
always:false (no forced always-on). The skill persists a mapping file in ~/.openclaw/workspace which is within the agent's workspace (expected). It does not request system-wide config changes or other skills' credentials.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install feishu-robot-protocol
  3. After installation, invoke the skill by name or use /feishu-robot-protocol
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.2.1
v0.2.1 introduces a major update with a double-layer messaging protocol for Feishu robots. - Implements "double message" mechanism for robot-to-robot @mentions to reliably trigger mention events. - Adds dual-format sending: first message by robot account, second message by user account using feishu_im_user_message. - Updates reply and parsing logic to handle double-layer message recognition, always associating replies with correct sender. - Message protocol now requires explicit 📌/图钉 marker for parsing, supporting group and multi-person mention. - Enhances user ID mapping: adds ID expiration and refresh logic; mapping file records last updated timestamp for each user. - All examples clarified—placeholders must be replaced by real mapping values, not used verbatim.
v0.1.0
Initial release of "飞书机器人身份消息协议" skill - Defines a unified protocol for identity recognition and messaging between multiple OpenClaw robots in Feishu groups. - Introduces a per-group user-name-to-ID mapping table in markdown format, auto-synced daily and manually triggerable. - Specifies standard message format for sender and receiver tagging, ensuring consistent identity parsing and reply behavior. - Outlines automatic and manual mechanisms for updating group user/robot mappings by scanning recent messages. - Provides code examples and utility functions for querying, updating, and maintaining the mapping table.
Metadata
Slug feishu-robot-protocol
Version 0.2.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is FeiShu Robot @ Protocol?

定义飞书机器人身份消息协议,实现多机器人间统一发送者身份识别和用户身份消息回复,支持群组用户映射管理和定时更新。 It is an AI Agent Skill for Claude Code / OpenClaw, with 293 downloads so far.

How do I install FeiShu Robot @ Protocol?

Run "/install feishu-robot-protocol" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is FeiShu Robot @ Protocol free?

Yes, FeiShu Robot @ Protocol is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does FeiShu Robot @ Protocol support?

FeiShu Robot @ Protocol is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created FeiShu Robot @ Protocol?

It is built and maintained by Leng<o(YoY)o> (@skyfate); the current version is v0.2.1.

💬 Comments