🧪 Skills
Feishu Card JSON v2
发送飞书互动卡片(Card JSON 2.0)。当需要让飞书用户填写表单、做选择、确认操作、或查看 结构化数据时,发送交互卡片代替纯文字问答。需要安装 fe
v0.1.0
Description
name: feishu-card description: > 发送飞书互动卡片(Card JSON 2.0)。当需要让飞书用户填写表单、做选择、确认操作、或查看 结构化数据时,发送交互卡片代替纯文字问答。需要安装 feishu-cards 插件(注册工具: feishu_send_card / feishu_send_form / feishu_update_card)。 metadata: { "openclaw": { "requires": { "tools": ["feishu_send_card", "feishu_send_form", "feishu_update_card"] }, "install": [ { "id": "npm", "kind": "plugin", "package": "@openclaw/feishu-cards", "label": "Install feishu-cards plugin (npm)" } ] } }
feishu-card Skill
使用 feishu_send_form 和 feishu_send_card 工具向飞书用户发送互动卡片,替代低效的一问一答对话模式。
何时触发
| 场景 | 用卡片 ✅ | 用文字 ❌ |
|---|---|---|
| 需要用户填写多个字段 | ✅ | ❌ |
| 需要用户做单选/多选 | ✅ | ❌ |
| 确认危险/重要操作 | ✅ | ❌ |
| 展示 ≥3 行结构化数据 | ✅ | ❌ |
| 简单一句话回答 | ❌ | ✅ |
| 单条通知 | ❌ | ✅ |
工具使用
1. feishu_send_form — 表单卡片(推荐首选)
自动构建带提交/重置按钮的表单卡片,支持四种字段类型:
{
"to": "ou_xxx",
"title": "信息填写",
"description": "请填写以下信息(选填)",
"headerColor": "blue",
"fields": [
{
"name": "username",
"label": "姓名",
"type": "text",
"placeholder": "请输入姓名",
"required": true
},
{
"name": "dept",
"label": "部门",
"type": "select",
"options": [
{ "label": "技术", "value": "tech" },
{ "label": "产品", "value": "product" },
{ "label": "运营", "value": "ops" }
]
},
{
"name": "start_date",
"label": "开始日期",
"type": "date"
},
{
"name": "remark",
"label": "备注",
"type": "textarea",
"placeholder": "可选填"
}
],
"submitLabel": "提交",
"resetLabel": "重置",
"actionValue": { "action": "my_form_submit" }
}
字段类型:
| type | 组件 | 备注 |
|---|---|---|
text |
单行输入框 | 默认 |
textarea |
多行输入框 | rows=3, auto_resize |
date |
日期选择器 | 返回 YYYY-MM-DD |
select |
单选下拉 | 需提供 options |
headerColor 可选值:
blue green red orange yellow turquoise violet purple indigo carmine wathet grey default
2. feishu_send_card — 发送任意卡片 JSON
当 feishu_send_form 不够用时(需要按钮组、表格、图表、多列布局等),直接传 Card JSON 2.0 对象:
{
"to": "ou_xxx",
"card": {
"schema": "2.0",
"config": { "wide_screen_mode": true },
"header": {
"title": { "tag": "plain_text", "content": "卡片标题" },
"template": "blue"
},
"body": {
"direction": "vertical",
"elements": []
}
},
"accountId": "default"
}
3. feishu_update_card — 更新已发送卡片
用于:操作后更新卡片状态(如按钮点击后显示"已确认")。
{
"messageId": "om_xxx",
"card": { /* 新卡片 JSON */ },
"accountId": "default"
}
4. 处理回调
用户提交表单或点击按钮后,回调以 [CARD_ACTION] 消息形式到达 Agent,payload 包含:
form_value: 各字段的name → value映射(表单提交时)action.value:behaviors[].value中设置的自定义对象(按钮点击时)open_id: 操作人的飞书 open_id
收到 [CARD_ACTION] 后,继续处理业务逻辑,并可用 feishu_update_card 更新卡片状态。
常用卡片模板
确认操作
{
"schema": "2.0",
"config": { "wide_screen_mode": true },
"header": { "title": { "tag": "plain_text", "content": "⚠️ 操作确认" }, "template": "orange" },
"body": {
"direction": "vertical",
"elements": [
{ "tag": "markdown", "content": "你确定要执行 **[操作名]** 吗?此操作不可撤销。" },
{ "tag": "hr" },
{
"tag": "column_set",
"flex_mode": "none",
"columns": [
{
"tag": "column", "width": "weighted", "weight": 1,
"elements": [{ "tag": "button", "text": { "tag": "plain_text", "content": "✅ 确认" }, "type": "primary", "behaviors": [{ "type": "callback", "value": { "action": "confirm" } }] }]
},
{
"tag": "column", "width": "weighted", "weight": 1,
"elements": [{ "tag": "button", "text": { "tag": "plain_text", "content": "❌ 取消" }, "type": "danger", "behaviors": [{ "type": "callback", "value": { "action": "cancel" } }] }]
}
]
}
]
}
}
数据展示 + 操作按钮
{
"schema": "2.0",
"config": { "wide_screen_mode": true },
"header": { "title": { "tag": "plain_text", "content": "📊 结果" }, "template": "green" },
"body": {
"direction": "vertical",
"elements": [
{
"tag": "table",
"page_size": 10,
"columns": [
{ "name": "key", "display_name": "字段", "width": "auto" },
{ "name": "val", "display_name": "值", "width": "auto" }
],
"rows": []
},
{ "tag": "hr" },
{
"tag": "button",
"text": { "tag": "plain_text", "content": "继续" },
"type": "primary",
"behaviors": [{ "type": "callback", "value": { "action": "next" } }]
}
]
}
}
组件速查(Card JSON 2.0)
容器
| tag | 说明 |
|---|---|
column_set |
多列布局,flex_mode: none/stretch/flow/bisect/trisect |
form |
表单容器,需设 name,提交时返回字段值 |
interactive_container |
整块可点击区域,behaviors 触发回调 |
collapsible_panel |
折叠面板,expanded: false 默认收起 |
内容
| tag | 说明 |
|---|---|
plain_text |
纯文本,text_size: heading-0~4/normal/notation,text_color: default/grey/red/... |
markdown |
富文本,支持 **bold** _italic_ [link](url) <at id=ou_xxx> |
img |
图片,img_key 为飞书上传后的 key |
img_combination |
多图组合,combination_mode: double/triple/quad/trisect/mix |
chart |
图表,chart_spec 使用 VChart 格式 |
table |
表格,data_type: text/lark_md/number/person/date/options/url |
person / person_list |
用户头像 |
hr |
分割线 |
audio |
音频播放器,需 audio_key |
交互
| tag | 说明 |
|---|---|
input |
输入框,rows≥2 变多行 |
button |
按钮,type: default/primary/danger/text;behaviors: callback/form_action/open_url |
select_static |
单选下拉 |
multi_select_static |
多选下拉 |
select_person / multi_select_person |
人员选择器 |
date_picker / time_picker / picker_datetime |
日期/时间选择 |
img_picker |
图片上传选择 |
checker |
勾选框,checked 状态变化触发 behaviors |
overflow |
折叠更多菜单 |
Reviews (0)
Sign in to write a review.
No reviews yet. Be the first to review!
Comments (0)
No comments yet. Be the first to share your thoughts!