feishu-card
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFeishu Interactive Card
飞书交互卡片
Build, send, and handle callbacks for Feishu interactive message cards. Cards replace plain text messages for any communication that benefits from structured layout or user actions (buttons, selects).
构建、发送飞书交互消息卡片并处理其回调。对于任何受益于结构化布局或用户操作(按钮、选择器)的通信场景,卡片可替代纯文本消息。
When to Use
适用场景
- Morning briefings (confirm/adjust/add task buttons)
- Evening reviews (acknowledge/defer buttons)
- Alert notifications (auto-fix/ignore/escalate buttons)
- Skill test results (listen/retest/mark-stable buttons)
- Any yes/no or multi-choice confirmation
- Status updates that need acknowledgment
- 晨间简报(确认/调整/新增任务按钮)
- 晚间复盘(确认/延后按钮)
- 告警通知(自动修复/忽略/升级按钮)
- 技能测试结果(查看/重测/标记为稳定按钮)
- 任何是/否或多选确认场景
- 需要确认接收的状态更新
Sending a Card
发送卡片
API
API
POST /open-apis/im/v1/messages?receive_id_type=chat_idjson
{
"receive_id": "<chat_id>",
"msg_type": "interactive",
"content": "<card_json_string>"
}Critical: The field must be a JSON string (stringified JSON), not a raw object.
contentPOST /open-apis/im/v1/messages?receive_id_type=chat_idjson
{
"receive_id": "<chat_id>",
"msg_type": "interactive",
"content": "<card_json_string>"
}重要提示:字段必须是JSON字符串(序列化后的JSON),不能是原始对象。
contentCard Structure
卡片结构
json
{
"config": { "wide_screen_mode": true },
"header": {
"title": { "tag": "plain_text", "content": "Card Title" },
"template": "blue"
},
"elements": [
{ "tag": "div", "text": { "tag": "lark_md", "content": "**Bold** and `code` supported" } },
{ "tag": "hr" },
{ "tag": "action", "actions": [
{ "tag": "button", "text": { "tag": "plain_text", "content": "Confirm" }, "type": "primary", "value": { "action": "confirm" } },
{ "tag": "button", "text": { "tag": "plain_text", "content": "Adjust" }, "type": "default", "value": { "action": "adjust" } }
]}
]
}json
{
"config": { "wide_screen_mode": true },
"header": {
"title": { "tag": "plain_text", "content": "Card Title" },
"template": "blue"
},
"elements": [
{ "tag": "div", "text": { "tag": "lark_md", "content": "**Bold** and `code` supported" } },
{ "tag": "hr" },
{ "tag": "action", "actions": [
{ "tag": "button", "text": { "tag": "plain_text", "content": "Confirm" }, "type": "primary", "value": { "action": "confirm" } },
{ "tag": "button", "text": { "tag": "plain_text", "content": "Adjust" }, "type": "default", "value": { "action": "adjust" } }
]}
]
}Header Templates (Colors)
头部模板(颜色)
| Template | Color | Use For |
|---|---|---|
| Blue | Normal briefings, info |
| Green | Success, completed |
| Red | Alerts, failures |
| Orange | Warnings, degraded |
| Purple | Special, creative |
| Teal | Skill/tech results |
| Grey | Low priority, FYI |
| 模板 | 颜色 | 适用场景 |
|---|---|---|
| 蓝色 | 常规简报、信息通知 |
| 绿色 | 成功、完成状态 |
| 红色 | 告警、失败 |
| 橙色 | 警告、服务降级 |
| 紫色 | 特殊、创意类内容 |
| 青绿色 | 技能/技术结果 |
| 灰色 | 低优先级、仅供参考 |
Supported Elements
支持的元素
| Element | Tag | Purpose |
|---|---|---|
| Rich text | | Markdown-like content |
| Divider | | Visual separator |
| Action buttons | | Clickable actions |
| Select menu | | Dropdown selection |
| Note/footer | | Small gray footer text |
| Column set | | Multi-column layout |
| Image | | Inline image |
| 元素 | 标签 | 用途 |
|---|---|---|
| 富文本 | | 类Markdown内容 |
| 分割线 | | 视觉分隔符 |
| 操作按钮 | | 可点击操作 |
| 下拉选择菜单 | | 下拉选择 |
| 备注/页脚 | | 灰色小号页脚文本 |
| 多列布局 | | 多栏布局 |
| 图片 | | 行内图片 |
lark_md
Syntax
lark_mdlark_md
语法
lark_mdFeishu's tag supports a subset of Markdown:
lark_md- ,
**bold**,*italic*~~strikethrough~~ [link text](url)- for mentions
<at id=ou_xxx>name</at> - Newlines: use within the string
\n
飞书的标签支持Markdown的子集:
lark_md- 、
**bold**、*italic*~~strikethrough~~ [link text](url)- 用于@用户
<at id=ou_xxx>name</at> - 换行:字符串内使用
\n
Card Templates
卡片模板
Morning Briefing Card
晨间简报卡片
See references/card-morning-briefing.json for the full template.
Structure:
- Header: date + greeting (template: blue)
- Section 1: Anomalies (red text if any, green "No anomalies" if clear)
- Section 2: Today's action queue (numbered list with priority tags)
- Section 3: Action buttons (Confirm / Adjust / Add Task)
- Footer: generation timestamp
完整模板见references/card-morning-briefing.json
结构:
- 头部:日期 + 问候(模板:蓝色)
- 第一部分:异常情况(如有则显示红色文本,无异常则显示绿色的"无异常")
- 第二部分:今日待办队列(带优先级标签的有序列表)
- 第三部分:操作按钮(确认 / 调整 / 新增任务)
- 页脚:生成时间戳
Alert Card
告警卡片
See references/card-alert.json for the full template.
Structure:
- Header: alert type + service name (template: red)
- Body: What happened, impact assessment
- Action buttons (Auto-fix / Ignore / Escalate)
完整模板见references/card-alert.json
结构:
- 头部:告警类型 + 服务名称(模板:红色)
- 正文:事件描述、影响评估
- 操作按钮(自动修复 / 忽略 / 升级上报)
Skill Test Result Card
技能测试结果卡片
See references/card-skill-test.json for the full template.
Structure:
- Header: skill name + pass/fail (template: green/red)
- Body: Test metrics, pass count, details
- Action buttons (Retest / Mark Stable / Archive)
完整模板见references/card-skill-test.json
结构:
- 头部:技能名称 + 通过/失败(模板:绿色/红色)
- 正文:测试指标、通过数量、详情
- 操作按钮(重测 / 标记为稳定 / 归档)
Confirmation Card
确认卡片
Generic yes/no card. Use for any binary decision.
json
{
"header": { "title": { "tag": "plain_text", "content": "Confirmation Required" }, "template": "orange" },
"elements": [
{ "tag": "div", "text": { "tag": "lark_md", "content": "**Question**: Description of what needs confirming" } },
{ "tag": "action", "actions": [
{ "tag": "button", "text": { "tag": "plain_text", "content": "Yes, proceed" }, "type": "primary", "value": { "action": "confirm", "context": "unique_id" } },
{ "tag": "button", "text": { "tag": "plain_text", "content": "No, cancel" }, "type": "danger", "value": { "action": "cancel", "context": "unique_id" } }
]}
]
}通用是/否卡片,适用于所有二元决策场景。
json
{
"header": { "title": { "tag": "plain_text", "content": "Confirmation Required" }, "template": "orange" },
"elements": [
{ "tag": "div", "text": { "tag": "lark_md", "content": "**Question**: Description of what needs confirming" } },
{ "tag": "action", "actions": [
{ "tag": "button", "text": { "tag": "plain_text", "content": "Yes, proceed" }, "type": "primary", "value": { "action": "confirm", "context": "unique_id" } },
{ "tag": "button", "text": { "tag": "plain_text", "content": "No, cancel" }, "type": "danger", "value": { "action": "cancel", "context": "unique_id" } }
]}
]
}Handling Callbacks
处理回调
STATUS (2026-02-10): WebSocket currently does NOT subscribe toevents. Buttons on cards are display-only for now. Use the text fallback approach below until card callback support is added.card.action.trigger
状态(2026-02-10):WebSocket当前暂未订阅事件。目前卡片上的按钮仅用于展示。在卡片回调支持上线前,请使用下方的文本兜底方案。card.action.trigger
Current Approach: Text Fallback
当前方案:文本兜底
Since card button clicks cannot be received yet:
- Include clear text instructions in the card footer: "Reply '确认' to confirm, '调整' to adjust, '加任务' to add"
- User replies with a text message → AI agent receives via (works today)
im.message.receive_v1 - Parse the text reply to determine the action
由于目前暂无法接收卡片按钮点击事件:
- 在卡片页脚添加清晰的文本指引:"回复'确认'进行确认,回复'调整'进行调整,回复'加任务'新增任务"
- 用户回复文本消息 → AI agent通过事件接收(当前已支持)
im.message.receive_v1 - 解析文本回复判断对应的操作
Future: Full Card Callbacks (when card.action.trigger
is supported)
card.action.trigger未来方案:完整卡片回调(待card.action.trigger
事件支持后启用)
card.action.triggerWhen user clicks a button on a card, Feishu sends a callback event via WebSocket.
The callback arrives as a event containing:
card.action.trigger- : The
action.valueobject from the button definitionvalue - : Who clicked
operator.open_id - : For response verification
token
Callback processing:
- Parse to determine what was clicked
action.value - Execute the corresponding action (e.g., mark today-actions as confirmed)
- Update the original card to reflect the new state (e.g., change button to "Confirmed" checkmark)
- Optionally send a brief follow-up message
Use the API to update the card content after a button click.
PATCH /open-apis/im/v1/messages/:message_id当用户点击卡片上的按钮时,飞书会通过WebSocket发送回调事件。
回调为事件,包含:
card.action.trigger- :按钮定义中的
action.value对象value - :点击用户的ID
operator.open_id - :用于响应校验
token
回调处理流程:
- 解析判断点击的按钮对应的操作
action.value - 执行对应操作(例如将今日待办标记为已确认)
- 更新原始卡片以反映新状态(例如将按钮改为带对勾的"已确认")
- 可选择发送简短的后续消息
使用 API在按钮点击后更新卡片内容。
PATCH /open-apis/im/v1/messages/:message_idBest Practices
最佳实践
- One primary action: Each card should have one obvious primary button (type: ) and secondary options
primary - Value context: Always include enough context in button to reconstruct what the button is about (e.g., date, task_id)
value - Concise content: Cards are for quick scanning. Keep text short. Use formatting for emphasis.
lark_md - No walls of text: If content is long, summarize in card and link to a Feishu doc for details
- Template colors: Match the header color to the sentiment (red=alert, green=success, blue=info)
- 单个主操作:每张卡片应设置1个明确的主按钮(类型:)和其他次选项
primary - 值上下文:始终在按钮的中包含足够的上下文信息,以便明确按钮对应的操作对象(例如日期、任务ID)
value - 内容简洁:卡片用于快速浏览,文本尽量简短,使用格式突出重点
lark_md - 避免大段文本:如果内容较长,在卡片中做摘要,链接到飞书文档查看详情
- 模板颜色匹配:头部颜色需匹配消息属性(红色=告警,绿色=成功,蓝色=信息)
Dependencies
依赖
- Feishu IM API (POST messages with )
msg_type: interactive - WebSocket connection (receives events)
card.action.trigger - See API #4 for interactive card details
FEISHU_API_HANDBOOK.md
- 飞书IM API(发送类型的消息)
msg_type: interactive - WebSocket连接(接收事件)
card.action.trigger - 详见API #4 了解交互卡片的详细说明
FEISHU_API_HANDBOOK.md
Integration Points
集成点
- skill: Sends briefing as card instead of plain text
daily-briefing - skill: Evening review uses card format
ops-rhythm - skill: Alerts sent as red cards
n8n-ops - skill: Test results sent as cards
skill-lab - skill: Triggers sync after card confirmation
feishu-sync
- skill:以卡片而非纯文本形式发送简报
daily-briefing - skill:晚间复盘使用卡片格式
ops-rhythm - skill:告警以红色卡片形式发送
n8n-ops - skill:测试结果以卡片形式发送
skill-lab - skill:卡片确认后触发同步操作
feishu-sync