@mambasms/mcp-server 0.6.8 → 0.6.10
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/README.md +153 -153
- package/index.js +1374 -1360
- package/package.json +1 -1
- package/skill/mambasms-mcp/SKILL.md +235 -235
package/package.json
CHANGED
|
@@ -1,235 +1,235 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: mambasms-mcp
|
|
3
|
-
description: 曼巴 MambaSMS 营销自动化 MCP(@mambasms/mcp-server)使用技能。当需要创建/修改邮件模板、建营销活动或自动化流程草稿、创建用户分组,或查询活动/流程/分组/联系人/报表/余额时使用。含 52 个工具的选型、参数、质量闸门、条件写法与排错口径。
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# MambaSMS MCP 使用技能
|
|
7
|
-
|
|
8
|
-
客户的 AI(
|
|
9
|
-
**模板、活动草稿、流程草稿、条件分组、数据查询**。
|
|
10
|
-
核心定位:**AI 管内容生产,后台管发送与精修**。一切写操作只到 `draft`。
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 1. 前置检查(每次会话开始时)
|
|
15
|
-
|
|
16
|
-
| 项 | 要求 |
|
|
17
|
-
|---|---|
|
|
18
|
-
| `MAMBA_ACCESS_TOKEN` | 店铺密钥 `shop_xxxxxxxx`,等同店铺全权凭证 |
|
|
19
|
-
| `MAMBA_API_BASE` | 生产 `https://api.mambasms.com`;测试 `https://olapapi.mambasend.com`。**两环境数据完全隔离** |
|
|
20
|
-
| `MAMBA_READONLY` | 置 `1` 时只注册只读工具(52→36),写操作全部不可用 |
|
|
21
|
-
| 自查 | 不确定工具时先调 `mamba_guide`(能力总览)→ `mamba_search`(关键词)→ `mamba_tool_schema`(参数) |
|
|
22
|
-
|
|
23
|
-
**密钥不经过对话**:店铺密钥由 MCP 连接器的 `env` 提供(`MAMBA_ACCESS_TOKEN`),MCP 进程自己读取并放进每个请求头。
|
|
24
|
-
**绝不要向用户索要密钥,也不要把密钥写入代码、文档或聊天记录**——工具报鉴权失败时,让用户去检查 MCP 配置里的 `env`,而不是把 key 发过来。
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## 2. 十二条铁律
|
|
29
|
-
|
|
30
|
-
1. **先查目录再写**:模板查 `catalog_query`、分组查 `group_catalog`、流程先 `flow_triggers`。目录是唯一真源,禁止凭印象编字段。
|
|
31
|
-
2. **只建草稿**:`campaign_create_*` / `flow_create` 产出 `status=draft`,不发送、不启用、不扣费。绝不向用户宣称“已发送/已上线”。
|
|
32
|
-
3. **正文质量闸门**:活动正文渲染后 **≥4200 字符**、流程邮件节点 **≥3000 字符**,必须含 `{Unsubscribe}`,买家可见文案**一律英文**。不达标会被 412 拒绝,需补充模块化内容而不是灌水。
|
|
33
|
-
4. **模板首选结构化**:`template_create_from_design`(emailDesign)优于手写 HTML;要迁移现成 HTML 才用 `template_create(html)`。
|
|
34
|
-
5. **`email_design` 与 `html` 互斥**:二选一,不要同时传。
|
|
35
|
-
6. **建分组必须二维**:`query_content` 是**二维数组**,外层 OR、内层 AND;建组前必须已调用 `group_catalog`(否则被拒,30 分钟内免再查)。
|
|
36
|
-
7. **活动指定人群**:`communication_select="tag"` + `tag_id`;排除人群用 `non_send_tag_id`。
|
|
37
|
-
8. **花括号只用单花括号**:`{Unsubscribe}` / `${order.number}`,禁止 `{{ }}` 混用(引擎不认,会导致正式发送失败)。
|
|
38
|
-
9. **改前先查 list**:避免重复创建同名模板/活动/分组;已有对象优先 `*_update_content` 或 `template_update`。
|
|
39
|
-
10. **`update_*` 仅 draft 可改**:已发送/已启用的对象会返回 412。需要改就去后台复制,不要试图绕过。
|
|
40
|
-
11. **汇报必须带证据**:返回对象 `id`、`status=draft`、受众(分组名/人数)、预览链接;不要只说“已完成”。
|
|
41
|
-
12. **失败先读报错再改参数**:412 的错误文案都写了下一步动作;不要原样重试。
|
|
42
|
-
13. **限流要当常态处理**:单店 **10 请求/秒**;`campaign_list` **10 秒 1 次**;遇 `429` 退避 ≥1 秒、活动列表退避 ≥10 秒,不要死循环重试。
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## 2.5 限流与并发(429 / 412 的正确处理)
|
|
47
|
-
|
|
48
|
-
| 层 | 规则 | 触发场景 | 应对 |
|
|
49
|
-
|---|---|---|---|
|
|
50
|
-
| 店铺级全局 | **10 请求/秒**(按店铺 key) | 一轮并行发太多工具调用 | 客户端限速 ≤10 QPS;遇 429 退避 1 秒 |
|
|
51
|
-
| 活动列表 | **`campaign_list` 10 秒 1 次**(同店铺、同端点) | 连续查两次活动列表 | 隔 ≥10 秒再查;拿到 id 后用 `campaign_report` / `campaign_link_report`(走助手代理,不受此限);一次把 `page_size` 拉够,别反复翻页 |
|
|
52
|
-
| 助手代理 | 同店铺调用**串行**(会话锁),服务端自动退避重试 | 并行发多个只读/写工具 | 服务端已自动重试;**写操作仍建议串行**,避免长时间排队 |
|
|
53
|
-
| 事件推送 | 40 次/秒 | 与 MCP 无关 | — |
|
|
54
|
-
|
|
55
|
-
**错误区分**:`429` = 限流(退避重试);`412 上一条消息还在处理中` = 会话锁(**等服务端重试或 1 秒后重试**,不要改参数);`412 校验未通过` = 参数问题(按文案改)。
|
|
56
|
-
|
|
57
|
-
**批量读取的正确姿势**:一次 `page_size` 取 50~100,本地筛选;不要「翻页 10 次 + 每页再查详情」。活动类接口 10 秒 1 次的桶按端点独立计算。
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## 3. 工具地图(52 个)
|
|
62
|
-
|
|
63
|
-
### 3.1 模板(17)
|
|
64
|
-
|
|
65
|
-
| 工具 | 用途 |
|
|
66
|
-
|---|---|
|
|
67
|
-
| `template_create_from_design` | **首选**:传 emailDesign 结构化 JSON 生成模板 |
|
|
68
|
-
| `template_create` | 纯 `html` 或语义区块 `sections`(`cart_list`/`browse_list` 动态区块) |
|
|
69
|
-
| `template_update` / `template_delete` | 改(可只改标题/摘要)/ 删(被活动或流程引用时拒绝) |
|
|
70
|
-
| `template_list` / `template_get` | 列表 / 详情(**返回渲染预览**,占位符已替换,不要当原模板改回去) |
|
|
71
|
-
| `template_list_system` / `template_get_system` / `template_system_categories` | 系统模板库参考(结构+文案) |
|
|
72
|
-
| `catalog_query` | 创建规范目录:`emailDesign` / `styles` / `layouts` / `components` / `discount` / `variants` |
|
|
73
|
-
| `block_library_query` | 编辑器预置区块库 |
|
|
74
|
-
| `template_preview` | 渲染 HTML + **免登永久预览链接** |
|
|
75
|
-
| `template_send_test` | 发测试邮件(≤10 收件人,同店铺 2 分钟限频,需已启用发件人) |
|
|
76
|
-
| `template_export` / `template_import` | `.mambatpl` 导出 / 从 URL 导入(`.mambatpl` 或 `zipHtml`) |
|
|
77
|
-
| `upload_image` | 图片转存平台 CDN(jpg/jpeg/png/gif/webp,≤5MB) |
|
|
78
|
-
| `template_snippets` | 页头/页脚 HTML 片段(`header-basic` / `footer-basic` / `footer-social`) |
|
|
79
|
-
|
|
80
|
-
### 3.2 只读与质检(23)
|
|
81
|
-
|
|
82
|
-
| 范围 | 工具 |
|
|
83
|
-
|---|---|
|
|
84
|
-
| 活动 | `campaign_list` `campaign_report` `campaign_link_report` `campaign_abtest_result` `campaign_content` |
|
|
85
|
-
| 自动化 | `flow_list` `flow_report` `flow_send_failure` `flow_content` `flow_triggers` |
|
|
86
|
-
| 分组 | `group_list` `group_catalog` `group_members` |
|
|
87
|
-
| 联系人 | `contact_get`(精确查)`contact_send_status` |
|
|
88
|
-
| 报表 | `audience_growth` `form_performance` `domain_health` `store_overview` `order_stats` `account_balance` |
|
|
89
|
-
| 质检/品牌 | `email_audit`(13 条规则+评分,`deep=true` 加模型审查)`brand_profile` |
|
|
90
|
-
|
|
91
|
-
### 3.3 写 = 只建草稿(8)
|
|
92
|
-
|
|
93
|
-
`campaign_create_email` `campaign_create_sms` `campaign_create_abtest` `campaign_create_sms_abtest`
|
|
94
|
-
`campaign_update_content` `flow_create` `flow_update_content` `user_group_create`
|
|
95
|
-
|
|
96
|
-
### 3.4 通用(4)
|
|
97
|
-
|
|
98
|
-
`mamba_guide`(能力总览,可传 `topic`)`mamba_search` `mamba_tool_schema` `mamba_execute`
|
|
99
|
-
|
|
100
|
-
> 完整参数(必填项/类型/说明)见 `references/tool-catalog.md`。
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## 4. 四条标准流程
|
|
105
|
-
|
|
106
|
-
### 4.1 从零做一封营销邮件(最常用)
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
1) catalog_query(topic="emailDesign") # 取字段规范;要骨架再加 layouts,要配色加 styles
|
|
110
|
-
2) brand_profile() # 有品牌档案时按品牌语气写文案
|
|
111
|
-
3) template_create_from_design(title=..., email_design=<JSON>) # 建模板(也可直接进 4)
|
|
112
|
-
4) template_preview(id) # 拿免登链接给用户看
|
|
113
|
-
5) template_send_test(id, emails=["me@x.com"])# 可选:发到自己邮箱确认
|
|
114
|
-
6) campaign_create_email(title=..., email_design=<JSON 或 template_id>,
|
|
115
|
-
subject_line=..., communication_select="tag", tag_id=<分组id>)
|
|
116
|
-
7) email_audit(source="campaigns", campaigns_id=<id>) # 交付前自检,score<80 先改
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
emailDesign 最小合规样例(**买家可见文案必须英文**):
|
|
120
|
-
|
|
121
|
-
```json
|
|
122
|
-
{
|
|
123
|
-
"style": "classic",
|
|
124
|
-
"theme": { "primaryColor": "#1a1a2e", "accentColor": "#d4af37" },
|
|
125
|
-
"hero": { "title": "Black Friday Starts Now", "subtitle": "Up to 40% off sitewide" },
|
|
126
|
-
"intro": "Our biggest sale of the year is live. Limited stock, while supplies last.",
|
|
127
|
-
"products": [
|
|
128
|
-
{ "name": "Linen Shirt", "price": "$49.00", "originalPrice": "$69.00" },
|
|
129
|
-
{ "name": "Cotton Trousers", "price": "$59.00", "originalPrice": "$79.00" }
|
|
130
|
-
],
|
|
131
|
-
"offer": { "headline": "40% OFF", "subline": "Use code at checkout", "code": "{DiscountCode}" },
|
|
132
|
-
"cta": { "text": "SHOP NOW", "link": "https://your-store.com/collections/sale" },
|
|
133
|
-
"social": ["instagram", "facebook", "tiktok"]
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
要点:`hero.title` 是 banner 文字(必填);商品只出现在网格位;Logo/信任背书/页脚退订由系统自动生成;用户点名的商品必须逐个原样放进 `products[].name`。
|
|
138
|
-
|
|
139
|
-
### 4.2 迁移现成 HTML
|
|
140
|
-
|
|
141
|
-
```
|
|
142
|
-
upload_image(url) # 图片先转 CDN(否则外链可能被邮箱客户端拦)
|
|
143
|
-
template_create(title=..., html=<整份 HTML,含 {Unsubscribe}>)
|
|
144
|
-
template_preview(id)
|
|
145
|
-
```
|
|
146
|
-
HTML 必须:内联样式、表格布局、含 `{Unsubscribe}`;正文过短会被质量闸门拒(活动 ≥4200 字符)。
|
|
147
|
-
|
|
148
|
-
### 4.3 按条件圈人(建分组)
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
1) group_catalog() # 数据域清单 + 通用规则(必做)
|
|
152
|
-
2) group_catalog(nested_path="success_checkout")# 该域真实字段 + 规则
|
|
153
|
-
3) user_group_create(name="高价值老客", query_content=<二维数组 JSON 字符串>)
|
|
154
|
-
4) group_list(keyword=...) # 等 dynamicStatus=complete 看 userCount(数十秒)
|
|
155
|
-
5) group_members(group_id=...) # 抽样看成员
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
条件写法见 `references/group-conditions.md`。最常见三条:
|
|
159
|
-
|
|
160
|
-
```json
|
|
161
|
-
// 近 30 天下过单
|
|
162
|
-
[[{"condition":"gte","field":"number","logic":"must","nestedPath":"success_checkout","script":false,"value":"1"},
|
|
163
|
-
{"condition":"gte","field":"date_day","logic":"must","nestedPath":"success_checkout","script":false,"value":"formerly:30"}]]
|
|
164
|
-
|
|
165
|
-
// 美国客户(基础属性,nestedPath 传空串)
|
|
166
|
-
[[{"condition":"term_query","field":"country","logic":"must","nestedPath":"","value":"US"}]]
|
|
167
|
-
|
|
168
|
-
// A 或 B:两个外层组("A或B"=[[A],[B]],不是 [[A,B]])
|
|
169
|
-
[[{...A...}],[{...B...}]]
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### 4.4 弃单挽回自动化(加购未购买)
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
1) flow_triggers() # 取 trigger_key 与 filters(真源,别猜)
|
|
176
|
-
2) flow_create(flow_name="弃单挽回 60 分钟",
|
|
177
|
-
trigger_key="join_cart", # 加购未购买 = 弃单;没有 abandon_checkout 这个 key
|
|
178
|
-
channel="Email",
|
|
179
|
-
delay_minutes=60, delay_unit="minute",
|
|
180
|
-
email_subject="Still thinking it over?",
|
|
181
|
-
email_content=<整份 HTML ≥3000 字符,含 {Unsubscribe}>,
|
|
182
|
-
exit_conditions=["checkout_started","order_placed"], # 发起结账/下单后不再发
|
|
183
|
-
frequency_type="inLast", frequency_value=7, frequency_unit="day") # 7 天内最多进一次
|
|
184
|
-
3) flow_list(keyword="弃单挽回") # 确认 status=draft、邮件节点 page.edition=richtext
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**触发器真源(15 个)**:`back_in_stock` `customer_created` `entered_segment` `exited_segment` `flow_notify`
|
|
188
|
-
`join_cart` `order_create` `order_fulfilled` `order_paid` `order_placed` `order_refunded` `order_status_change`
|
|
189
|
-
`subscribe` `viewed_page` `viewed_product`
|
|
190
|
-
|
|
191
|
-
- ⚠️ `abandon_checkout` **不是**触发器 key(它是分组条件里的数据域)——弃单流程用 `join_cart`
|
|
192
|
-
- 触发器名(`order_placed`/`join_cart` 等)也不能作为分组 `nestedPath`
|
|
193
|
-
- `exit_conditions` 合法值:`add_to_cart` / `checkout_started` / `order_placed` / `order_paid`
|
|
194
|
-
- `frequency_type`:`atTime`(只进一次)/ `inLast`(按间隔,需 `frequency_value`+`frequency_unit`=hour|day|week)/ `none`;不传默认「间隔 24 小时」
|
|
195
|
-
- 正文来源三选一:`email_content`(= `html`)/ `email_design` / `template_id`;多节点用 `steps`
|
|
196
|
-
- `trigger_filters` 传触发器过滤器(如 `cart_total`、`product`、`product-collection`,具体 key 见 `flow_triggers(trigger_key=...)`)
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## 5. 报错速查
|
|
201
|
-
|
|
202
|
-
| 现象 | 原因 | 处理 |
|
|
203
|
-
|---|---|---|
|
|
204
|
-
| `authorization error (invalid basic auth data or API key)` | 密钥没填/填错/被重置 | 后台「店铺设置 → API 密钥」重新取 |
|
|
205
|
-
| `412 tool not allowed` | 工具不在放行白名单(如 `delete_campaign`) | 删除/发送/启用类能力刻意不开放,走后台 |
|
|
206
|
-
| `412 only draft can be modified (current status: sent)` | 改了非草稿对象 | 复制成新草稿再改 |
|
|
207
|
-
| `412 ... not found` | id 不属于当前店铺,或环境用混 | 核对 key 与 `MAMBA_API_BASE` |
|
|
208
|
-
| `412 正文质量校验未通过` | 太短/没 `{Unsubscribe}`/非英文 | 补内容模块、加退订、英文文案 |
|
|
209
|
-
| `412 分组条件校验未通过: 存在系统不支持的字段` | 编造了 field/nestedPath | 用 `group_catalog` 返回的真实字段重写 |
|
|
210
|
-
| `isError: 创建分组前必须先调用 group_catalog` | 跳过了目录查询 | 先查目录再建(30 分钟免再查) |
|
|
211
|
-
| `412 template is in use by N campaign/flow page(s)` | 模板被引用中 | 先在后台解除引用 |
|
|
212
|
-
| `500 unknown error` | 多为参数结构错误 | 对照 `mamba_tool_schema` 检查类型(数组/字符串) |
|
|
213
|
-
|
|
214
|
-
更多见 `references/troubleshooting.md`。
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## 6. 交付口径(怎么向客户汇报)
|
|
219
|
-
|
|
220
|
-
- 建活动:`活动id` + `status=draft` + 受众(分组名/人数)+ 主题行 + 预览链接;**明确说明“需在后台确认后发送”**
|
|
221
|
-
- 建模板:`模板id` + 预览链接 + warnings(如有)
|
|
222
|
-
- 建分组:`分组id` + 条件摘要 + `userCount`(打包完成后)
|
|
223
|
-
- 查询类:给指标 + 时间窗(默认近 180 天)+ 口径(订单已排除取消单;余额为美元且 group 级)
|
|
224
|
-
- 永不承诺:已发送、已启用、已扣费、已删除已发送对象
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
## 7. 参考文件
|
|
229
|
-
|
|
230
|
-
| 文件 | 内容 |
|
|
231
|
-
|---|---|
|
|
232
|
-
| `references/email-design.md` | emailDesign 全字段、硬规则、多版本、组件与折扣 |
|
|
233
|
-
| `references/group-conditions.md` | 条件二维结构、操作符白名单、时间写法、数据域与常见组合 |
|
|
234
|
-
| `references/tool-catalog.md` | 52 个工具的必填/可选参数清单 |
|
|
235
|
-
| `references/troubleshooting.md` | 报错、质量闸门、环境与限频、只读模式 |
|
|
1
|
+
---
|
|
2
|
+
name: mambasms-mcp
|
|
3
|
+
description: 曼巴 MambaSMS 营销自动化 MCP(@mambasms/mcp-server)使用技能。当需要创建/修改邮件模板、建营销活动或自动化流程草稿、创建用户分组,或查询活动/流程/分组/联系人/报表/余额时使用。含 52 个工具的选型、参数、质量闸门、条件写法与排错口径。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MambaSMS MCP 使用技能
|
|
7
|
+
|
|
8
|
+
客户的 AI(任意支持 MCP 的客户端:Claude Desktop / Cursor / Codex / IDE 插件 / 聚合客户端)通过 `@mambasms/mcp-server` 直接操作 MambaSMS:
|
|
9
|
+
**模板、活动草稿、流程草稿、条件分组、数据查询**。
|
|
10
|
+
核心定位:**AI 管内容生产,后台管发送与精修**。一切写操作只到 `draft`。
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 1. 前置检查(每次会话开始时)
|
|
15
|
+
|
|
16
|
+
| 项 | 要求 |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `MAMBA_ACCESS_TOKEN` | 店铺密钥 `shop_xxxxxxxx`,等同店铺全权凭证 |
|
|
19
|
+
| `MAMBA_API_BASE` | 生产 `https://api.mambasms.com`;测试 `https://olapapi.mambasend.com`。**两环境数据完全隔离** |
|
|
20
|
+
| `MAMBA_READONLY` | 置 `1` 时只注册只读工具(52→36),写操作全部不可用 |
|
|
21
|
+
| 自查 | 不确定工具时先调 `mamba_guide`(能力总览)→ `mamba_search`(关键词)→ `mamba_tool_schema`(参数) |
|
|
22
|
+
|
|
23
|
+
**密钥不经过对话**:店铺密钥由 MCP 连接器的 `env` 提供(`MAMBA_ACCESS_TOKEN`),MCP 进程自己读取并放进每个请求头。
|
|
24
|
+
**绝不要向用户索要密钥,也不要把密钥写入代码、文档或聊天记录**——工具报鉴权失败时,让用户去检查 MCP 配置里的 `env`,而不是把 key 发过来。
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. 十二条铁律
|
|
29
|
+
|
|
30
|
+
1. **先查目录再写**:模板查 `catalog_query`、分组查 `group_catalog`、流程先 `flow_triggers`。目录是唯一真源,禁止凭印象编字段。
|
|
31
|
+
2. **只建草稿**:`campaign_create_*` / `flow_create` 产出 `status=draft`,不发送、不启用、不扣费。绝不向用户宣称“已发送/已上线”。
|
|
32
|
+
3. **正文质量闸门**:活动正文渲染后 **≥4200 字符**、流程邮件节点 **≥3000 字符**,必须含 `{Unsubscribe}`,买家可见文案**一律英文**。不达标会被 412 拒绝,需补充模块化内容而不是灌水。
|
|
33
|
+
4. **模板首选结构化**:`template_create_from_design`(emailDesign)优于手写 HTML;要迁移现成 HTML 才用 `template_create(html)`。
|
|
34
|
+
5. **`email_design` 与 `html` 互斥**:二选一,不要同时传。
|
|
35
|
+
6. **建分组必须二维**:`query_content` 是**二维数组**,外层 OR、内层 AND;建组前必须已调用 `group_catalog`(否则被拒,30 分钟内免再查)。
|
|
36
|
+
7. **活动指定人群**:`communication_select="tag"` + `tag_id`;排除人群用 `non_send_tag_id`。
|
|
37
|
+
8. **花括号只用单花括号**:`{Unsubscribe}` / `${order.number}`,禁止 `{{ }}` 混用(引擎不认,会导致正式发送失败)。
|
|
38
|
+
9. **改前先查 list**:避免重复创建同名模板/活动/分组;已有对象优先 `*_update_content` 或 `template_update`。
|
|
39
|
+
10. **`update_*` 仅 draft 可改**:已发送/已启用的对象会返回 412。需要改就去后台复制,不要试图绕过。
|
|
40
|
+
11. **汇报必须带证据**:返回对象 `id`、`status=draft`、受众(分组名/人数)、预览链接;不要只说“已完成”。
|
|
41
|
+
12. **失败先读报错再改参数**:412 的错误文案都写了下一步动作;不要原样重试。
|
|
42
|
+
13. **限流要当常态处理**:单店 **10 请求/秒**;`campaign_list` **10 秒 1 次**;遇 `429` 退避 ≥1 秒、活动列表退避 ≥10 秒,不要死循环重试。
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 2.5 限流与并发(429 / 412 的正确处理)
|
|
47
|
+
|
|
48
|
+
| 层 | 规则 | 触发场景 | 应对 |
|
|
49
|
+
|---|---|---|---|
|
|
50
|
+
| 店铺级全局 | **10 请求/秒**(按店铺 key) | 一轮并行发太多工具调用 | 客户端限速 ≤10 QPS;遇 429 退避 1 秒 |
|
|
51
|
+
| 活动列表 | **`campaign_list` 10 秒 1 次**(同店铺、同端点) | 连续查两次活动列表 | 隔 ≥10 秒再查;拿到 id 后用 `campaign_report` / `campaign_link_report`(走助手代理,不受此限);一次把 `page_size` 拉够,别反复翻页 |
|
|
52
|
+
| 助手代理 | 同店铺调用**串行**(会话锁),服务端自动退避重试 | 并行发多个只读/写工具 | 服务端已自动重试;**写操作仍建议串行**,避免长时间排队 |
|
|
53
|
+
| 事件推送 | 40 次/秒 | 与 MCP 无关 | — |
|
|
54
|
+
|
|
55
|
+
**错误区分**:`429` = 限流(退避重试);`412 上一条消息还在处理中` = 会话锁(**等服务端重试或 1 秒后重试**,不要改参数);`412 校验未通过` = 参数问题(按文案改)。
|
|
56
|
+
|
|
57
|
+
**批量读取的正确姿势**:一次 `page_size` 取 50~100,本地筛选;不要「翻页 10 次 + 每页再查详情」。活动类接口 10 秒 1 次的桶按端点独立计算。
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 3. 工具地图(52 个)
|
|
62
|
+
|
|
63
|
+
### 3.1 模板(17)
|
|
64
|
+
|
|
65
|
+
| 工具 | 用途 |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `template_create_from_design` | **首选**:传 emailDesign 结构化 JSON 生成模板 |
|
|
68
|
+
| `template_create` | 纯 `html` 或语义区块 `sections`(`cart_list`/`browse_list` 动态区块) |
|
|
69
|
+
| `template_update` / `template_delete` | 改(可只改标题/摘要)/ 删(被活动或流程引用时拒绝) |
|
|
70
|
+
| `template_list` / `template_get` | 列表 / 详情(**返回渲染预览**,占位符已替换,不要当原模板改回去) |
|
|
71
|
+
| `template_list_system` / `template_get_system` / `template_system_categories` | 系统模板库参考(结构+文案) |
|
|
72
|
+
| `catalog_query` | 创建规范目录:`emailDesign` / `styles` / `layouts` / `components` / `discount` / `variants` |
|
|
73
|
+
| `block_library_query` | 编辑器预置区块库 |
|
|
74
|
+
| `template_preview` | 渲染 HTML + **免登永久预览链接** |
|
|
75
|
+
| `template_send_test` | 发测试邮件(≤10 收件人,同店铺 2 分钟限频,需已启用发件人) |
|
|
76
|
+
| `template_export` / `template_import` | `.mambatpl` 导出 / 从 URL 导入(`.mambatpl` 或 `zipHtml`) |
|
|
77
|
+
| `upload_image` | 图片转存平台 CDN(jpg/jpeg/png/gif/webp,≤5MB) |
|
|
78
|
+
| `template_snippets` | 页头/页脚 HTML 片段(`header-basic` / `footer-basic` / `footer-social`) |
|
|
79
|
+
|
|
80
|
+
### 3.2 只读与质检(23)
|
|
81
|
+
|
|
82
|
+
| 范围 | 工具 |
|
|
83
|
+
|---|---|
|
|
84
|
+
| 活动 | `campaign_list` `campaign_report` `campaign_link_report` `campaign_abtest_result` `campaign_content` |
|
|
85
|
+
| 自动化 | `flow_list` `flow_report` `flow_send_failure` `flow_content` `flow_triggers` |
|
|
86
|
+
| 分组 | `group_list` `group_catalog` `group_members` |
|
|
87
|
+
| 联系人 | `contact_get`(精确查)`contact_send_status` |
|
|
88
|
+
| 报表 | `audience_growth` `form_performance` `domain_health` `store_overview` `order_stats` `account_balance` |
|
|
89
|
+
| 质检/品牌 | `email_audit`(13 条规则+评分,`deep=true` 加模型审查)`brand_profile` |
|
|
90
|
+
|
|
91
|
+
### 3.3 写 = 只建草稿(8)
|
|
92
|
+
|
|
93
|
+
`campaign_create_email` `campaign_create_sms` `campaign_create_abtest` `campaign_create_sms_abtest`
|
|
94
|
+
`campaign_update_content` `flow_create` `flow_update_content` `user_group_create`
|
|
95
|
+
|
|
96
|
+
### 3.4 通用(4)
|
|
97
|
+
|
|
98
|
+
`mamba_guide`(能力总览,可传 `topic`)`mamba_search` `mamba_tool_schema` `mamba_execute`
|
|
99
|
+
|
|
100
|
+
> 完整参数(必填项/类型/说明)见 `references/tool-catalog.md`。
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 4. 四条标准流程
|
|
105
|
+
|
|
106
|
+
### 4.1 从零做一封营销邮件(最常用)
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
1) catalog_query(topic="emailDesign") # 取字段规范;要骨架再加 layouts,要配色加 styles
|
|
110
|
+
2) brand_profile() # 有品牌档案时按品牌语气写文案
|
|
111
|
+
3) template_create_from_design(title=..., email_design=<JSON>) # 建模板(也可直接进 4)
|
|
112
|
+
4) template_preview(id) # 拿免登链接给用户看
|
|
113
|
+
5) template_send_test(id, emails=["me@x.com"])# 可选:发到自己邮箱确认
|
|
114
|
+
6) campaign_create_email(title=..., email_design=<JSON 或 template_id>,
|
|
115
|
+
subject_line=..., communication_select="tag", tag_id=<分组id>)
|
|
116
|
+
7) email_audit(source="campaigns", campaigns_id=<id>) # 交付前自检,score<80 先改
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
emailDesign 最小合规样例(**买家可见文案必须英文**):
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"style": "classic",
|
|
124
|
+
"theme": { "primaryColor": "#1a1a2e", "accentColor": "#d4af37" },
|
|
125
|
+
"hero": { "title": "Black Friday Starts Now", "subtitle": "Up to 40% off sitewide" },
|
|
126
|
+
"intro": "Our biggest sale of the year is live. Limited stock, while supplies last.",
|
|
127
|
+
"products": [
|
|
128
|
+
{ "name": "Linen Shirt", "price": "$49.00", "originalPrice": "$69.00" },
|
|
129
|
+
{ "name": "Cotton Trousers", "price": "$59.00", "originalPrice": "$79.00" }
|
|
130
|
+
],
|
|
131
|
+
"offer": { "headline": "40% OFF", "subline": "Use code at checkout", "code": "{DiscountCode}" },
|
|
132
|
+
"cta": { "text": "SHOP NOW", "link": "https://your-store.com/collections/sale" },
|
|
133
|
+
"social": ["instagram", "facebook", "tiktok"]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
要点:`hero.title` 是 banner 文字(必填);商品只出现在网格位;Logo/信任背书/页脚退订由系统自动生成;用户点名的商品必须逐个原样放进 `products[].name`。
|
|
138
|
+
|
|
139
|
+
### 4.2 迁移现成 HTML
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
upload_image(url) # 图片先转 CDN(否则外链可能被邮箱客户端拦)
|
|
143
|
+
template_create(title=..., html=<整份 HTML,含 {Unsubscribe}>)
|
|
144
|
+
template_preview(id)
|
|
145
|
+
```
|
|
146
|
+
HTML 必须:内联样式、表格布局、含 `{Unsubscribe}`;正文过短会被质量闸门拒(活动 ≥4200 字符)。
|
|
147
|
+
|
|
148
|
+
### 4.3 按条件圈人(建分组)
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
1) group_catalog() # 数据域清单 + 通用规则(必做)
|
|
152
|
+
2) group_catalog(nested_path="success_checkout")# 该域真实字段 + 规则
|
|
153
|
+
3) user_group_create(name="高价值老客", query_content=<二维数组 JSON 字符串>)
|
|
154
|
+
4) group_list(keyword=...) # 等 dynamicStatus=complete 看 userCount(数十秒)
|
|
155
|
+
5) group_members(group_id=...) # 抽样看成员
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
条件写法见 `references/group-conditions.md`。最常见三条:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
// 近 30 天下过单
|
|
162
|
+
[[{"condition":"gte","field":"number","logic":"must","nestedPath":"success_checkout","script":false,"value":"1"},
|
|
163
|
+
{"condition":"gte","field":"date_day","logic":"must","nestedPath":"success_checkout","script":false,"value":"formerly:30"}]]
|
|
164
|
+
|
|
165
|
+
// 美国客户(基础属性,nestedPath 传空串)
|
|
166
|
+
[[{"condition":"term_query","field":"country","logic":"must","nestedPath":"","value":"US"}]]
|
|
167
|
+
|
|
168
|
+
// A 或 B:两个外层组("A或B"=[[A],[B]],不是 [[A,B]])
|
|
169
|
+
[[{...A...}],[{...B...}]]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 4.4 弃单挽回自动化(加购未购买)
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
1) flow_triggers() # 取 trigger_key 与 filters(真源,别猜)
|
|
176
|
+
2) flow_create(flow_name="弃单挽回 60 分钟",
|
|
177
|
+
trigger_key="join_cart", # 加购未购买 = 弃单;没有 abandon_checkout 这个 key
|
|
178
|
+
channel="Email",
|
|
179
|
+
delay_minutes=60, delay_unit="minute",
|
|
180
|
+
email_subject="Still thinking it over?",
|
|
181
|
+
email_content=<整份 HTML ≥3000 字符,含 {Unsubscribe}>,
|
|
182
|
+
exit_conditions=["checkout_started","order_placed"], # 发起结账/下单后不再发
|
|
183
|
+
frequency_type="inLast", frequency_value=7, frequency_unit="day") # 7 天内最多进一次
|
|
184
|
+
3) flow_list(keyword="弃单挽回") # 确认 status=draft、邮件节点 page.edition=richtext
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**触发器真源(15 个)**:`back_in_stock` `customer_created` `entered_segment` `exited_segment` `flow_notify`
|
|
188
|
+
`join_cart` `order_create` `order_fulfilled` `order_paid` `order_placed` `order_refunded` `order_status_change`
|
|
189
|
+
`subscribe` `viewed_page` `viewed_product`
|
|
190
|
+
|
|
191
|
+
- ⚠️ `abandon_checkout` **不是**触发器 key(它是分组条件里的数据域)——弃单流程用 `join_cart`
|
|
192
|
+
- 触发器名(`order_placed`/`join_cart` 等)也不能作为分组 `nestedPath`
|
|
193
|
+
- `exit_conditions` 合法值:`add_to_cart` / `checkout_started` / `order_placed` / `order_paid`
|
|
194
|
+
- `frequency_type`:`atTime`(只进一次)/ `inLast`(按间隔,需 `frequency_value`+`frequency_unit`=hour|day|week)/ `none`;不传默认「间隔 24 小时」
|
|
195
|
+
- 正文来源三选一:`email_content`(= `html`)/ `email_design` / `template_id`;多节点用 `steps`
|
|
196
|
+
- `trigger_filters` 传触发器过滤器(如 `cart_total`、`product`、`product-collection`,具体 key 见 `flow_triggers(trigger_key=...)`)
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 5. 报错速查
|
|
201
|
+
|
|
202
|
+
| 现象 | 原因 | 处理 |
|
|
203
|
+
|---|---|---|
|
|
204
|
+
| `authorization error (invalid basic auth data or API key)` | 密钥没填/填错/被重置 | 后台「店铺设置 → API 密钥」重新取 |
|
|
205
|
+
| `412 tool not allowed` | 工具不在放行白名单(如 `delete_campaign`) | 删除/发送/启用类能力刻意不开放,走后台 |
|
|
206
|
+
| `412 only draft can be modified (current status: sent)` | 改了非草稿对象 | 复制成新草稿再改 |
|
|
207
|
+
| `412 ... not found` | id 不属于当前店铺,或环境用混 | 核对 key 与 `MAMBA_API_BASE` |
|
|
208
|
+
| `412 正文质量校验未通过` | 太短/没 `{Unsubscribe}`/非英文 | 补内容模块、加退订、英文文案 |
|
|
209
|
+
| `412 分组条件校验未通过: 存在系统不支持的字段` | 编造了 field/nestedPath | 用 `group_catalog` 返回的真实字段重写 |
|
|
210
|
+
| `isError: 创建分组前必须先调用 group_catalog` | 跳过了目录查询 | 先查目录再建(30 分钟免再查) |
|
|
211
|
+
| `412 template is in use by N campaign/flow page(s)` | 模板被引用中 | 先在后台解除引用 |
|
|
212
|
+
| `500 unknown error` | 多为参数结构错误 | 对照 `mamba_tool_schema` 检查类型(数组/字符串) |
|
|
213
|
+
|
|
214
|
+
更多见 `references/troubleshooting.md`。
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 6. 交付口径(怎么向客户汇报)
|
|
219
|
+
|
|
220
|
+
- 建活动:`活动id` + `status=draft` + 受众(分组名/人数)+ 主题行 + 预览链接;**明确说明“需在后台确认后发送”**
|
|
221
|
+
- 建模板:`模板id` + 预览链接 + warnings(如有)
|
|
222
|
+
- 建分组:`分组id` + 条件摘要 + `userCount`(打包完成后)
|
|
223
|
+
- 查询类:给指标 + 时间窗(默认近 180 天)+ 口径(订单已排除取消单;余额为美元且 group 级)
|
|
224
|
+
- 永不承诺:已发送、已启用、已扣费、已删除已发送对象
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## 7. 参考文件
|
|
229
|
+
|
|
230
|
+
| 文件 | 内容 |
|
|
231
|
+
|---|---|
|
|
232
|
+
| `references/email-design.md` | emailDesign 全字段、硬规则、多版本、组件与折扣 |
|
|
233
|
+
| `references/group-conditions.md` | 条件二维结构、操作符白名单、时间写法、数据域与常见组合 |
|
|
234
|
+
| `references/tool-catalog.md` | 52 个工具的必填/可选参数清单 |
|
|
235
|
+
| `references/troubleshooting.md` | 报错、质量闸门、环境与限频、只读模式 |
|