feishu-messaging

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

飞书消息与文档 Skill

Feishu Message and Document Skill

概述

Overview

此 Skill 通过飞书开放平台 API 帮助用户发送消息、创建文档和管理飞书资源。
This Skill helps users send messages, create documents, and manage Feishu resources through the Feishu Open Platform API.

核心能力

Core Capabilities

功能状态所需权限
发送文本消息✅ 可用
im:message:send_as_bot
发送富文本消息✅ 可用
im:message:send_as_bot
发送卡片消息✅ 可用
im:message:send_as_bot
获取群聊列表✅ 可用
im:chat:readonly
获取群成员⏳ 待授权
im:chat.members:read
创建飞书文档⏳ 待授权
docx:document
创建多维表格⏳ 待授权
bitable:app
创建知识库页面⏳ 待授权
wiki:wiki
FunctionStatusRequired Permissions
Send Text Message✅ Available
im:message:send_as_bot
Send Rich Text Message✅ Available
im:message:send_as_bot
Send Card Message✅ Available
im:message:send_as_bot
Get Group Chat List✅ Available
im:chat:readonly
Get Group Members⏳ Pending Authorization
im:chat.members:read
Create Feishu Document⏳ Pending Authorization
docx:document
Create Feishu Base⏳ Pending Authorization
bitable:app
Create Knowledge Base Page⏳ Pending Authorization
wiki:wiki

使用方法

Usage Methods

发送消息给指定用户

Send Message to Specified User

给 [姓名] 发一条飞书消息,告诉他 [内容]
前置条件:需要获取用户的 open_id
Send a Feishu message to [Name], telling him [content]
Prerequisite: Need to obtain the user's open_id

获取用户 open_id 的方法

Methods to Obtain User open_id

  1. 方法一:通过邮箱/手机号查询(需要
    contact:user.id:readonly
    权限)
    用户邮箱:xxx@company.com
  2. 方法二:让用户主动发消息
    • 用户在飞书中搜索机器人名称
    • 发送任意消息
    • 机器人获取到用户的 open_id
  3. 方法三:用户自行查看
    • 用户在机器人对话中发送
      /myid
    • 或从飞书开放平台后台查看
  1. Method 1: Query via Email/Phone Number (Requires
    contact:user.id:readonly
    permission)
    User Email: xxx@company.com
  2. Method 2: Ask User to Send Message Actively
    • User searches for the bot name in Feishu
    • Sends any message
    • The bot obtains the user's open_id
  3. Method 3: User Checks Themselves
    • User sends
      /myid
      in the bot chat
    • Or check from the Feishu Open Platform backend

已知用户 ID 记录

Known User ID Records

姓名open_id备注
王植萌
ou_18b8063b232cbdec73ea1541dfb74890
zhimeng.wang@qunar.com
Nameopen_idRemarks
Wang Zhimeng
ou_18b8063b232cbdec73ea1541dfb74890
zhimeng.wang@qunar.com

消息类型

Message Types

1. 文本消息

1. Text Message

python
mcp__feishu__im_v1_message_create(
    params={"receive_id_type": "open_id"},
    data={
        "receive_id": "ou_xxx",
        "msg_type": "text",
        "content": '{"text": "Hello World"}'
    }
)
python
mcp__feishu__im_v1_message_create(
    params={"receive_id_type": "open_id"},
    data={
        "receive_id": "ou_xxx",
        "msg_type": "text",
        "content": '{"text": "Hello World"}'
    }
)

2. 富文本消息(Post)

2. Rich Text Message (Post)

支持标题、粗体、链接、@用户等格式。
python
mcp__feishu__im_v1_message_create(
    params={"receive_id_type": "open_id"},
    data={
        "receive_id": "ou_xxx",
        "msg_type": "post",
        "content": json.dumps({
            "zh_cn": {
                "title": "消息标题",
                "content": [
                    [{"tag": "text", "text": "正文内容"}],
                    [{"tag": "text", "text": "粗体", "style": ["bold"]}],
                    [{"tag": "a", "text": "链接", "href": "https://example.com"}]
                ]
            }
        })
    }
)
Supports titles, bold text, links, @mentions, etc.
python
mcp__feishu__im_v1_message_create(
    params={"receive_id_type": "open_id"},
    data={
        "receive_id": "ou_xxx",
        "msg_type": "post",
        "content": json.dumps({
            "zh_cn": {
                "title": "Message Title",
                "content": [
                    [{"tag": "text", "text": "Body Content"}],
                    [{"tag": "text", "text": "Bold Text", "style": ["bold"]}],
                    [{"tag": "a", "text": "Link", "href": "https://example.com"}]
                ]
            }
        })
    }
)

3. 卡片消息(Interactive)

3. Interactive Card Message

最丰富的消息格式,支持分栏、按钮、图片等。
python
mcp__feishu__im_v1_message_create(
    params={"receive_id_type": "open_id"},
    data={
        "receive_id": "ou_xxx",
        "msg_type": "interactive",
        "content": json.dumps({
            "config": {"wide_screen_mode": True},
            "header": {
                "title": {"tag": "plain_text", "content": "卡片标题"},
                "template": "blue"  # blue/green/orange/red/purple
            },
            "elements": [
                {"tag": "markdown", "content": "**支持 Markdown**\n- 列表项1\n- 列表项2"},
                {"tag": "hr"},
                {"tag": "div", "text": {"tag": "lark_md", "content": "分栏内容"}}
            ]
        })
    }
)
The most rich message format, supports columns, buttons, images, etc.
python
mcp__feishu__im_v1_message_create(
    params={"receive_id_type": "open_id"},
    data={
        "receive_id": "ou_xxx",
        "msg_type": "interactive",
        "content": json.dumps({
            "config": {"wide_screen_mode": True},
            "header": {
                "title": {"tag": "plain_text", "content": "Card Title"},
                "template": "blue"  # blue/green/orange/red/purple
            },
            "elements": [
                {"tag": "markdown", "content": "**Supports Markdown**\n- List Item 1\n- List Item 2"},
                {"tag": "hr"},
                {"tag": "div", "text": {"tag": "lark_md", "content": "Column Content"}}
            ]
        })
    }
)

标准操作流程

Standard Operating Procedures

发送消息 SOP

Send Message SOP

1. 确认收件人
   ↓ 有 open_id → 直接发送
   ↓ 无 open_id → 获取 open_id(见上述方法)

2. 确认消息类型
   ↓ 简单文本 → text
   ↓ 需要格式 → post
   ↓ 丰富卡片 → interactive

3. 构造消息内容
   ↓ 根据类型构造 JSON

4. 发送消息
   ↓ 调用 im_v1_message_create

5. 确认送达
   ↓ 检查返回的 message_id
1. Confirm Recipient
   ↓ Has open_id → Send directly
   ↓ No open_id → Obtain open_id (see methods above)

2. Confirm Message Type
   ↓ Simple text → text
   ↓ Needs formatting → post
   ↓ Rich card → interactive

3. Construct Message Content
   ↓ Construct JSON according to type

4. Send Message
   ↓ Call im_v1_message_create

5. Confirm Delivery
   ↓ Check the returned message_id

创建文档 SOP(待权限开通)

Create Document SOP (Pending Permission Activation)

1. 确认文档类型
   ↓ 普通文档 → docx_builtin_import
   ↓ 多维表格 → bitable_v1_app_create
   ↓ 知识库页面 → wiki 相关 API

2. 准备内容
   ↓ Markdown 格式(会自动转换)

3. 创建文档

4. 分享权限(可选)
   ↓ 添加协作者
1. Confirm Document Type
   ↓ Regular Document → docx_builtin_import
   ↓ Feishu Base → bitable_v1_app_create
   ↓ Knowledge Base Page → wiki-related APIs

2. Prepare Content
   ↓ Markdown format (will be converted automatically)

3. Create Document

4. Share Permissions (Optional)
   ↓ Add collaborators

权限申请指南

Permission Application Guide

飞书应用信息

Feishu Application Information

权限申请链接

Permission Application Links

功能权限申请链接
查询用户ID
contact:user.id:readonly
申请
读取群成员
im:chat.members:read
申请
读取消息
im:message
申请
创建文档
docx:document
申请
多维表格
bitable:app
申请
知识库
wiki:wiki
申请
FunctionPermissionApplication Link
Query User ID
contact:user.id:readonly
Apply
Read Group Members
im:chat.members:read
Apply
Read Messages
im:message
Apply
Create Document
docx:document
Apply
Feishu Base
bitable:app
Apply
Knowledge Base
wiki:wiki
Apply

一键申请全部

Apply for All at Once

常见问题

Frequently Asked Questions

Q: 消息发送成功但用户没收到?

Q: Message sent successfully but user didn't receive it?

可能原因
  1. 用户未与机器人建立联系 → 让用户先给机器人发消息
  2. open_id 不正确 → 确认 open_id 来源
  3. 跨租户 → 机器人无法给其他企业用户发消息
Possible Reasons:
  1. User hasn't established contact with the bot → Ask user to send a message to the bot first
  2. Incorrect open_id → Confirm the source of open_id
  3. Cross-tenant → Bot can't send messages to users from other enterprises

Q: 权限申请不了?

Q: Can't apply for permissions?

可能原因
  1. 机器人版本正在审核中 → 等待审核通过
  2. 企业管理员限制 → 联系管理员开通
  3. 权限需要特殊审批 → 走企业内部流程
Possible Reasons:
  1. Bot version is under review → Wait for approval
  2. Enterprise admin restrictions → Contact admin to enable
  3. Permissions require special approval → Follow internal enterprise processes

Q: 如何发送群消息?

Q: How to send group messages?

使用
chat_id
代替
open_id
python
params={"receive_id_type": "chat_id"},
data={"receive_id": "oc_xxx", ...}
Use
chat_id
instead of
open_id
:
python
params={"receive_id_type": "chat_id"},
data={"receive_id": "oc_xxx", ...}

消息模板

Message Templates

能力介绍卡片

Capability Introduction Card

json
{
  "config": {"wide_screen_mode": true},
  "header": {
    "title": {"tag": "plain_text", "content": "🤖 Claude Code 能力介绍"},
    "template": "blue"
  },
  "elements": [
    {"tag": "markdown", "content": "Hi,我是 **Claude Code**,一个 AI 编程助手。"},
    {"tag": "div", "text": {"tag": "lark_md", "content": "**💻 开发支持**\n• 代码编写、调试和重构\n• Bug 排查与修复"}},
    {"tag": "div", "text": {"tag": "lark_md", "content": "**📊 项目管理**\n• 飞书文档/多维表格操作\n• Git 提交、PR 创建"}},
    {"tag": "hr"},
    {"tag": "markdown", "content": "有任何需要,随时召唤我!"}
  ]
}
json
{
  "config": {"wide_screen_mode": true},
  "header": {
    "title": {"tag": "plain_text", "content": "🤖 Claude Code Capability Introduction"},
    "template": "blue"
  },
  "elements": [
    {"tag": "markdown", "content": "Hi, I'm **Claude Code**, an AI programming assistant."},
    {"tag": "div", "text": {"tag": "lark_md", "content": "**💻 Development Support**\n• Code writing, debugging and refactoring\n• Bug troubleshooting and fixing"}},
    {"tag": "div", "text": {"tag": "lark_md", "content": "**📊 Project Management**\n• Feishu document/Base operations\n• Git commits, PR creation"}},
    {"tag": "hr"},
    {"tag": "markdown", "content": "Feel free to call me whenever you need help!"}
  ]
}

任务通知卡片

Task Notification Card

json
{
  "config": {"wide_screen_mode": true},
  "header": {
    "title": {"tag": "plain_text", "content": "📋 任务通知"},
    "template": "green"
  },
  "elements": [
    {"tag": "div", "fields": [
      {"is_short": true, "text": {"tag": "lark_md", "content": "**任务**\n部署上线"}},
      {"is_short": true, "text": {"tag": "lark_md", "content": "**状态**\n✅ 已完成"}}
    ]},
    {"tag": "hr"},
    {"tag": "markdown", "content": "详情请查看 [链接](https://example.com)"}
  ]
}
json
{
  "config": {"wide_screen_mode": true},
  "header": {
    "title": {"tag": "plain_text", "content": "📋 Task Notification"},
    "template": "green"
  },
  "elements": [
    {"tag": "div", "fields": [
      {"is_short": true, "text": {"tag": "lark_md", "content": "**Task**\nDeployment and Launch"}},
      {"is_short": true, "text": {"tag": "lark_md", "content": "**Status**\n✅ Completed"}}
    ]},
    {"tag": "hr"},
    {"tag": "markdown", "content": "For details, please check [Link](https://example.com)"}
  ]
}

注意事项

Notes

  1. 消息频率限制 - 单用户每分钟最多 5 条消息
  2. 内容长度限制 - 卡片消息 body 不超过 30KB
  3. 图片需先上传 - 使用
    im/v1/images
    上传后获取 image_key
  4. 敏感信息 - 不要在消息中包含密码、token 等敏感信息
  1. Message Frequency Limit - Maximum 5 messages per user per minute
  2. Content Length Limit - Card message body cannot exceed 30KB
  3. Images Need to Be Uploaded First - Use
    im/v1/images
    to upload and get image_key
  4. Sensitive Information - Do not include passwords, tokens or other sensitive information in messages

相关资源

Related Resources