@rune-kit/rune 2.10.0 → 2.11.0

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.
Files changed (205) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +8 -6
  3. package/commands/rune.md +168 -168
  4. package/contexts/dev.md +34 -34
  5. package/contexts/research.md +43 -43
  6. package/contexts/review.md +55 -55
  7. package/extensions/ai-ml/PACK.md +88 -88
  8. package/extensions/ai-ml/skills/ai-agents.md +172 -172
  9. package/extensions/ai-ml/skills/code-sandbox.md +187 -187
  10. package/extensions/ai-ml/skills/deep-research.md +146 -146
  11. package/extensions/ai-ml/skills/embedding-search.md +66 -66
  12. package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -74
  13. package/extensions/ai-ml/skills/llm-architect.md +125 -125
  14. package/extensions/ai-ml/skills/llm-integration.md +64 -64
  15. package/extensions/ai-ml/skills/prompt-patterns.md +72 -72
  16. package/extensions/ai-ml/skills/rag-patterns.md +66 -66
  17. package/extensions/ai-ml/skills/web-extraction.md +114 -114
  18. package/extensions/analytics/PACK.md +92 -92
  19. package/extensions/analytics/skills/ab-testing.md +72 -72
  20. package/extensions/analytics/skills/dashboard-patterns.md +83 -83
  21. package/extensions/analytics/skills/data-validation.md +68 -68
  22. package/extensions/analytics/skills/funnel-analysis.md +81 -81
  23. package/extensions/analytics/skills/sql-patterns.md +57 -57
  24. package/extensions/analytics/skills/statistical-analysis.md +79 -79
  25. package/extensions/analytics/skills/tracking-setup.md +71 -71
  26. package/extensions/backend/PACK.md +104 -104
  27. package/extensions/backend/skills/api-patterns.md +84 -84
  28. package/extensions/backend/skills/async-pipeline.md +193 -193
  29. package/extensions/backend/skills/auth-patterns.md +97 -97
  30. package/extensions/backend/skills/background-jobs.md +133 -133
  31. package/extensions/backend/skills/caching-patterns.md +108 -108
  32. package/extensions/backend/skills/cli-generation.md +133 -133
  33. package/extensions/backend/skills/database-patterns.md +87 -87
  34. package/extensions/backend/skills/middleware-patterns.md +104 -104
  35. package/extensions/chrome-ext/PACK.md +93 -93
  36. package/extensions/chrome-ext/skills/cws-preflight.md +143 -143
  37. package/extensions/chrome-ext/skills/cws-publish.md +104 -104
  38. package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -251
  39. package/extensions/chrome-ext/skills/ext-messaging.md +139 -139
  40. package/extensions/chrome-ext/skills/ext-storage.md +133 -133
  41. package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -164
  42. package/extensions/content/PACK.md +96 -96
  43. package/extensions/content/skills/blog-patterns.md +88 -88
  44. package/extensions/content/skills/cms-integration.md +131 -131
  45. package/extensions/content/skills/content-scoring.md +107 -107
  46. package/extensions/content/skills/i18n.md +83 -83
  47. package/extensions/content/skills/mdx-authoring.md +137 -137
  48. package/extensions/content/skills/reference.md +1014 -1014
  49. package/extensions/content/skills/seo-patterns.md +67 -67
  50. package/extensions/content/skills/video-repurpose.md +153 -153
  51. package/extensions/devops/PACK.md +101 -101
  52. package/extensions/devops/skills/chaos-testing.md +67 -67
  53. package/extensions/devops/skills/ci-cd.md +75 -75
  54. package/extensions/devops/skills/docker.md +58 -58
  55. package/extensions/devops/skills/edge-serverless.md +163 -163
  56. package/extensions/devops/skills/infra-as-code.md +158 -158
  57. package/extensions/devops/skills/kubernetes.md +110 -110
  58. package/extensions/devops/skills/monitoring.md +57 -57
  59. package/extensions/devops/skills/server-setup.md +64 -64
  60. package/extensions/devops/skills/ssl-domain.md +42 -42
  61. package/extensions/ecommerce/PACK.md +116 -116
  62. package/extensions/ecommerce/skills/cart-system.md +79 -79
  63. package/extensions/ecommerce/skills/inventory-mgmt.md +102 -102
  64. package/extensions/ecommerce/skills/order-management.md +126 -126
  65. package/extensions/ecommerce/skills/payment-integration.md +472 -472
  66. package/extensions/ecommerce/skills/shopify-dev.md +69 -69
  67. package/extensions/ecommerce/skills/subscription-billing.md +93 -93
  68. package/extensions/ecommerce/skills/tax-compliance.md +117 -117
  69. package/extensions/gamedev/PACK.md +142 -142
  70. package/extensions/gamedev/skills/asset-pipeline.md +74 -74
  71. package/extensions/gamedev/skills/audio-system.md +129 -129
  72. package/extensions/gamedev/skills/camera-system.md +87 -87
  73. package/extensions/gamedev/skills/ecs.md +98 -98
  74. package/extensions/gamedev/skills/game-loops.md +72 -72
  75. package/extensions/gamedev/skills/input-system.md +199 -199
  76. package/extensions/gamedev/skills/multiplayer.md +180 -180
  77. package/extensions/gamedev/skills/particles.md +105 -105
  78. package/extensions/gamedev/skills/physics-engine.md +89 -89
  79. package/extensions/gamedev/skills/scene-management.md +146 -146
  80. package/extensions/gamedev/skills/threejs-patterns.md +90 -90
  81. package/extensions/gamedev/skills/webgl.md +71 -71
  82. package/extensions/mobile/PACK.md +106 -106
  83. package/extensions/mobile/skills/app-store-connect.md +152 -152
  84. package/extensions/mobile/skills/app-store-prep.md +66 -66
  85. package/extensions/mobile/skills/deep-linking.md +109 -109
  86. package/extensions/mobile/skills/flutter.md +60 -60
  87. package/extensions/mobile/skills/ios-build-pipeline.md +142 -142
  88. package/extensions/mobile/skills/native-bridge.md +66 -66
  89. package/extensions/mobile/skills/ota-updates.md +97 -97
  90. package/extensions/mobile/skills/push-notifications.md +111 -111
  91. package/extensions/mobile/skills/react-native.md +82 -82
  92. package/extensions/saas/PACK.md +116 -116
  93. package/extensions/saas/skills/billing-integration.md +200 -200
  94. package/extensions/saas/skills/feature-flags.md +130 -130
  95. package/extensions/saas/skills/multi-tenant.md +103 -103
  96. package/extensions/saas/skills/onboarding-flow.md +139 -139
  97. package/extensions/saas/skills/subscription-flow.md +95 -95
  98. package/extensions/saas/skills/team-management.md +144 -144
  99. package/extensions/security/PACK.md +99 -99
  100. package/extensions/security/skills/api-security.md +140 -140
  101. package/extensions/security/skills/compliance.md +68 -68
  102. package/extensions/security/skills/owasp-audit.md +64 -64
  103. package/extensions/security/skills/pentest-patterns.md +77 -77
  104. package/extensions/security/skills/secret-mgmt.md +65 -65
  105. package/extensions/security/skills/supply-chain.md +65 -65
  106. package/extensions/trading/PACK.md +80 -80
  107. package/extensions/trading/skills/chart-components.md +55 -55
  108. package/extensions/trading/skills/experiment-loop.md +125 -125
  109. package/extensions/trading/skills/fintech-patterns.md +47 -47
  110. package/extensions/trading/skills/indicator-library.md +58 -58
  111. package/extensions/trading/skills/quant-analysis.md +111 -111
  112. package/extensions/trading/skills/realtime-data.md +58 -58
  113. package/extensions/trading/skills/trade-logic.md +104 -104
  114. package/extensions/ui/PACK.md +130 -130
  115. package/extensions/ui/skills/a11y-audit.md +91 -91
  116. package/extensions/ui/skills/animation-patterns.md +127 -127
  117. package/extensions/ui/skills/component-patterns.md +100 -100
  118. package/extensions/ui/skills/design-decision.md +108 -108
  119. package/extensions/ui/skills/design-system.md +68 -68
  120. package/extensions/ui/skills/landing-patterns.md +155 -155
  121. package/extensions/ui/skills/palette-picker.md +173 -173
  122. package/extensions/ui/skills/react-health.md +90 -90
  123. package/extensions/ui/skills/type-system.md +125 -125
  124. package/extensions/ui/skills/web-vitals.md +153 -153
  125. package/extensions/zalo/PACK.md +145 -145
  126. package/extensions/zalo/skills/zalo-oa-mcp.md +317 -317
  127. package/extensions/zalo/skills/zalo-oa-messaging.md +429 -429
  128. package/extensions/zalo/skills/zalo-oa-setup.md +236 -236
  129. package/extensions/zalo/skills/zalo-oa-webhook.md +189 -189
  130. package/extensions/zalo/skills/zalo-personal-messaging.md +194 -194
  131. package/extensions/zalo/skills/zalo-personal-setup.md +153 -153
  132. package/extensions/zalo/skills/zalo-rate-guard.md +219 -219
  133. package/hooks/auto-format/index.cjs +48 -48
  134. package/hooks/hooks.json +111 -111
  135. package/hooks/post-session-reflect/index.cjs +189 -189
  136. package/hooks/pre-compact/index.cjs +95 -95
  137. package/hooks/run-hook.cmd +1 -1
  138. package/hooks/secrets-scan/index.cjs +100 -100
  139. package/hooks/session-start/index.cjs +71 -71
  140. package/hooks/typecheck/index.cjs +65 -65
  141. package/package.json +63 -63
  142. package/references/ui-pro-max-data/LICENSE-UI-PRO-MAX +21 -21
  143. package/references/ui-pro-max-data/charts.csv +26 -26
  144. package/references/ui-pro-max-data/colors.csv +161 -161
  145. package/references/ui-pro-max-data/styles.csv +68 -68
  146. package/references/ui-pro-max-data/typography.csv +74 -74
  147. package/references/ui-pro-max-data/ui-reasoning.csv +162 -162
  148. package/references/ui-pro-max-data/ux-guidelines.csv +99 -99
  149. package/skills/adversary/SKILL.md +283 -283
  150. package/skills/asset-creator/SKILL.md +157 -157
  151. package/skills/audit/SKILL.md +147 -2
  152. package/skills/autopsy/SKILL.md +335 -335
  153. package/skills/brainstorm/SKILL.md +342 -342
  154. package/skills/browser-pilot/SKILL.md +168 -168
  155. package/skills/constraint-check/SKILL.md +165 -165
  156. package/skills/context-engine/SKILL.md +404 -404
  157. package/skills/cook/SKILL.md +917 -863
  158. package/skills/db/SKILL.md +273 -273
  159. package/skills/debug/SKILL.md +465 -465
  160. package/skills/dependency-doctor/SKILL.md +265 -235
  161. package/skills/deploy/SKILL.md +274 -231
  162. package/skills/design/DESIGN-REFERENCE.md +365 -365
  163. package/skills/design/SKILL.md +589 -589
  164. package/skills/doc-processor/SKILL.md +254 -254
  165. package/skills/docs/SKILL.md +374 -374
  166. package/skills/docs-seeker/SKILL.md +177 -177
  167. package/skills/fix/SKILL.md +330 -330
  168. package/skills/git/SKILL.md +339 -339
  169. package/skills/hallucination-guard/SKILL.md +219 -219
  170. package/skills/incident/SKILL.md +254 -253
  171. package/skills/integrity-check/SKILL.md +169 -169
  172. package/skills/journal/SKILL.md +240 -240
  173. package/skills/launch/SKILL.md +344 -344
  174. package/skills/logic-guardian/SKILL.md +251 -251
  175. package/skills/marketing/SKILL.md +290 -289
  176. package/skills/mcp-builder/SKILL.md +425 -425
  177. package/skills/neural-memory/SKILL.md +362 -362
  178. package/skills/onboard/SKILL.md +404 -403
  179. package/skills/perf/SKILL.md +346 -346
  180. package/skills/plan/SKILL.md +433 -428
  181. package/skills/preflight/SKILL.md +415 -415
  182. package/skills/problem-solver/SKILL.md +380 -284
  183. package/skills/rescue/SKILL.md +474 -474
  184. package/skills/retro/SKILL.md +3 -1
  185. package/skills/review/SKILL.md +612 -588
  186. package/skills/review-intake/SKILL.md +249 -249
  187. package/skills/safeguard/SKILL.md +200 -200
  188. package/skills/sast/SKILL.md +190 -190
  189. package/skills/scaffold/SKILL.md +328 -287
  190. package/skills/scope-guard/SKILL.md +180 -180
  191. package/skills/scout/SKILL.md +263 -263
  192. package/skills/sentinel/SKILL.md +382 -381
  193. package/skills/sentinel-env/SKILL.md +254 -254
  194. package/skills/sequential-thinking/SKILL.md +234 -234
  195. package/skills/session-bridge/SKILL.md +543 -543
  196. package/skills/skill-forge/SKILL.md +581 -581
  197. package/skills/skill-router/SKILL.md +3 -0
  198. package/skills/surgeon/SKILL.md +215 -215
  199. package/skills/team/SKILL.md +556 -537
  200. package/skills/test/SKILL.md +614 -614
  201. package/skills/trend-scout/SKILL.md +145 -145
  202. package/skills/verification/SKILL.md +326 -326
  203. package/skills/video-creator/SKILL.md +201 -201
  204. package/skills/watchdog/SKILL.md +168 -168
  205. package/skills/worktree/SKILL.md +140 -140
@@ -1,429 +1,429 @@
1
- ---
2
- name: zalo-oa-messaging
3
- pack: "@rune/zalo"
4
- description: All 8 OA message types (text, image, file, sticker, list, template, transaction, promotion), follower management, and broadcast with demographic targeting.
5
- model: sonnet
6
- tools: "Read, Glob, Grep, Bash, Write, Edit"
7
- ---
8
-
9
- # zalo-oa-messaging
10
-
11
- Send any of the 8 Zalo OA message types, manage followers, and run broadcast campaigns via the v3 Official Account API.
12
-
13
- ## Base Config
14
-
15
- ```
16
- Base URL : https://openapi.zalo.me/v3.0/oa
17
- Upload : https://openapi.zalo.me/v2.0/oa (intentional version mismatch)
18
- Auth : Authorization: Bearer {oa_access_token}
19
- Content : Content-Type: application/json
20
- Endpoint : POST /message/cs (all 8 CS message types)
21
- ```
22
-
23
- ## Step 1 — Identify the Message Type
24
-
25
- | # | Type | Use Case | Constraint |
26
- |---|------|----------|------------|
27
- | 1 | Text | Simple reply, notification | 2000 char limit |
28
- | 2 | Image | Product photo, banner | attachment_id from upload |
29
- | 3 | File | PDF, invoice, document | attachment_id from upload |
30
- | 4 | Sticker | Friendly interaction | sticker_id from catalog |
31
- | 5 | List | Menu, product listing | max 10 items |
32
- | 6 | Template | CTA with buttons | max 5 buttons |
33
- | 7 | Transaction | Order/shipping update | pre-approved template required |
34
- | 8 | Promotion | Marketing campaign | approved template + quota |
35
-
36
- **All CS messages**: only sendable within 7 days of user's last interaction with the OA.
37
-
38
- ---
39
-
40
- ## Step 2 — Send the Right Payload
41
-
42
- ### Type 1 — Text Message
43
-
44
- ```http
45
- POST https://openapi.zalo.me/v3.0/oa/message/cs
46
- Authorization: Bearer {oa_access_token}
47
-
48
- {
49
- "recipient": { "user_id": "4337842264521611405" },
50
- "message": { "text": "Xin chào! Chúng tôi có thể giúp gì cho bạn?" }
51
- }
52
- ```
53
-
54
- Response (success):
55
- ```json
56
- { "error": 0, "message": "Success", "data": { "message_id": "oaMsgId.567890" } }
57
- ```
58
-
59
- ---
60
-
61
- ### Type 2 — Image Message
62
-
63
- Upload first (v2.0 endpoint), then send:
64
-
65
- ```http
66
- POST https://openapi.zalo.me/v2.0/oa/upload/image
67
- Authorization: Bearer {oa_access_token}
68
- Content-Type: multipart/form-data
69
-
70
- file=@banner.jpg (max 1MB)
71
- ```
72
-
73
- ```json
74
- { "error": 0, "data": { "attachment_id": "f8d5a7e1-2b3c-4d5e-8f9a-1b2c3d4e5f6a" } }
75
- ```
76
-
77
- Then send:
78
-
79
- ```json
80
- {
81
- "recipient": { "user_id": "4337842264521611405" },
82
- "message": {
83
- "attachment": {
84
- "type": "template",
85
- "payload": {
86
- "template_type": "media",
87
- "elements": [{
88
- "media_type": "image",
89
- "attachment_id": "f8d5a7e1-2b3c-4d5e-8f9a-1b2c3d4e5f6a"
90
- }]
91
- }
92
- }
93
- }
94
- }
95
- ```
96
-
97
- ---
98
-
99
- ### Type 3 — File Message
100
-
101
- ```http
102
- POST https://openapi.zalo.me/v2.0/oa/upload/file
103
- Authorization: Bearer {oa_access_token}
104
- Content-Type: multipart/form-data
105
-
106
- file=@invoice.pdf (max 5MB)
107
- ```
108
-
109
- ```json
110
- { "error": 0, "data": { "attachment_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890" } }
111
- ```
112
-
113
- Send payload same shape as image but `"media_type": "file"`.
114
-
115
- ---
116
-
117
- ### Type 4 — Sticker Message
118
-
119
- ```json
120
- {
121
- "recipient": { "user_id": "4337842264521611405" },
122
- "message": {
123
- "attachment": {
124
- "type": "template",
125
- "payload": {
126
- "template_type": "media",
127
- "elements": [{ "media_type": "sticker", "attachment_id": "87521" }]
128
- }
129
- }
130
- }
131
- }
132
- ```
133
-
134
- Sticker IDs: fetch from Zalo sticker catalog. Common IDs: 87521 (thumbs up), 87522 (heart), 87523 (smile).
135
-
136
- ---
137
-
138
- ### Type 5 — List Message
139
-
140
- ```json
141
- {
142
- "recipient": { "user_id": "4337842264521611405" },
143
- "message": {
144
- "attachment": {
145
- "type": "template",
146
- "payload": {
147
- "template_type": "list",
148
- "elements": [
149
- {
150
- "title": "Sản phẩm A",
151
- "subtitle": "Giá: 299.000đ",
152
- "image_url": "https://cdn.example.com/product-a.jpg",
153
- "default_action": { "type": "oa.open.url", "url": "https://example.com/product-a" }
154
- },
155
- {
156
- "title": "Sản phẩm B",
157
- "subtitle": "Giá: 199.000đ",
158
- "image_url": "https://cdn.example.com/product-b.jpg",
159
- "default_action": { "type": "oa.open.url", "url": "https://example.com/product-b" }
160
- }
161
- ],
162
- "buttons": [{
163
- "title": "Xem tất cả sản phẩm",
164
- "type": "oa.open.url",
165
- "payload": { "url": "https://example.com/products" }
166
- }]
167
- }
168
- }
169
- }
170
- }
171
- ```
172
-
173
- Limits: max 10 elements, max 5 buttons at bottom.
174
-
175
- ---
176
-
177
- ### Type 6 — Template Message (Button Template)
178
-
179
- ```json
180
- {
181
- "recipient": { "user_id": "4337842264521611405" },
182
- "message": {
183
- "attachment": {
184
- "type": "template",
185
- "payload": {
186
- "template_type": "button",
187
- "text": "Chọn hành động bạn muốn thực hiện:",
188
- "buttons": [
189
- {
190
- "title": "Xem đơn hàng",
191
- "type": "oa.open.url",
192
- "payload": { "url": "https://example.com/orders" }
193
- },
194
- {
195
- "title": "Gọi hỗ trợ",
196
- "type": "oa.open.phone",
197
- "payload": { "phone_code": "0901234567" }
198
- },
199
- {
200
- "title": "Theo dõi vận chuyển",
201
- "type": "oa.query.show",
202
- "payload": { "content": "TRACK_ORDER_12345" }
203
- }
204
- ]
205
- }
206
- }
207
- }
208
- }
209
- ```
210
-
211
- Button types: `oa.open.url`, `oa.open.phone`, `oa.query.show` (postback), `oa.open.sms`.
212
-
213
- ---
214
-
215
- ### Type 7 — Transaction Message
216
-
217
- Requires a pre-approved template from Zalo OA portal. Cannot send arbitrary content.
218
-
219
- ```json
220
- {
221
- "recipient": { "user_id": "4337842264521611405" },
222
- "message": {
223
- "attachment": {
224
- "type": "template",
225
- "payload": {
226
- "template_type": "transaction_order",
227
- "language": "VI",
228
- "elements": [{
229
- "attachment_id": "approved-template-id-from-zalo",
230
- "type": "banner"
231
- }],
232
- "parameters": {
233
- "order_id": "ORD-2026-001234",
234
- "order_status": "Đã giao hàng",
235
- "delivery_date": "15/03/2026",
236
- "tracking_url": "https://example.com/track/ORD-2026-001234"
237
- }
238
- }
239
- }
240
- }
241
- }
242
- ```
243
-
244
- Template must match an approved template ID. Parameter keys defined by the template.
245
-
246
- ---
247
-
248
- ### Type 8 — Promotion Message
249
-
250
- Requires approved template + sufficient broadcast quota.
251
-
252
- ```json
253
- {
254
- "recipient": { "user_id": "4337842264521611405" },
255
- "message": {
256
- "attachment": {
257
- "type": "template",
258
- "payload": {
259
- "template_type": "promotion",
260
- "language": "VI",
261
- "elements": [{
262
- "attachment_id": "approved-promo-banner-id",
263
- "type": "banner"
264
- }],
265
- "parameters": {
266
- "coupon_code": "SALE30",
267
- "discount": "30%",
268
- "expiry": "31/03/2026"
269
- }
270
- }
271
- }
272
- }
273
- }
274
- ```
275
-
276
- ---
277
-
278
- ## Step 3 — Long Text Chunking
279
-
280
- Text limit is 2000 chars. Chunk before sending:
281
-
282
- ```typescript
283
- function chunkMessage(text: string, limit = 2000): string[] {
284
- if (text.length <= limit) return [text]
285
- const chunks: string[] = []
286
- let remaining = text
287
- while (remaining.length > 0) {
288
- if (remaining.length <= limit) { chunks.push(remaining); break }
289
- let splitAt = remaining.lastIndexOf('\n', limit)
290
- if (splitAt === -1) splitAt = remaining.lastIndexOf(' ', limit)
291
- if (splitAt === -1) splitAt = limit
292
- chunks.push(remaining.slice(0, splitAt))
293
- remaining = remaining.slice(splitAt).trimStart()
294
- }
295
- return chunks
296
- }
297
-
298
- // Send each chunk with delay to respect rate limits
299
- for (const chunk of chunkMessage(longText)) {
300
- await sendTextMessage(userId, chunk)
301
- await new Promise(r => setTimeout(r, 300))
302
- }
303
- ```
304
-
305
- ---
306
-
307
- ## Step 4 — Follower Management
308
-
309
- ### List Followers
310
-
311
- ```http
312
- GET https://openapi.zalo.me/v3.0/oa/user/getlist?offset=0&count=50
313
- Authorization: Bearer {oa_access_token}
314
- ```
315
-
316
- ```json
317
- {
318
- "error": 0,
319
- "data": {
320
- "users": [
321
- { "user_id": "4337842264521611405", "display_name": "Nguyen Van A", "followed_date": 1709827200 }
322
- ],
323
- "total": 1250,
324
- "offset": 0,
325
- "count": 50
326
- }
327
- }
328
- ```
329
-
330
- Paginate: increment `offset` by `count` until `offset >= total`.
331
-
332
- ### User Profile
333
-
334
- ```http
335
- GET https://openapi.zalo.me/v3.0/oa/user/detail?user_id=4337842264521611405
336
- Authorization: Bearer {oa_access_token}
337
- ```
338
-
339
- ```json
340
- {
341
- "error": 0,
342
- "data": {
343
- "user_id": "4337842264521611405",
344
- "display_name": "Nguyen Van A",
345
- "birth_date": 0,
346
- "gender": 1,
347
- "phone": "",
348
- "city": "Ho Chi Minh City",
349
- "district": "",
350
- "tags_and_notes_info": { "tag_names": ["VIP", "Repeat-buyer"] }
351
- }
352
- }
353
- ```
354
-
355
- Note: `user_id` is OA-scoped — same person has a different `user_id` for each OA they follow.
356
-
357
- ### Tag Management
358
-
359
- ```http
360
- POST https://openapi.zalo.me/v3.0/oa/tag/tagfollower
361
- Authorization: Bearer {oa_access_token}
362
-
363
- { "user_id": "4337842264521611405", "tag_name": "VIP" }
364
- ```
365
-
366
- ```http
367
- POST https://openapi.zalo.me/v3.0/oa/tag/rmfollowerfromtag
368
- Authorization: Bearer {oa_access_token}
369
-
370
- { "user_id": "4337842264521611405", "tag_name": "VIP" }
371
- ```
372
-
373
- ---
374
-
375
- ## Step 5 — Broadcast
376
-
377
- ```http
378
- POST https://openapi.zalo.me/v3.0/oa/message/promotion
379
- Authorization: Bearer {oa_access_token}
380
-
381
- {
382
- "recipient": {
383
- "target": {
384
- "gender": 1,
385
- "ages": ["18-25", "26-35"],
386
- "cities": ["Ho Chi Minh City", "Ha Noi"],
387
- "platforms": ["iOS", "Android"],
388
- "telcos": ["Viettel", "Mobifone"]
389
- }
390
- },
391
- "message": {
392
- "attachment": {
393
- "type": "template",
394
- "payload": {
395
- "template_type": "promotion",
396
- "language": "VI",
397
- "elements": [{ "attachment_id": "approved-promo-banner-id", "type": "banner" }],
398
- "parameters": { "coupon_code": "SUMMER30", "discount": "30%" }
399
- }
400
- }
401
- }
402
- }
403
- ```
404
-
405
- Response includes estimated reach count before send is confirmed. Quota resets monthly.
406
-
407
- ---
408
-
409
- ## Sharp Edges
410
-
411
- - **7-day CS window** — `error: 12` means the user hasn't interacted in 7 days. Cannot bypass. Solution: use Transaction or Promotion templates (pre-approved) which ignore the window.
412
- - **Version mismatch is intentional** — upload endpoints stay on `v2.0`, message send is `v3.0`. Do not "fix" this.
413
- - **OA-scoped user_id** — never assume the same physical person has the same `user_id` across different OAs. Always store per-OA.
414
- - **Template approval lag** — Transaction/Promotion templates take 1-5 business days to approve. Plan ahead; cannot substitute with CS messages after approval delay.
415
- - **Image 1MB / File 5MB hard limits** — compress images server-side before upload. Zalo returns `error: 201` for oversized files.
416
- - **Broadcast quota** — based on follower count × OA verification tier. Track monthly usage; `error: 133` = quota exceeded.
417
- - **Button limit 5** — template messages silently drop buttons beyond index 4. Always validate `buttons.length <= 5` before sending.
418
-
419
- ## Error Codes Quick Reference
420
-
421
- | Code | Meaning | Fix |
422
- |------|---------|-----|
423
- | 0 | Success | — |
424
- | 12 | Outside 7-day CS window | Use approved template type |
425
- | 14 | Invalid access token | Refresh token, retry |
426
- | 107 | Invalid recipient | Verify user_id is OA-scoped and valid |
427
- | 133 | Broadcast quota exceeded | Wait for monthly reset |
428
- | 201 | File size exceeded | Compress/split before upload |
429
- | 216 | Template not approved | Submit template for Zalo review |
1
+ ---
2
+ name: zalo-oa-messaging
3
+ pack: "@rune/zalo"
4
+ description: All 8 OA message types (text, image, file, sticker, list, template, transaction, promotion), follower management, and broadcast with demographic targeting.
5
+ model: sonnet
6
+ tools: "Read, Glob, Grep, Bash, Write, Edit"
7
+ ---
8
+
9
+ # zalo-oa-messaging
10
+
11
+ Send any of the 8 Zalo OA message types, manage followers, and run broadcast campaigns via the v3 Official Account API.
12
+
13
+ ## Base Config
14
+
15
+ ```
16
+ Base URL : https://openapi.zalo.me/v3.0/oa
17
+ Upload : https://openapi.zalo.me/v2.0/oa (intentional version mismatch)
18
+ Auth : Authorization: Bearer {oa_access_token}
19
+ Content : Content-Type: application/json
20
+ Endpoint : POST /message/cs (all 8 CS message types)
21
+ ```
22
+
23
+ ## Step 1 — Identify the Message Type
24
+
25
+ | # | Type | Use Case | Constraint |
26
+ |---|------|----------|------------|
27
+ | 1 | Text | Simple reply, notification | 2000 char limit |
28
+ | 2 | Image | Product photo, banner | attachment_id from upload |
29
+ | 3 | File | PDF, invoice, document | attachment_id from upload |
30
+ | 4 | Sticker | Friendly interaction | sticker_id from catalog |
31
+ | 5 | List | Menu, product listing | max 10 items |
32
+ | 6 | Template | CTA with buttons | max 5 buttons |
33
+ | 7 | Transaction | Order/shipping update | pre-approved template required |
34
+ | 8 | Promotion | Marketing campaign | approved template + quota |
35
+
36
+ **All CS messages**: only sendable within 7 days of user's last interaction with the OA.
37
+
38
+ ---
39
+
40
+ ## Step 2 — Send the Right Payload
41
+
42
+ ### Type 1 — Text Message
43
+
44
+ ```http
45
+ POST https://openapi.zalo.me/v3.0/oa/message/cs
46
+ Authorization: Bearer {oa_access_token}
47
+
48
+ {
49
+ "recipient": { "user_id": "4337842264521611405" },
50
+ "message": { "text": "Xin chào! Chúng tôi có thể giúp gì cho bạn?" }
51
+ }
52
+ ```
53
+
54
+ Response (success):
55
+ ```json
56
+ { "error": 0, "message": "Success", "data": { "message_id": "oaMsgId.567890" } }
57
+ ```
58
+
59
+ ---
60
+
61
+ ### Type 2 — Image Message
62
+
63
+ Upload first (v2.0 endpoint), then send:
64
+
65
+ ```http
66
+ POST https://openapi.zalo.me/v2.0/oa/upload/image
67
+ Authorization: Bearer {oa_access_token}
68
+ Content-Type: multipart/form-data
69
+
70
+ file=@banner.jpg (max 1MB)
71
+ ```
72
+
73
+ ```json
74
+ { "error": 0, "data": { "attachment_id": "f8d5a7e1-2b3c-4d5e-8f9a-1b2c3d4e5f6a" } }
75
+ ```
76
+
77
+ Then send:
78
+
79
+ ```json
80
+ {
81
+ "recipient": { "user_id": "4337842264521611405" },
82
+ "message": {
83
+ "attachment": {
84
+ "type": "template",
85
+ "payload": {
86
+ "template_type": "media",
87
+ "elements": [{
88
+ "media_type": "image",
89
+ "attachment_id": "f8d5a7e1-2b3c-4d5e-8f9a-1b2c3d4e5f6a"
90
+ }]
91
+ }
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ---
98
+
99
+ ### Type 3 — File Message
100
+
101
+ ```http
102
+ POST https://openapi.zalo.me/v2.0/oa/upload/file
103
+ Authorization: Bearer {oa_access_token}
104
+ Content-Type: multipart/form-data
105
+
106
+ file=@invoice.pdf (max 5MB)
107
+ ```
108
+
109
+ ```json
110
+ { "error": 0, "data": { "attachment_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890" } }
111
+ ```
112
+
113
+ Send payload same shape as image but `"media_type": "file"`.
114
+
115
+ ---
116
+
117
+ ### Type 4 — Sticker Message
118
+
119
+ ```json
120
+ {
121
+ "recipient": { "user_id": "4337842264521611405" },
122
+ "message": {
123
+ "attachment": {
124
+ "type": "template",
125
+ "payload": {
126
+ "template_type": "media",
127
+ "elements": [{ "media_type": "sticker", "attachment_id": "87521" }]
128
+ }
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ Sticker IDs: fetch from Zalo sticker catalog. Common IDs: 87521 (thumbs up), 87522 (heart), 87523 (smile).
135
+
136
+ ---
137
+
138
+ ### Type 5 — List Message
139
+
140
+ ```json
141
+ {
142
+ "recipient": { "user_id": "4337842264521611405" },
143
+ "message": {
144
+ "attachment": {
145
+ "type": "template",
146
+ "payload": {
147
+ "template_type": "list",
148
+ "elements": [
149
+ {
150
+ "title": "Sản phẩm A",
151
+ "subtitle": "Giá: 299.000đ",
152
+ "image_url": "https://cdn.example.com/product-a.jpg",
153
+ "default_action": { "type": "oa.open.url", "url": "https://example.com/product-a" }
154
+ },
155
+ {
156
+ "title": "Sản phẩm B",
157
+ "subtitle": "Giá: 199.000đ",
158
+ "image_url": "https://cdn.example.com/product-b.jpg",
159
+ "default_action": { "type": "oa.open.url", "url": "https://example.com/product-b" }
160
+ }
161
+ ],
162
+ "buttons": [{
163
+ "title": "Xem tất cả sản phẩm",
164
+ "type": "oa.open.url",
165
+ "payload": { "url": "https://example.com/products" }
166
+ }]
167
+ }
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ Limits: max 10 elements, max 5 buttons at bottom.
174
+
175
+ ---
176
+
177
+ ### Type 6 — Template Message (Button Template)
178
+
179
+ ```json
180
+ {
181
+ "recipient": { "user_id": "4337842264521611405" },
182
+ "message": {
183
+ "attachment": {
184
+ "type": "template",
185
+ "payload": {
186
+ "template_type": "button",
187
+ "text": "Chọn hành động bạn muốn thực hiện:",
188
+ "buttons": [
189
+ {
190
+ "title": "Xem đơn hàng",
191
+ "type": "oa.open.url",
192
+ "payload": { "url": "https://example.com/orders" }
193
+ },
194
+ {
195
+ "title": "Gọi hỗ trợ",
196
+ "type": "oa.open.phone",
197
+ "payload": { "phone_code": "0901234567" }
198
+ },
199
+ {
200
+ "title": "Theo dõi vận chuyển",
201
+ "type": "oa.query.show",
202
+ "payload": { "content": "TRACK_ORDER_12345" }
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ }
208
+ }
209
+ ```
210
+
211
+ Button types: `oa.open.url`, `oa.open.phone`, `oa.query.show` (postback), `oa.open.sms`.
212
+
213
+ ---
214
+
215
+ ### Type 7 — Transaction Message
216
+
217
+ Requires a pre-approved template from Zalo OA portal. Cannot send arbitrary content.
218
+
219
+ ```json
220
+ {
221
+ "recipient": { "user_id": "4337842264521611405" },
222
+ "message": {
223
+ "attachment": {
224
+ "type": "template",
225
+ "payload": {
226
+ "template_type": "transaction_order",
227
+ "language": "VI",
228
+ "elements": [{
229
+ "attachment_id": "approved-template-id-from-zalo",
230
+ "type": "banner"
231
+ }],
232
+ "parameters": {
233
+ "order_id": "ORD-2026-001234",
234
+ "order_status": "Đã giao hàng",
235
+ "delivery_date": "15/03/2026",
236
+ "tracking_url": "https://example.com/track/ORD-2026-001234"
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+ ```
243
+
244
+ Template must match an approved template ID. Parameter keys defined by the template.
245
+
246
+ ---
247
+
248
+ ### Type 8 — Promotion Message
249
+
250
+ Requires approved template + sufficient broadcast quota.
251
+
252
+ ```json
253
+ {
254
+ "recipient": { "user_id": "4337842264521611405" },
255
+ "message": {
256
+ "attachment": {
257
+ "type": "template",
258
+ "payload": {
259
+ "template_type": "promotion",
260
+ "language": "VI",
261
+ "elements": [{
262
+ "attachment_id": "approved-promo-banner-id",
263
+ "type": "banner"
264
+ }],
265
+ "parameters": {
266
+ "coupon_code": "SALE30",
267
+ "discount": "30%",
268
+ "expiry": "31/03/2026"
269
+ }
270
+ }
271
+ }
272
+ }
273
+ }
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Step 3 — Long Text Chunking
279
+
280
+ Text limit is 2000 chars. Chunk before sending:
281
+
282
+ ```typescript
283
+ function chunkMessage(text: string, limit = 2000): string[] {
284
+ if (text.length <= limit) return [text]
285
+ const chunks: string[] = []
286
+ let remaining = text
287
+ while (remaining.length > 0) {
288
+ if (remaining.length <= limit) { chunks.push(remaining); break }
289
+ let splitAt = remaining.lastIndexOf('\n', limit)
290
+ if (splitAt === -1) splitAt = remaining.lastIndexOf(' ', limit)
291
+ if (splitAt === -1) splitAt = limit
292
+ chunks.push(remaining.slice(0, splitAt))
293
+ remaining = remaining.slice(splitAt).trimStart()
294
+ }
295
+ return chunks
296
+ }
297
+
298
+ // Send each chunk with delay to respect rate limits
299
+ for (const chunk of chunkMessage(longText)) {
300
+ await sendTextMessage(userId, chunk)
301
+ await new Promise(r => setTimeout(r, 300))
302
+ }
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Step 4 — Follower Management
308
+
309
+ ### List Followers
310
+
311
+ ```http
312
+ GET https://openapi.zalo.me/v3.0/oa/user/getlist?offset=0&count=50
313
+ Authorization: Bearer {oa_access_token}
314
+ ```
315
+
316
+ ```json
317
+ {
318
+ "error": 0,
319
+ "data": {
320
+ "users": [
321
+ { "user_id": "4337842264521611405", "display_name": "Nguyen Van A", "followed_date": 1709827200 }
322
+ ],
323
+ "total": 1250,
324
+ "offset": 0,
325
+ "count": 50
326
+ }
327
+ }
328
+ ```
329
+
330
+ Paginate: increment `offset` by `count` until `offset >= total`.
331
+
332
+ ### User Profile
333
+
334
+ ```http
335
+ GET https://openapi.zalo.me/v3.0/oa/user/detail?user_id=4337842264521611405
336
+ Authorization: Bearer {oa_access_token}
337
+ ```
338
+
339
+ ```json
340
+ {
341
+ "error": 0,
342
+ "data": {
343
+ "user_id": "4337842264521611405",
344
+ "display_name": "Nguyen Van A",
345
+ "birth_date": 0,
346
+ "gender": 1,
347
+ "phone": "",
348
+ "city": "Ho Chi Minh City",
349
+ "district": "",
350
+ "tags_and_notes_info": { "tag_names": ["VIP", "Repeat-buyer"] }
351
+ }
352
+ }
353
+ ```
354
+
355
+ Note: `user_id` is OA-scoped — same person has a different `user_id` for each OA they follow.
356
+
357
+ ### Tag Management
358
+
359
+ ```http
360
+ POST https://openapi.zalo.me/v3.0/oa/tag/tagfollower
361
+ Authorization: Bearer {oa_access_token}
362
+
363
+ { "user_id": "4337842264521611405", "tag_name": "VIP" }
364
+ ```
365
+
366
+ ```http
367
+ POST https://openapi.zalo.me/v3.0/oa/tag/rmfollowerfromtag
368
+ Authorization: Bearer {oa_access_token}
369
+
370
+ { "user_id": "4337842264521611405", "tag_name": "VIP" }
371
+ ```
372
+
373
+ ---
374
+
375
+ ## Step 5 — Broadcast
376
+
377
+ ```http
378
+ POST https://openapi.zalo.me/v3.0/oa/message/promotion
379
+ Authorization: Bearer {oa_access_token}
380
+
381
+ {
382
+ "recipient": {
383
+ "target": {
384
+ "gender": 1,
385
+ "ages": ["18-25", "26-35"],
386
+ "cities": ["Ho Chi Minh City", "Ha Noi"],
387
+ "platforms": ["iOS", "Android"],
388
+ "telcos": ["Viettel", "Mobifone"]
389
+ }
390
+ },
391
+ "message": {
392
+ "attachment": {
393
+ "type": "template",
394
+ "payload": {
395
+ "template_type": "promotion",
396
+ "language": "VI",
397
+ "elements": [{ "attachment_id": "approved-promo-banner-id", "type": "banner" }],
398
+ "parameters": { "coupon_code": "SUMMER30", "discount": "30%" }
399
+ }
400
+ }
401
+ }
402
+ }
403
+ ```
404
+
405
+ Response includes estimated reach count before send is confirmed. Quota resets monthly.
406
+
407
+ ---
408
+
409
+ ## Sharp Edges
410
+
411
+ - **7-day CS window** — `error: 12` means the user hasn't interacted in 7 days. Cannot bypass. Solution: use Transaction or Promotion templates (pre-approved) which ignore the window.
412
+ - **Version mismatch is intentional** — upload endpoints stay on `v2.0`, message send is `v3.0`. Do not "fix" this.
413
+ - **OA-scoped user_id** — never assume the same physical person has the same `user_id` across different OAs. Always store per-OA.
414
+ - **Template approval lag** — Transaction/Promotion templates take 1-5 business days to approve. Plan ahead; cannot substitute with CS messages after approval delay.
415
+ - **Image 1MB / File 5MB hard limits** — compress images server-side before upload. Zalo returns `error: 201` for oversized files.
416
+ - **Broadcast quota** — based on follower count × OA verification tier. Track monthly usage; `error: 133` = quota exceeded.
417
+ - **Button limit 5** — template messages silently drop buttons beyond index 4. Always validate `buttons.length <= 5` before sending.
418
+
419
+ ## Error Codes Quick Reference
420
+
421
+ | Code | Meaning | Fix |
422
+ |------|---------|-----|
423
+ | 0 | Success | — |
424
+ | 12 | Outside 7-day CS window | Use approved template type |
425
+ | 14 | Invalid access token | Refresh token, retry |
426
+ | 107 | Invalid recipient | Verify user_id is OA-scoped and valid |
427
+ | 133 | Broadcast quota exceeded | Wait for monthly reset |
428
+ | 201 | File size exceeded | Compress/split before upload |
429
+ | 216 | Template not approved | Submit template for Zalo review |