卡片消息
卡片消息是一种富文本消息格式,支持标题、正文、图片、按钮等多种元素组合。
卡片结构
{
"msg_type": "card",
"content": {
"header": { ... },
"elements": [ ... ]
}
}
Header 标题
{
"header": {
"title": "审批通知",
"template": "blue"
}
}
支持的模板颜色:blue、green、orange、red、purple
Elements 元素
文本块
{
"tag": "div",
"text": "这是一段文本内容"
}
分割线
{
"tag": "hr"
}
按钮组
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": "同意",
"type": "primary",
"value": "approve"
},
{
"tag": "button",
"text": "拒绝",
"type": "danger",
"value": "reject"
}
]
}
完整示例
{
"msg_type": "card",
"content": {
"header": {
"title": "📋 报销审批",
"template": "blue"
},
"elements": [
{
"tag": "div",
"text": "**申请人:** 张三"
},
{
"tag": "div",
"text": "**金额:** ¥1,280.00"
},
{
"tag": "div",
"text": "**事由:** 客户拜访差旅费"
},
{
"tag": "hr"
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": "✅ 同意",
"type": "primary",
"value": "approve"
},
{
"tag": "button",
"text": "❌ 拒绝",
"type": "danger",
"value": "reject"
},
{
"tag": "button",
"text": "查看详情",
"type": "default",
"url": "https://oa.example.com/expense/123"
}
]
}
]
}
}
按钮回调
用户点击按钮后,开放平台会向您配置的 Webhook 地址发送回调事件,详见 事件订阅。