@wecom/wecom-openclaw-plugin 2026.3.25-beta.2 → 2026.3.25-beta.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wecom/wecom-openclaw-plugin",
3
- "version": "2026.3.25-beta.2",
3
+ "version": "2026.3.25-beta.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,191 +1,157 @@
1
1
  ---
2
2
  name: wecom-send-template-card
3
- description: 企业微信模板卡片消息技能。当对话中存在需要用户做出选择、确认、投票或查看结构化信息的场景时,自动识别并使用最合适的模板卡片类型发送消息。支持文本通知(text_notice)、图文展示(news_notice)、按钮交互(button_interaction)、投票选择(vote_interaction)、多项选择(multiple_interaction)五种卡片类型。当你需要向用户展示多个方案让其选择时、需要发起投票时、需要发送结构化通知时、需要用户在多个维度上做出选择时,都应该使用此技能而不是纯文本消息。即使用户没有明确要求"发卡片",只要对话语境适合使用卡片(如"帮我问一下张三选 A 还是 B"),也应主动使用。仅当通过 wecom 通道通信时使用此技能。
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
- 在回复文本中直接输出一个 markdown JSON 代码块,代码块中的 JSON 必须格式正确、合法且包含 `card_type` 字段。插件层会自动从回复中检测并提取该 JSON 字符串并 Parse,然后通过企业微信 SDK 发送模板卡片消息。
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
- | 对话场景 | 推荐卡片类型 | card_type |
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
- - **按钮交互**:选择方案、确认操作、同意/拒绝、选一个、A还是B、需要你确认
70
- - **投票选择**:投票、表决、评选、单选/多选、最喜欢哪个
71
- - **多项选择**:多个维度选择、分别选择、组合选择、多个下拉框
72
-
73
- ---
74
-
75
- ## 五种卡片类型详细说明
76
-
77
- 请参考 [./references/api-template-card-types.md](./references/api-template-card-types.md) 的描述。
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
- `task_id` 用于唯一标识一次交互,需确保唯一性。生成规则:
84
- - 格式:`task_{场景描述}_{时间戳}`
85
- - 示例:`task_solution_select_1711234567`、`task_vote_team_building_1711234568`
48
+ ### 场景速查
86
49
 
87
- ### card_action 规则
50
+ | card_type | 典型场景 |
51
+ |-----------|---------|
52
+ | `text_notice` | 系统告警、部署通知、数据日报、审批结果、放假公告 |
53
+ | `news_notice` | 新闻推送、活动宣传、产品发布、带图表的周报、新员工介绍 |
54
+ | `button_interaction` | 审批(同意/驳回)、工单处理(接单/转派)、确认操作、满意度评价、二次确认(是/否) |
55
+ | `vote_interaction` | 团建投票、会议时间协调、问卷单题、意见征集、方案评选 |
56
+ | `multiple_interaction` | 多维度信息收集(部门+楼层+时间)、报障工单(类型+紧急程度)、会议室预定(日期+时间+房间) |
88
57
 
89
- - `text_notice` 和 `news_notice` 的 `card_action` 为**必填**字段
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
- ### 示例 1:发送投票卡片(vote_interaction)
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": "vote_interaction",
108
- "source": {
109
- "desc": "团建投票"
110
- },
111
- "main_title": {
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方案 - 重构", "style": 1, "key": "plan_a_refactor" },
152
- { "text": "B方案 - 兼容", "style": 4, "key": "plan_b_compat" }
106
+ { "text": "A方案-重构", "style": 1, "key": "plan_a" },
107
+ { "text": "B方案-兼容", "style": 4, "key": "plan_b" }
153
108
  ],
154
- "task_id": "task_solution_select_1711234568"
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": "text_notice",
169
- "main_title": {
170
- "title": "项目进度更新",
171
- "desc": "截至当前,项目整体进度已达到 80%"
172
- },
173
- "emphasis_content": {
174
- "title": "80%",
175
- "desc": "项目完成度"
176
- },
177
- "sub_title_text": "各模块进展顺利,预计按期交付。",
178
- "card_action": {
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
- - 如果 JSON 格式不合法或 `card_type` 不在五种类型中,代码块会被保留在原文中作为普通文本展示(不会被提取为卡片)
190
- - 确保每个交互型卡片(button_interaction、vote_interaction、multiple_interaction)都有唯一的 `task_id`
191
- - `text_notice` 和 `news_notice` 必须包含 `card_action` 字段
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
+ ```