@wecom/wecom-openclaw-plugin 2026.3.25-beta.2 → 2026.3.25-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +302 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +302 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/skills/wecom-send-template-card/SKILL.md +102 -136
- package/skills/wecom-send-template-card/references/api-template-card-types.md +291 -574
package/package.json
CHANGED
|
@@ -1,191 +1,157 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: wecom-send-template-card
|
|
3
|
-
description:
|
|
3
|
+
description: 当需要通过企业微信发送结构化卡片消息时使用,包括:通知提醒、投票表决、方案选择、多维度选择等需要用户交互或查看结构化信息的场景。即使用户未明确要求"发卡片",只要语境适合(如"帮我问一下选A还是B"),也应主动激活。仅限 wecom 通道。
|
|
4
4
|
metadata:
|
|
5
5
|
{
|
|
6
6
|
"openclaw": { "emoji": "🃏", "requires": { "config": ["channels.wecom"] } },
|
|
7
7
|
}
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
---
|
|
11
|
-
|
|
12
10
|
## 使用方式
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
### 输出格式
|
|
17
|
-
|
|
18
|
-
在你的回复中,正常文本照常输出,需要发送模板卡片时,将完整的 template_card JSON 包裹在 markdown 代码块中:
|
|
12
|
+
在回复中输出 ` ```json ``` ` 代码块,内容为符合 [JSON Schema](./references/api-template-card-types.md) 的模板卡片 JSON。插件自动提取并发送。
|
|
19
13
|
|
|
20
14
|
````
|
|
21
|
-
|
|
15
|
+
你的回复文本...
|
|
22
16
|
|
|
23
17
|
```json
|
|
24
18
|
{
|
|
25
|
-
"card_type": "
|
|
26
|
-
...
|
|
19
|
+
"card_type": "...",
|
|
20
|
+
...
|
|
27
21
|
}
|
|
28
22
|
```
|
|
29
|
-
|
|
30
|
-
可以继续输出其他文本...
|
|
31
23
|
````
|
|
32
24
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
1. **必须使用 markdown 代码块**:用 ` ```json ` 和 ` ``` ` 包裹 JSON
|
|
36
|
-
2. **必须包含 `card_type` 字段**:值为以下五种之一:`text_notice`、`news_notice`、`button_interaction`、`vote_interaction`、`multiple_interaction`
|
|
37
|
-
3. **JSON 必须合法**:确保能被 `JSON.parse` 正确解析,生成后请自查一次。
|
|
38
|
-
4. **一次回复可包含多个卡片**:每个卡片用独立的代码块包裹
|
|
39
|
-
5. **代码块外的文本正常展示**:提取卡片后,剩余文本会作为普通流式回复发送给用户
|
|
40
|
-
|
|
41
|
-
### 重要注意事项
|
|
42
|
-
|
|
43
|
-
- **不要使用 MCP 工具调用**来发送模板卡片,直接在回复中输出 JSON 代码块即可
|
|
44
|
-
- 代码块中的 JSON 就是 `template_card` 的完整结构体(即企业微信 API 中 `template_card` 字段的值)
|
|
45
|
-
- 不需要包裹外层的 `msgtype`、`chatid` 等字段,只需 `template_card` 本身的内容
|
|
46
|
-
- **字段类型必须严格匹配企业微信 API 要求**:
|
|
47
|
-
- `mode`、`style`、`type`、`desc_color` 等字段必须为**整数**(如 `0`、`1`),**不能**用字符串(如 `"multi"`、`"single"`)
|
|
48
|
-
- `disable`、`is_checked` 必须为**布尔值** `true` / `false`,**不能**用字符串
|
|
49
|
-
- 例:`"mode": 1`(✅ 正确) vs `"mode": "multi"`(❌ 错误)
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## 场景识别与卡片类型选择
|
|
25
|
+
## 生成规则
|
|
54
26
|
|
|
55
|
-
|
|
27
|
+
1. **严格按 schema 生成**:字段名、类型、嵌套结构必须与 [./references/api-template-card-types.md](./references/api-template-card-types.md) 中的 JSON Schema 定义完全一致
|
|
28
|
+
2. **每张卡片必须有 `task_id`**:格式 `task_{场景}_{时间戳}`,只能包含数字、字母、`_-@`
|
|
29
|
+
3. 不要使用 MCP 工具调用,直接在回复中输出 JSON 代码块
|
|
30
|
+
4. 代码块外的文本会作为普通回复发送
|
|
56
31
|
|
|
57
|
-
|
|
58
|
-
|---------|------------|-----------|
|
|
59
|
-
| 通知提醒、状态更新、信息汇总 | 文本通知模版卡片 | `text_notice` |
|
|
60
|
-
| 带图片的内容展示、新闻资讯、产品介绍 | 图文展示模版卡片 | `news_notice` |
|
|
61
|
-
| 需要用户点击按钮做出选择(如:确认/取消、选择方案 A/B/C) | 按钮交互模版卡片 | `button_interaction` |
|
|
62
|
-
| 需要用户在多个选项中投票(单选或多选) | 投票选择模版卡片 | `vote_interaction` |
|
|
63
|
-
| 需要用户在多个维度上分别做出选择(如:选择时间+地点+人员) | 多项选择模版卡片 | `multiple_interaction` |
|
|
32
|
+
## 卡片类型选择
|
|
64
33
|
|
|
65
|
-
###
|
|
34
|
+
### 决策流程
|
|
66
35
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
## 核心规则
|
|
80
|
-
|
|
81
|
-
### task_id 生成规则
|
|
36
|
+
```
|
|
37
|
+
用户需求是否需要交互?
|
|
38
|
+
├─ 否(纯通知/信息推送)
|
|
39
|
+
│ ├─ 需要图片展示? → news_notice
|
|
40
|
+
│ └─ 不需要图片 → text_notice
|
|
41
|
+
│
|
|
42
|
+
└─ 是(需要用户操作)
|
|
43
|
+
├─ 从有限选项中做一个操作(≤6个按钮)→ button_interaction
|
|
44
|
+
├─ 从一组选项中投票/选择(可多选) → vote_interaction
|
|
45
|
+
└─ 提供多个维度的选择(≤3个下拉框) → multiple_interaction
|
|
46
|
+
```
|
|
82
47
|
|
|
83
|
-
|
|
84
|
-
- 格式:`task_{场景描述}_{时间戳}`
|
|
85
|
-
- 示例:`task_solution_select_1711234567`、`task_vote_team_building_1711234568`
|
|
48
|
+
### 场景速查
|
|
86
49
|
|
|
87
|
-
|
|
50
|
+
| card_type | 典型场景 |
|
|
51
|
+
|-----------|---------|
|
|
52
|
+
| `text_notice` | 系统告警、部署通知、数据日报、审批结果、放假公告 |
|
|
53
|
+
| `news_notice` | 新闻推送、活动宣传、产品发布、带图表的周报、新员工介绍 |
|
|
54
|
+
| `button_interaction` | 审批(同意/驳回)、工单处理(接单/转派)、确认操作、满意度评价、二次确认(是/否) |
|
|
55
|
+
| `vote_interaction` | 团建投票、会议时间协调、问卷单题、意见征集、方案评选 |
|
|
56
|
+
| `multiple_interaction` | 多维度信息收集(部门+楼层+时间)、报障工单(类型+紧急程度)、会议室预定(日期+时间+房间) |
|
|
88
57
|
|
|
89
|
-
|
|
90
|
-
- 若无实际跳转需求,可设置 `type: 1` 并使用一个通用 URL
|
|
91
|
-
- `button_interaction`、`vote_interaction`、`multiple_interaction` 不需要 `card_action`
|
|
58
|
+
### 易混淆卡片区分
|
|
92
59
|
|
|
93
|
-
|
|
60
|
+
- **button_interaction vs vote_interaction**:按钮型适合"少量选项+即时操作"(如确认/取消),投票型适合"选项多+可多选+统一提交"(如投票)
|
|
61
|
+
- **vote_interaction vs multiple_interaction**:投票型是"一个问题选多项",多项选择型是"多个独立问题各选一项"(如同时选时间和地点)
|
|
94
62
|
|
|
95
|
-
##
|
|
63
|
+
## 必填字段速查
|
|
96
64
|
|
|
97
|
-
|
|
65
|
+
| card_type | required |
|
|
66
|
+
|-----------|----------|
|
|
67
|
+
| `text_notice` | `card_type`, `task_id`, `card_action`, (`main_title` 或 `sub_title_text` 至少一个) |
|
|
68
|
+
| `news_notice` | `card_type`, `task_id`, `main_title`, `card_action` |
|
|
69
|
+
| `button_interaction` | `card_type`, `task_id`, `main_title`, `button_list` |
|
|
70
|
+
| `vote_interaction` | `card_type`, `task_id`, `title`, `options` |
|
|
71
|
+
| `multiple_interaction` | `card_type`, `task_id`, `title`, `selectors` |
|
|
98
72
|
|
|
99
|
-
|
|
73
|
+
## 最小示例
|
|
100
74
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
好的,我来为你发一个团建活动投票卡片 🗳️
|
|
75
|
+
### text_notice
|
|
104
76
|
|
|
105
77
|
```json
|
|
106
78
|
{
|
|
107
|
-
"card_type": "
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
"
|
|
112
|
-
"title": "团建活动投票",
|
|
113
|
-
"desc": "请选择你最想参加的团建活动"
|
|
114
|
-
},
|
|
115
|
-
"checkbox": {
|
|
116
|
-
"question_key": "team_building_vote",
|
|
117
|
-
"option_list": [
|
|
118
|
-
{ "id": "opt_hiking", "text": "🏔️ 爬山" },
|
|
119
|
-
{ "id": "opt_dinner", "text": "🍽️ 聚餐" },
|
|
120
|
-
{ "id": "opt_escape", "text": "🔐 密室逃脱" }
|
|
121
|
-
],
|
|
122
|
-
"mode": 1
|
|
123
|
-
},
|
|
124
|
-
"submit_button": {
|
|
125
|
-
"text": "提交投票",
|
|
126
|
-
"key": "submit_team_building"
|
|
127
|
-
},
|
|
128
|
-
"task_id": "task_team_building_vote_1711234567"
|
|
79
|
+
"card_type": "text_notice",
|
|
80
|
+
"main_title": { "title": "项目进度更新", "desc": "进度已达 80%" },
|
|
81
|
+
"emphasis_content": { "title": "80%", "desc": "完成度" },
|
|
82
|
+
"card_action": { "type": 1, "url": "https://work.weixin.qq.com" },
|
|
83
|
+
"task_id": "task_progress_1711234567"
|
|
129
84
|
}
|
|
130
85
|
```
|
|
131
86
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
### 示例 2:发送按钮交互卡片(button_interaction)
|
|
135
|
-
|
|
136
|
-
**用户**:有两个技术方案让用户选:A方案重构、B方案兼容
|
|
87
|
+
### news_notice
|
|
137
88
|
|
|
138
|
-
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"card_type": "news_notice",
|
|
92
|
+
"main_title": { "title": "新功能上线", "desc": "v5.0 已发布" },
|
|
93
|
+
"card_image": { "url": "https://wework.qpic.cn/wwpic/xxx/0" },
|
|
94
|
+
"card_action": { "type": 1, "url": "https://work.weixin.qq.com" },
|
|
95
|
+
"task_id": "task_release_1711234568"
|
|
96
|
+
}
|
|
97
|
+
```
|
|
139
98
|
|
|
140
|
-
|
|
99
|
+
### button_interaction
|
|
141
100
|
|
|
142
101
|
```json
|
|
143
102
|
{
|
|
144
103
|
"card_type": "button_interaction",
|
|
145
|
-
"main_title": {
|
|
146
|
-
"title": "技术方案选择",
|
|
147
|
-
"desc": "请选择你倾向的技术方案"
|
|
148
|
-
},
|
|
149
|
-
"sub_title_text": "A方案:全面重构,长期收益更高但开发周期长\nB方案:兼容现有架构,快速交付但技术债增加",
|
|
104
|
+
"main_title": { "title": "方案选择", "desc": "请选择技术方案" },
|
|
150
105
|
"button_list": [
|
|
151
|
-
{ "text": "A
|
|
152
|
-
{ "text": "B
|
|
106
|
+
{ "text": "A方案-重构", "style": 1, "key": "plan_a" },
|
|
107
|
+
{ "text": "B方案-兼容", "style": 4, "key": "plan_b" }
|
|
153
108
|
],
|
|
154
|
-
"task_id": "
|
|
109
|
+
"task_id": "task_plan_select_1711234569"
|
|
155
110
|
}
|
|
156
111
|
```
|
|
157
112
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
### 示例 3:发送文本通知卡片(text_notice)
|
|
161
|
-
|
|
162
|
-
**用户**:通知一下项目进度已完成80%
|
|
163
|
-
|
|
164
|
-
**你的回复**:
|
|
113
|
+
### vote_interaction(简化格式)
|
|
165
114
|
|
|
166
115
|
```json
|
|
167
116
|
{
|
|
168
|
-
"card_type": "
|
|
169
|
-
"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
"
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
"type": 1,
|
|
180
|
-
"url": "https://work.weixin.qq.com"
|
|
181
|
-
}
|
|
117
|
+
"card_type": "vote_interaction",
|
|
118
|
+
"title": "团建投票",
|
|
119
|
+
"description": "选择你想参加的活动",
|
|
120
|
+
"options": [
|
|
121
|
+
{ "id": "hiking", "text": "爬山" },
|
|
122
|
+
{ "id": "dinner", "text": "聚餐" },
|
|
123
|
+
{ "id": "escape", "text": "密室逃脱" }
|
|
124
|
+
],
|
|
125
|
+
"mode": 1,
|
|
126
|
+
"submit_text": "提交投票",
|
|
127
|
+
"task_id": "task_team_vote_1711234570"
|
|
182
128
|
}
|
|
183
129
|
```
|
|
184
130
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
## 错误处理
|
|
131
|
+
### multiple_interaction(简化格式)
|
|
188
132
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"card_type": "multiple_interaction",
|
|
136
|
+
"title": "团建安排",
|
|
137
|
+
"description": "分别选择时间和地点",
|
|
138
|
+
"selectors": [
|
|
139
|
+
{
|
|
140
|
+
"title": "时间",
|
|
141
|
+
"options": [
|
|
142
|
+
{ "id": "sat", "text": "周六" },
|
|
143
|
+
{ "id": "sun", "text": "周日" }
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"title": "地点",
|
|
148
|
+
"options": [
|
|
149
|
+
{ "id": "park", "text": "公园" },
|
|
150
|
+
{ "id": "resort", "text": "度假村" }
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"submit_text": "提交选择",
|
|
155
|
+
"task_id": "task_arrange_1711234571"
|
|
156
|
+
}
|
|
157
|
+
```
|