feishu-cli-msg
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese飞书消息发送技能
Feishu Message Sending Skill
通过 feishu-cli 发送飞书消息,支持多种消息类型和丰富的消息管理操作。
Send Feishu messages via feishu-cli, supporting multiple message types and rich message management operations.
核心概念
Core Concepts
消息架构
Message Architecture
飞书消息 API 的 字段是一个 JSON 字符串(不是 JSON 对象)。CLI 提供三种输入方式:
content| 输入方式 | 参数 | 适用场景 |
|---|---|---|
| 快捷文本 | | 纯文本消息,最简单 |
| 内联 JSON | | 简单 JSON,一行搞定 |
| JSON 文件 | | 复杂消息(卡片、富文本等) |
优先级: > > (同时指定时前者优先)
--text--content--content-fileThe field of Feishu Message API is a JSON string (not a JSON object). The CLI provides three input methods:
content| Input Method | Parameter | Applicable Scenario |
|---|---|---|
| Quick Text | | Plain text messages, the simplest option |
| Inline JSON | | Simple JSON, can be done in one line |
| JSON File | | Complex messages (cards, rich text, etc.) |
Priority: > > (the former takes precedence when specified simultaneously)
--text--content--content-file接收者类型
Recipient Types
| --receive-id-type | 说明 | 示例 |
|---|---|---|
| 邮箱地址 | user@example.com | |
| open_id | Open ID | ou_xxx |
| user_id | User ID | xxx |
| union_id | Union ID | on_xxx |
| chat_id | 群聊 ID | oc_xxx |
| --receive-id-type | Description | Example |
|---|---|---|
| Email address | user@example.com | |
| open_id | Open ID | ou_xxx |
| user_id | User ID | xxx |
| union_id | Union ID | on_xxx |
| chat_id | Group Chat ID | oc_xxx |
消息类型选择
Message Type Selection
决策树(Claude 未指定类型时自动选择)
Decision Tree (Automatically selected when Claude doesn't specify type)
默认优先使用 (卡片消息),样式美观、内容丰富、支持颜色/多列/按钮等。
interactive用户需求
├─ 【默认】通知/报告/告警/任何有信息量的消息 → interactive(卡片)
├─ 发送已上传的图片/文件/音视频 → image/file/audio/media
├─ 分享群聊或用户名片 → share_chat/share_user
├─ 会话分割线(仅 p2p) → system
└─ 仅以下场景才用 text/post:
├─ 用户明确要求发纯文本 → text
└─ 用户明确要求发富文本 → post为什么优先卡片:text 不支持任何格式渲染,post 样式有限,卡片支持彩色 header、多列 fields、按钮、分割线、备注等,视觉效果远优于其他类型。
Default priority is (card message) with beautiful styling, rich content, and support for colors/multi-columns/buttons, etc.
interactiveUser Requirement
├─ [Default] Notification/Report/Alert/Any informative message → interactive (card)
├─ Send uploaded image/file/audio/video → image/file/audio/media
├─ Share group chat or user business card → share_chat/share_user
├─ Conversation divider (p2p only) → system
└─ Use text/post only in the following scenarios:
├─ User explicitly requests plain text → text
└─ User explicitly requests rich text → postWhy prioritize cards: text does not support any format rendering, post has limited styling, while cards support colored headers, multi-column fields, buttons, dividers, notes, etc., with visual effects far superior to other types.
消息类型一览
Overview of Message Types
| 类型 | 说明 | content 格式 | 大小限制 |
|---|---|---|---|
| text | 纯文本 | | 150 KB |
| post | 富文本 | | 150 KB |
| image | 图片 | | — |
| file | 文件 | | — |
| audio | 语音 | | — |
| media | 视频 | | — |
| sticker | 表情包 | | 仅转发 |
| interactive | 卡片 | Card JSON / template_id / card_id | 30 KB |
| share_chat | 群名片 | | — |
| share_user | 个人名片 | | — |
| system | 系统分割线 | | 仅 p2p |
| Type | Description | content Format | Size Limit |
|---|---|---|---|
| text | Plain text | | 150 KB |
| post | Rich text | | 150 KB |
| image | Image | | — |
| file | File | | — |
| audio | Voice | | — |
| media | Video | | — |
| sticker | Sticker | | Forward only |
| interactive | Card | Card JSON / template_id / card_id | 30 KB |
| share_chat | Group Chat Card | | — |
| share_user | User Business Card | | — |
| system | System Divider | | P2P only |
发送命令
Sending Commands
基础格式
Basic Format
bash
feishu-cli msg send \
--receive-id-type <type> \
--receive-id <id> \
[--msg-type <msg_type>] \
[--text "<text>" | --content '<json>' | --content-file <file.json>]bash
feishu-cli msg send \
--receive-id-type <type> \
--receive-id <id> \
[--msg-type <msg_type>] \
[--text "<text>" | --content '<json>' | --content-file <file.json>]text 类型
text Type
bash
undefinedbash
undefined最简形式(默认 msg-type 为 text)
Simplest form (default msg-type is text)
feishu-cli msg send
--receive-id-type email
--receive-id user@example.com
--text "你好,这是一条测试消息"
--receive-id-type email
--receive-id user@example.com
--text "你好,这是一条测试消息"
text 类型支持的内联语法:
- `@` 用户:`<at user_id="ou_xxx">Tom</at>`
- `@` 所有人:`<at user_id="all"></at>`
**注意**:text 类型**不支持**富文本样式(加粗、斜体、下划线、删除线、超链接等均不会渲染)。如需格式排版,请使用 `post` 类型。feishu-cli msg send
--receive-id-type email
--receive-id user@example.com
--text "Hello, this is a test message"
--receive-id-type email
--receive-id user@example.com
--text "Hello, this is a test message"
Inline syntax supported by text type:
- `@` user: `<at user_id="ou_xxx">Tom</at>`
- `@` all users: `<at user_id="all"></at>`
**Note**: text type **does not support** rich text styles (bold, italic, underline, strikethrough, hyperlinks, etc. will not be rendered). For formatted layout, use the `post` type.post 类型(富文本)
post Type (Rich Text)
推荐使用 标签承载 Markdown,一个 标签独占一个段落:
mdmdbash
cat > /tmp/msg.json << 'EOF'
{
"zh_cn": {
"title": "项目进展通知",
"content": [
[{"tag": "md", "text": "**本周进展**\n- 完成功能 A 开发\n- 修复 3 个 Bug\n- [查看详情](https://example.com)"}],
[{"tag": "md", "text": "**下周计划**\n1. 功能 B 开发\n2. 性能优化"}]
]
}
}
EOF
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type post \
--content-file /tmp/msg.jsonpost 支持的 tag 类型:
| tag | 说明 | 主要属性 |
|---|---|---|
| text | 文本 | text, style(bold/italic/underline/lineThrough) |
| a | 超链接 | text, href |
| at | @用户 | user_id, user_name |
| img | 图片 | image_key, width, height |
| media | 视频 | file_key, image_key |
| emotion | 表情 | emoji_type |
| hr | 分割线 | — |
| code_block | 代码块 | language, text |
| md | Markdown | text(独占段落,推荐使用) |
It is recommended to use the tag to carry Markdown, with one tag occupying one paragraph:
mdmdbash
cat > /tmp/msg.json << 'EOF'
{
"zh_cn": {
"title": "Project Progress Notification",
"content": [
[{"tag": "md", "text": "**This Week's Progress**\n- Completed Feature A development\n- Fixed 3 Bugs\n- [View Details](https://example.com)"}],
[{"tag": "md", "text": "**Next Week's Plan**\n1. Feature B development\n2. Performance optimization"}]
]
}
}
EOF
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type post \
--content-file /tmp/msg.jsonTag types supported by post:
| tag | Description | Main Attributes |
|---|---|---|
| text | Text | text, style (bold/italic/underline/lineThrough) |
| a | Hyperlink | text, href |
| at | @user | user_id, user_name |
| img | Image | image_key, width, height |
| media | Video | file_key, image_key |
| emotion | Emoji | emoji_type |
| hr | Divider | — |
| code_block | Code Block | language, text |
| md | Markdown | text (occupies a single paragraph, recommended) |
interactive 类型(卡片消息)
interactive Type (Card Message)
卡片消息有三种发送方式:
方式一:完整 Card JSON(推荐,最灵活)
bash
cat > /tmp/card.json << 'EOF'
{
"header": {
"template": "blue",
"title": {"tag": "plain_text", "content": "任务完成通知"}
},
"elements": [
{"tag": "markdown", "content": "**项目**: feishu-cli\n**状态**: 已完成\n**负责人**: <at id=all></at>"},
{"tag": "hr"},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "由 CI/CD 自动发送"}]}
]
}
EOF
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type interactive \
--content-file /tmp/card.json方式二:template_id
bash
cat > /tmp/card.json << 'EOF'
{
"type": "template",
"data": {
"template_id": "AAqk1xxxxxx",
"template_variable": {"name": "张三", "status": "已完成"}
}
}
EOF
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type interactive \
--content-file /tmp/card.json方式三:card_id
bash
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type interactive \
--content '{"type":"card","data":{"card_id":"7371713483664506900"}}'There are three ways to send card messages:
Method 1: Complete Card JSON (Recommended, most flexible)
bash
cat > /tmp/card.json << 'EOF'
{
"header": {
"template": "blue",
"title": {"tag": "plain_text", "content": "Task Completion Notification"}
},
"elements": [
{"tag": "markdown", "content": "**Project**: feishu-cli\n**Status**: Completed\n**Responsible Person**: <at id=all></at>"},
{"tag": "hr"},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "Automatically sent by CI/CD"}]}
]
}
EOF
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type interactive \
--content-file /tmp/card.jsonMethod 2: template_id
bash
cat > /tmp/card.json << 'EOF'
{
"type": "template",
"data": {
"template_id": "AAqk1xxxxxx",
"template_variable": {"name": "Zhang San", "status": "Completed"}
}
}
EOF
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type interactive \
--content-file /tmp/card.jsonMethod 3: card_id
bash
feishu-cli msg send \
--receive-id-type email \
--receive-id user@example.com \
--msg-type interactive \
--content '{"type":"card","data":{"card_id":"7371713483664506900"}}'Card JSON 结构(v1 vs v2)
Card JSON Structure (v1 vs v2)
v1 格式(推荐,兼容性好):
json
{
"header": {"template": "blue", "title": {"tag": "plain_text", "content": "标题"}},
"elements": [...]
}v2 格式(更多组件):
json
{
"schema": "2.0",
"header": {"template": "blue", "title": {"tag": "plain_text", "content": "标题"}},
"body": {"direction": "vertical", "elements": [...]}
}v2 额外支持:table(表格)、chart(图表)、form_container(表单)、column_set(多列布局)等高级组件。对于简单通知,v1 足够;需要复杂布局时用 v2。
v1 Format (Recommended, good compatibility):
json
{
"header": {"template": "blue", "title": {"tag": "plain_text", "content": "Title"}},
"elements": [...]
}v2 Format (More components):
json
{
"schema": "2.0",
"header": {"template": "blue", "title": {"tag": "plain_text", "content": "Title"}},
"body": {"direction": "vertical", "elements": [...]}
}v2 additionally supports advanced components such as table, chart, form_container, column_set (multi-column layout), etc. For simple notifications, v1 is sufficient; use v2 when complex layouts are needed.
header 颜色模板
Header Color Templates
| 颜色值 | 色系 | 推荐场景 |
|---|---|---|
| blue | 蓝色 | 通用通知、信息 |
| wathet | 浅蓝 | 轻量提示 |
| turquoise | 青色 | 进行中状态 |
| green | 绿色 | 成功、完成 |
| yellow | 黄色 | 注意、提醒 |
| orange | 橙色 | 警告 |
| red | 红色 | 错误、紧急 |
| carmine | 深红 | 严重告警 |
| violet | 紫罗兰 | 特殊标记 |
| purple | 紫色 | 自定义分类 |
| indigo | 靛蓝 | 深色主题 |
| grey | 灰色 | 已处理、归档 |
语义化推荐:绿=成功 / 蓝=通知 / 橙=警告 / 红=错误 / 灰=已处理
| Color Value | Color System | Recommended Scenario |
|---|---|---|
| blue | Blue | General notifications, information |
| wathet | Light Blue | Lightweight prompts |
| turquoise | Cyan | In-progress status |
| green | Green | Success, completion |
| yellow | Yellow | Notes, reminders |
| orange | Orange | Warnings |
| red | Red | Errors, emergencies |
| carmine | Deep Red | Severe alerts |
| violet | Violet | Special markers |
| purple | Purple | Custom categories |
| indigo | Indigo | Dark theme |
| grey | Grey | Processed, archived |
Semantic Recommendations: Green = Success / Blue = Notification / Orange = Warning / Red = Error / Grey = Processed
常用组件速查
Quick Reference for Common Components
内容组件:
| 组件 | tag | 说明 |
|---|---|---|
| Markdown | | 支持 lark_md 语法,最常用 |
| 分割线 | | 水平分割线 |
| 备注 | | 底部灰色小字备注 |
| 图片 | | 图片展示 |
布局组件:
| 组件 | tag | 说明 |
|---|---|---|
| 文本+附加 | | 文本块,可含 fields(多列)和 extra(右侧附加) |
| 多列布局 | | 横向分栏布局 |
交互组件:
| 组件 | tag | 说明 |
|---|---|---|
| 按钮 | | default/primary/danger 三种类型 |
| 下拉选择 | | 静态下拉菜单 |
| 日期选择 | | 日期选择器 |
| 折叠菜单 | | 更多操作菜单 |
Content Components:
| Component | tag | Description |
|---|---|---|
| Markdown | | Supports lark_md syntax, most commonly used |
| Divider | | Horizontal divider |
| Note | | Bottom gray small text note |
| Image | | Image display |
Layout Components:
| Component | tag | Description |
|---|---|---|
| Text + Attachment | | Text block, can contain fields (multi-column) and extra (right attachment) |
| Multi-column Layout | | Horizontal column layout |
Interactive Components:
| Component | tag | Description |
|---|---|---|
| Button | | Three types: default/primary/danger |
| Dropdown Selection | | Static dropdown menu |
| Date Picker | | Date picker |
| Collapsible Menu | | More operations menu |
卡片 Markdown 语法(lark_md)
Card Markdown Syntax (lark_md)
卡片内 组件使用 语法,与标准 Markdown 有差异:
markdownlark_mdmarkdown
undefinedThe component in cards uses syntax, which differs from standard Markdown:
markdownlark_mdmarkdown
undefined支持的语法
Supported Syntax
加粗 斜体 删除线 链接

行内代码bold italic strikethrough link

inline code特有语法
Unique Syntax
<font color='green'>绿色文字</font>
<font color='red'>红色文字</font>
<font color='grey'>灰色文字</font>
<at id=ou_xxx></at>
<at id=all></at>
**注意**:lark_md 的 `<font color>` 仅支持 green/red/grey 三种颜色。<font color='green'>Green text</font>
<font color='red'>Red text</font>
<font color='grey'>Grey text</font>
<at id=ou_xxx></at>
<at id=all></at>
**Note**: `<font color>` in lark_md only supports three colors: green/red/grey.常用卡片模板
Common Card Templates
模板 1:简单通知卡片
Template 1: Simple Notification Card
json
{
"header": {
"template": "blue",
"title": {"tag": "plain_text", "content": "通知标题"}
},
"elements": [
{"tag": "markdown", "content": "通知内容,支持 **加粗** 和 [链接](https://example.com)"},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "来自自动化工具"}]}
]
}json
{
"header": {
"template": "blue",
"title": {"tag": "plain_text", "content": "Notification Title"}
},
"elements": [
{"tag": "markdown", "content": "Notification content, supports **bold** and [links](https://example.com)"},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "From automation tool"}]}
]
}模板 2:告警卡片(多列 + 按钮)
Template 2: Alert Card (Multi-column + Buttons)
json
{
"header": {
"template": "red",
"title": {"tag": "plain_text", "content": "告警通知"}
},
"elements": [
{
"tag": "div",
"fields": [
{"is_short": true, "text": {"tag": "lark_md", "content": "**服务**\napi-gateway"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**级别**\n<font color='red'>P0</font>"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**时间**\n2024-01-01 10:00"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**影响**\n<font color='red'>用户无法登录</font>"}}
]
},
{"tag": "hr"},
{
"tag": "action",
"actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "查看详情"}, "type": "primary", "url": "https://example.com/alert/123"},
{"tag": "button", "text": {"tag": "plain_text", "content": "忽略"}, "type": "default"}
]
}
]
}json
{
"header": {
"template": "red",
"title": {"tag": "plain_text", "content": "Alert Notification"}
},
"elements": [
{
"tag": "div",
"fields": [
{"is_short": true, "text": {"tag": "lark_md", "content": "**Service**\napi-gateway"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**Level**\n<font color='red'>P0</font>"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**Time**\n2024-01-01 10:00"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**Impact**\n<font color='red'>Users cannot log in</font>"}}
]
},
{"tag": "hr"},
{
"tag": "action",
"actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "View Details"}, "type": "primary", "url": "https://example.com/alert/123"},
{"tag": "button", "text": {"tag": "plain_text", "content": "Ignore"}, "type": "default"}
]
}
]
}模板 3:进度报告卡片
Template 3: Progress Report Card
json
{
"header": {
"template": "green",
"title": {"tag": "plain_text", "content": "构建报告"}
},
"elements": [
{"tag": "markdown", "content": "**项目**: feishu-cli\n**分支**: main\n**提交**: abc1234"},
{"tag": "hr"},
{"tag": "markdown", "content": "<font color='green'>Tests: 42/42 passed</font>\n<font color='green'>Build: Success</font>\n<font color='grey'>Duration: 3m 25s</font>"},
{"tag": "hr"},
{
"tag": "action",
"actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "查看日志"}, "type": "default", "url": "https://ci.example.com/build/123"}
]
},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "CI/CD Pipeline #123"}]}
]
}json
{
"header": {
"template": "green",
"title": {"tag": "plain_text", "content": "Build Report"}
},
"elements": [
{"tag": "markdown", "content": "**Project**: feishu-cli\n**Branch**: main\n**Commit**: abc1234"},
{"tag": "hr"},
{"tag": "markdown", "content": "<font color='green'>Tests: 42/42 passed</font>\n<font color='green'>Build: Success</font>\n<font color='grey'>Duration: 3m 25s</font>"},
{"tag": "hr"},
{
"tag": "action",
"actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "View Logs"}, "type": "default", "url": "https://ci.example.com/build/123"}
]
},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "CI/CD Pipeline #123"}]}
]
}模板 4:文档操作通知
Template 4: Document Operation Notification
json
{
"header": {
"template": "turquoise",
"title": {"tag": "plain_text", "content": "文档操作通知"}
},
"elements": [
{
"tag": "div",
"fields": [
{"is_short": true, "text": {"tag": "lark_md", "content": "**操作类型**\n创建文档"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**状态**\n<font color='green'>成功</font>"}}
]
},
{"tag": "markdown", "content": "**文档标题**: 周报 2024-W01\n**文档链接**: [点击查看](https://xxx.feishu.cn/docx/abc123)"},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "由 feishu-cli 自动创建"}]}
]
}json
{
"header": {
"template": "turquoise",
"title": {"tag": "plain_text", "content": "Document Operation Notification"}
},
"elements": [
{
"tag": "div",
"fields": [
{"is_short": true, "text": {"tag": "lark_md", "content": "**Operation Type**\nCreate Document"}},
{"is_short": true, "text": {"tag": "lark_md", "content": "**Status**\n<font color='green'>Success</font>"}}
]
},
{"tag": "markdown", "content": "**Document Title**: Weekly Report 2024-W01\n**Document Link**: [Click to View](https://xxx.feishu.cn/docx/abc123)"},
{"tag": "note", "elements": [{"tag": "plain_text", "content": "Automatically created by feishu-cli"}]}
]
}模板 5:审批确认卡片(多按钮)
Template 5: Approval Confirmation Card (Multiple Buttons)
json
{
"header": {
"template": "orange",
"title": {"tag": "plain_text", "content": "审批请求"}
},
"elements": [
{"tag": "markdown", "content": "**申请人**: 张三\n**申请类型**: 服务器扩容\n**说明**: 线上流量增长,需要增加 2 台服务器"},
{"tag": "hr"},
{
"tag": "action",
"actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "批准"}, "type": "primary"},
{"tag": "button", "text": {"tag": "plain_text", "content": "拒绝"}, "type": "danger"},
{"tag": "button", "text": {"tag": "plain_text", "content": "查看详情"}, "type": "default", "url": "https://example.com/approval/456"}
]
}
]
}json
{
"header": {
"template": "orange",
"title": {"tag": "plain_text", "content": "Approval Request"}
},
"elements": [
{"tag": "markdown", "content": "**Applicant**: Zhang San\n**Application Type**: Server Expansion\n**Description**: Online traffic has increased, need to add 2 servers"},
{"tag": "hr"},
{
"tag": "action",
"actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "Approve"}, "type": "primary"},
{"tag": "button", "text": {"tag": "plain_text", "content": "Reject"}, "type": "danger"},
{"tag": "button", "text": {"tag": "plain_text", "content": "View Details"}, "type": "default", "url": "https://example.com/approval/456"}
]
}
]
}回复消息
Reply to Messages
回复指定消息,支持与 相同的消息类型和输入方式。
msg sendbash
undefinedReply to specified messages, supporting the same message types and input methods as .
msg sendbash
undefined文本回复
Text reply
feishu-cli msg reply <message_id> --text "收到,我来处理"
feishu-cli msg reply <message_id> --text "Received, I will handle it"
卡片回复
Card reply
feishu-cli msg reply <message_id> --msg-type interactive --content-file /tmp/card.json
feishu-cli msg reply <message_id> --msg-type interactive --content-file /tmp/card.json
富文本回复
Rich text reply
feishu-cli msg reply <message_id> --msg-type post --content-file /tmp/post.json
| 参数 | 说明 | 默认值 |
|------|------|--------|
| `--msg-type` | 消息类型 | `text` |
| `--text` / `--content` / `--content-file` | 消息内容(三选一) | 必填 |feishu-cli msg reply <message_id> --msg-type post --content-file /tmp/post.json
| Parameter | Description | Default Value |
|------|------|--------|
| `--msg-type` | Message type | `text` |
| `--text` / `--content` / `--content-file` | Message content (choose one of three) | Required |合并转发
Merge Forward
将多条消息合并转发给指定接收者。
bash
feishu-cli msg merge-forward \
--receive-id user@example.com \
--receive-id-type email \
--message-ids om_xxx,om_yyy,om_zzz| 参数 | 说明 | 默认值 |
|---|---|---|
| 接收者 ID | 必填 |
| 接收者类型 | |
| 消息 ID 列表(逗号分隔) | 必填 |
Merge and forward multiple messages to the specified recipient.
bash
feishu-cli msg merge-forward \
--receive-id user@example.com \
--receive-id-type email \
--message-ids om_xxx,om_yyy,om_zzz| Parameter | Description | Default Value |
|---|---|---|
| Recipient ID | Required |
| Recipient type | |
| List of message IDs (comma-separated) | Required |
Reaction 表情回应
Reaction Emoji Response
给消息添加/删除/查询表情回应。
bash
undefinedAdd/remove/query emoji reactions for messages.
bash
undefined添加表情
Add emoji
feishu-cli msg reaction add <message_id> --emoji-type THUMBSUP
feishu-cli msg reaction add <message_id> --emoji-type THUMBSUP
删除表情
Remove emoji
feishu-cli msg reaction remove <message_id> --reaction-id <REACTION_ID>
feishu-cli msg reaction remove <message_id> --reaction-id <REACTION_ID>
查询表情列表
Query emoji list
feishu-cli msg reaction list <message_id> [--emoji-type THUMBSUP] [--page-size 20]
常用 emoji-type:`THUMBSUP`(点赞)、`SMILE`(微笑)、`LAUGH`(大笑)、`HEART`(爱心)、`JIAYI`(加一)、`OK`、`FIRE`feishu-cli msg reaction list <message_id> [--emoji-type THUMBSUP] [--page-size 20]
Common emoji-type values: `THUMBSUP` (Like), `SMILE` (Smile), `LAUGH` (Laugh), `HEART` (Love), `JIAYI` (Plus One), `OK`, `FIRE`Pin 置顶消息
Pin Messages
bash
undefinedbash
undefined置顶消息
Pin message
feishu-cli msg pin <message_id>
feishu-cli msg pin <message_id>
取消置顶
Unpin message
feishu-cli msg unpin <message_id>
feishu-cli msg unpin <message_id>
获取群内置顶消息列表
Get list of pinned messages in group
feishu-cli msg pins --chat-id <chat_id> [--start-time <ms_timestamp>] [--end-time <ms_timestamp>]
`--start-time` 和 `--end-time` 使用**毫秒级**时间戳。feishu-cli msg pins --chat-id <chat_id> [--start-time <ms_timestamp>] [--end-time <ms_timestamp>]
`--start-time` and `--end-time` use **millisecond-level** timestamps.其他消息命令
Other Message Commands
获取消息详情
Get Message Details
bash
feishu-cli msg get <message_id>
feishu-cli msg get om_xxx --output jsonbash
feishu-cli msg get <message_id>
feishu-cli msg get om_xxx --output json转发消息
Forward Message
bash
feishu-cli msg forward <message_id> \
--receive-id user@example.com \
--receive-id-type emailbash
feishu-cli msg forward <message_id> \
--receive-id user@example.com \
--receive-id-type email删除消息
Delete Message
仅能删除机器人自己发送的消息,不可恢复。
bash
feishu-cli msg delete <message_id>Only messages sent by the bot itself can be deleted, and deletion is irreversible.
bash
feishu-cli msg delete <message_id>获取消息列表
Get Message List
bash
feishu-cli msg list \
--container-id oc_xxx \
--container-id-type chat \
--page-size 20 \
--sort-type ByCreateTimeDesc支持参数:、(秒级时间戳)、。
--start-time--end-time--page-tokenbash
feishu-cli msg list \
--container-id oc_xxx \
--container-id-type chat \
--page-size 20 \
--sort-type ByCreateTimeDescSupported parameters: , (second-level timestamp), .
--start-time--end-time--page-token获取会话历史
Get Conversation History
bash
feishu-cli msg history \
--container-id oc_xxx \
--container-id-type chat \
--sort-type ByCreateTimeAsc \
--page-size 50bash
feishu-cli msg history \
--container-id oc_xxx \
--container-id-type chat \
--sort-type ByCreateTimeAsc \
--page-size 50查询消息已读用户
Query Message Read Users
bash
feishu-cli msg read-users <message_id>
feishu-cli msg read-users om_xxx --user-id-type user_id --page-size 50bash
feishu-cli msg read-users <message_id>
feishu-cli msg read-users om_xxx --user-id-type user_id --page-size 50搜索群聊
Search Group Chats
bash
feishu-cli msg search-chats --query "项目群"
feishu-cli msg search-chats --page-size 20bash
feishu-cli msg search-chats --query "Project Group"
feishu-cli msg search-chats --page-size 20搜索消息(需 User Access Token)
Search Messages (Requires User Access Token)
bash
feishu-cli search messages "关键词" \
--user-access-token u-xxx \
--chat-ids oc_xxx \
--message-type file \
--start-time 1704067200bash
feishu-cli search messages "keyword" \
--user-access-token u-xxx \
--chat-ids oc_xxx \
--message-type file \
--start-time 1704067200执行流程
Execution Process
Claude 发送消息时按以下流程操作:
- 确定接收者:默认 (email),或从上下文获取
user@example.com - 选择消息类型:
- 用户明确指定类型 → 使用指定类型
- 默认使用 (卡片消息) → 根据内容语义选择 header 颜色和合适的组件布局
interactive - 仅在用户明确要求纯文本/富文本时 → 使用 /
textpost
- 构造卡片内容:
- 根据消息语义选择 header 颜色(绿=成功、红=错误、橙=警告、蓝=通知、灰=归档)
- 使用 组件承载主要内容
markdown - 有多个键值对时使用 +
div多列布局fields - 需要操作链接时添加 +
actionbutton - 底部添加 备注来源
note - 将 JSON 写入临时文件后用 发送
--content-file
- 发送并检查结果:执行命令,确认返回 message_id
When Claude sends messages, follow these steps:
- Determine Recipient: Default is (email), or obtained from context
user@example.com - Select Message Type:
- If user explicitly specifies type → use the specified type
- Default to (card message) → select header color and appropriate component layout based on content semantics
interactive - Use /
textonly when user explicitly requests plain text/rich textpost
- Construct Card Content:
- Select header color based on message semantics (Green=Success, Red=Error, Orange=Warning, Blue=Notification, Grey=Archived)
- Use component to carry main content
markdown - Use +
divmulti-column layout when there are multiple key-value pairsfields - Add +
actionwhen operation links are neededbutton - Add at the bottom to indicate the source
note - Write the JSON to a temporary file and send it using
--content-file
- Send and Check Result: Execute the command and confirm the returned message_id
权限要求
Permission Requirements
| 权限 | 说明 |
|---|---|
| 消息读写 |
| 以机器人身份发送消息 |
| 搜索群聊 |
| 获取历史消息 |
| Permission | Description |
|---|---|
| Message read/write |
| Send messages as bot |
| Search group chats |
| Get historical messages |
注意事项
Notes
| 限制 | 说明 |
|---|---|
| text 大小限制 | 单条最大 150 KB |
| 卡片/富文本大小限制 | 单条最大 30 KB |
| system 消息 | 仅 p2p 会话有效,群聊无效 |
| sticker 消息 | 仅支持转发收到的表情包,不支持自行上传 |
| 卡片按钮回调 | 按钮的交互回调需应用服务端支持,CLI 发送的按钮仅 url 跳转有效 |
| API 频率限制 | 请求过快返回 429,等待几秒后重试 |
| 删除消息 | 仅能删除机器人发送的消息 |
| Limit | Description |
|---|---|
| text size limit | Maximum 150 KB per message |
| card/rich text size limit | Maximum 30 KB per message |
| system message | Only valid in p2p conversations, invalid in group chats |
| sticker message | Only supports forwarding received stickers, does not support uploading custom stickers |
| card button callback | The interaction callback of buttons requires application server support; buttons sent via CLI only support url redirection |
| API rate limit | Returns 429 if requests are too frequent, retry after a few seconds |
| Delete message | Only messages sent by the bot can be deleted |
错误处理
Error Handling
| 错误 | 原因 | 解决 |
|---|---|---|
| post 类型 JSON 格式错误 | 确保格式为 |
| 接收者 ID 无效 | 检查 --receive-id-type 和 --receive-id 是否匹配 |
| 机器人无权限 | 确认应用有 |
| API 限流 | 等待几秒后重试 |
| 用户不存在 | 检查邮箱或 ID 是否正确 |
| 卡片 JSON 超过 30 KB | 精简卡片内容或拆分为多条消息 |
| Error | Cause | Solution |
|---|---|---|
| Incorrect JSON format for post type | Ensure the format is |
| Invalid recipient ID | Check if --receive-id-type and --receive-id match |
| Bot has no permission | Confirm the application has the |
| API rate limit exceeded | Retry after a few seconds |
| User does not exist | Check if the email or ID is correct |
| Card JSON exceeds 30 KB | Simplify card content or split into multiple messages |
参考文档
Reference Documents
- :各消息类型的 content JSON 结构详解
references/message_content.md - :卡片消息完整构造指南(组件、布局、模板)
references/card_schema.md
- : Detailed explanation of content JSON structure for each message type
references/message_content.md - : Complete guide to constructing card messages (components, layout, templates)
references/card_schema.md