@moltflow/skills 1.3.0 → 2.0.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.
@@ -0,0 +1,463 @@
1
+ ---
2
+ name: moltflow
3
+ description: "WhatsApp Business automation API for sessions, messaging, groups, labels, and webhooks. Use when: whatsapp, send message, create session, qr code, monitor group, label contacts, webhook."
4
+ source: "MoltFlow Team"
5
+ version: "2.0.0"
6
+ risk: safe
7
+ requiredEnv:
8
+ - MOLTFLOW_API_KEY
9
+ primaryEnv: MOLTFLOW_API_KEY
10
+ disableModelInvocation: true
11
+ ---
12
+
13
+ > **MoltFlow** -- WhatsApp Business automation for teams. Connect, monitor, and automate WhatsApp at scale.
14
+ > [Save up to 17% with yearly billing](https://molt.waiflow.app/checkout?plan=free) -- Free tier available, no credit card required.
15
+
16
+ # MoltFlow Core API
17
+
18
+ Manage WhatsApp sessions, send messages, monitor groups, organize with labels, and receive real-time events via webhooks.
19
+
20
+ ## When to Use
21
+
22
+ - "Connect WhatsApp" or "create a session"
23
+ - "Send a WhatsApp message" or "send text to contact"
24
+ - "Monitor a WhatsApp group" or "list groups"
25
+ - "Label contacts" or "sync labels from WhatsApp"
26
+ - "Set up a webhook" or "listen for WhatsApp events"
27
+ - "Get QR code" or "start session"
28
+ - "List chats" or "get chat history"
29
+
30
+ ## Prerequisites
31
+
32
+ 1. **MOLTFLOW_API_KEY** -- Generate from the [MoltFlow Dashboard](https://molt.waiflow.app) under Settings > API Keys
33
+ 2. All requests require authentication via `Authorization: Bearer <token>` or `X-API-Key: <key>`
34
+ 3. Base URL: `https://apiv2.waiflow.app/api/v2`
35
+
36
+ ## Authentication
37
+
38
+ Every request must include one of:
39
+
40
+ ```
41
+ Authorization: Bearer <jwt_token>
42
+ ```
43
+
44
+ or
45
+
46
+ ```
47
+ X-API-Key: <your_api_key>
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Sessions
53
+
54
+ Manage WhatsApp connections. Each session represents one WhatsApp account linked via QR code.
55
+
56
+ | Method | Endpoint | Description |
57
+ |--------|----------|-------------|
58
+ | GET | `/sessions` | List all sessions |
59
+ | POST | `/sessions` | Create a new session |
60
+ | GET | `/sessions/{id}` | Get session details |
61
+ | DELETE | `/sessions/{id}` | Delete a session |
62
+ | POST | `/sessions/{id}/start` | Start session (triggers QR scan) |
63
+ | POST | `/sessions/{id}/stop` | Stop a running session |
64
+ | POST | `/sessions/{id}/restart` | Restart a session |
65
+ | POST | `/sessions/{id}/logout` | Logout and clear auth state |
66
+ | GET | `/sessions/{id}/qr` | Get QR code for pairing |
67
+ | GET | `/sessions/{id}/events` | SSE stream of session events |
68
+
69
+ ### Session Status Values
70
+
71
+ Sessions progress through these states: `stopped` -> `starting` -> `qr_code` -> `working` -> `failed`
72
+
73
+ ### Create Session
74
+
75
+ **POST** `/sessions`
76
+
77
+ ```json
78
+ {
79
+ "name": "My WhatsApp"
80
+ }
81
+ ```
82
+
83
+ **Response** `201 Created`:
84
+
85
+ ```json
86
+ {
87
+ "id": "a1b2c3d4-...",
88
+ "name": "My WhatsApp",
89
+ "status": "stopped",
90
+ "phone_number": null,
91
+ "is_business": false,
92
+ "created_at": "2026-02-11T10:00:00Z"
93
+ }
94
+ ```
95
+
96
+ ### Start Session and Get QR
97
+
98
+ After creating a session, start it and retrieve the QR code:
99
+
100
+ 1. `POST /sessions/{id}/start` -- begins the WAHA engine
101
+ 2. Wait for status to become `qr_code` (use SSE events or poll)
102
+ 3. `GET /sessions/{id}/qr` -- returns the QR code image
103
+
104
+ ### SSE Events
105
+
106
+ `GET /sessions/{id}/events?token=<jwt>` returns a Server-Sent Events stream. Events include session status changes, incoming messages, and connection updates.
107
+
108
+ ### Session Settings
109
+
110
+ **PATCH** `/sessions/{id}/settings`
111
+
112
+ Configure per-session behavior. Settings are stored in the session's `config` JSON field.
113
+
114
+ ```json
115
+ // Request
116
+ {
117
+ "auto_transcribe": true
118
+ }
119
+
120
+ // Response
121
+ {
122
+ "status": "ok",
123
+ "config": {
124
+ "auto_transcribe": true
125
+ }
126
+ }
127
+ ```
128
+
129
+ | Field | Type | Description |
130
+ |-------|------|-------------|
131
+ | `auto_transcribe` | boolean | Automatically transcribe incoming voice messages |
132
+
133
+ ---
134
+
135
+ ## Messages
136
+
137
+ Send and retrieve WhatsApp messages through connected sessions.
138
+
139
+ | Method | Endpoint | Description |
140
+ |--------|----------|-------------|
141
+ | POST | `/messages/send` | Send a text message |
142
+ | POST | `/messages/send/poll` | Send a poll message |
143
+ | POST | `/messages/send/sticker` | Send a sticker |
144
+ | POST | `/messages/send/gif` | Send a GIF |
145
+ | GET | `/messages/chats/{session_id}` | List all chats for a session |
146
+ | GET | `/messages/chat/{session_id}/{chat_id}` | Get chat message history |
147
+ | GET | `/messages/{message_id}` | Get a single message |
148
+
149
+ ### Send Text Message
150
+
151
+ **POST** `/messages/send`
152
+
153
+ ```json
154
+ {
155
+ "session_id": "a1b2c3d4-...",
156
+ "chat_id": "5511999999999@c.us",
157
+ "message": "Hello from MoltFlow!"
158
+ }
159
+ ```
160
+
161
+ **Response** `201 Created`:
162
+
163
+ ```json
164
+ {
165
+ "id": "msg-uuid-...",
166
+ "chat_id": "chat-uuid-...",
167
+ "wa_message_id": "ABCD1234",
168
+ "direction": "outbound",
169
+ "message_type": "text",
170
+ "content_preview": "Hello from MoltFlow!",
171
+ "status": "sent",
172
+ "sent_at": "2026-02-11T10:05:00Z",
173
+ "created_at": "2026-02-11T10:05:00Z"
174
+ }
175
+ ```
176
+
177
+ ### Chat ID Format
178
+
179
+ - Individual contacts: `<phone>@c.us` (e.g., `5511999999999@c.us`)
180
+ - Groups: `<group_id>@g.us` (e.g., `120363012345678901@g.us`)
181
+
182
+ ### Send Poll
183
+
184
+ **POST** `/messages/send/poll`
185
+
186
+ ```json
187
+ {
188
+ "session_id": "a1b2c3d4-...",
189
+ "chat_id": "5511999999999@c.us",
190
+ "title": "Preferred meeting time?",
191
+ "options": ["Morning", "Afternoon", "Evening"],
192
+ "allow_multiple": false
193
+ }
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Groups
199
+
200
+ Monitor WhatsApp groups for keywords, messages, and activity.
201
+
202
+ | Method | Endpoint | Description |
203
+ |--------|----------|-------------|
204
+ | GET | `/groups` | List monitored groups |
205
+ | GET | `/groups/available/{session_id}` | List available WA groups |
206
+ | POST | `/groups` | Add group to monitoring |
207
+ | GET | `/groups/{id}` | Get monitored group details |
208
+ | PATCH | `/groups/{id}` | Update monitoring settings |
209
+ | DELETE | `/groups/{id}` | Remove from monitoring |
210
+ | POST | `/groups/create` | Create a new WA group |
211
+ | POST | `/groups/{wa_group_id}/participants/add` | Add participants |
212
+ | POST | `/groups/{wa_group_id}/participants/remove` | Remove participants |
213
+ | POST | `/groups/{wa_group_id}/admin/promote` | Promote to admin |
214
+ | POST | `/groups/{wa_group_id}/admin/demote` | Demote from admin |
215
+
216
+ ### Add Group to Monitoring
217
+
218
+ **POST** `/groups`
219
+
220
+ ```json
221
+ {
222
+ "session_id": "a1b2c3d4-...",
223
+ "wa_group_id": "120363012345678901@g.us",
224
+ "monitor_mode": "keywords",
225
+ "monitor_keywords": ["urgent", "support", "help"]
226
+ }
227
+ ```
228
+
229
+ ### Monitor Modes
230
+
231
+ - `all` -- Capture every message in the group
232
+ - `keywords` -- Only capture messages matching specified keywords
233
+ - `mentions` -- Only when your account is mentioned
234
+ - `first_message` -- Only first messages from new users (default for new groups)
235
+
236
+ ---
237
+
238
+ ## Labels
239
+
240
+ Organize contacts and chats with color-coded labels. Supports sync with WhatsApp Business native labels.
241
+
242
+ | Method | Endpoint | Description |
243
+ |--------|----------|-------------|
244
+ | GET | `/labels` | List all labels |
245
+ | POST | `/labels` | Create a label |
246
+ | GET | `/labels/{id}` | Get label details |
247
+ | PATCH | `/labels/{id}` | Update a label |
248
+ | DELETE | `/labels/{id}` | Delete a label |
249
+ | POST | `/labels/{id}/sync` | Sync label to WhatsApp |
250
+ | POST | `/labels/sync-from-whatsapp` | Import labels from WA |
251
+ | GET | `/labels/business-check` | Check WA Business status |
252
+ | GET | `/labels/{id}/chats` | List chats with this label |
253
+ | GET | `/labels/chat/{chat_id}` | Get labels for a chat |
254
+ | PUT | `/labels/chat/{chat_id}` | Set labels for a chat |
255
+
256
+ ### Create Label
257
+
258
+ **POST** `/labels`
259
+
260
+ ```json
261
+ {
262
+ "name": "VIP Customer",
263
+ "color": "#FF6B35",
264
+ "description": "High-value accounts"
265
+ }
266
+ ```
267
+
268
+ **Response** `201 Created`:
269
+
270
+ ```json
271
+ {
272
+ "id": "label-uuid-...",
273
+ "name": "VIP Customer",
274
+ "color": "#FF6B35",
275
+ "description": "High-value accounts",
276
+ "chat_count": 0,
277
+ "synced": false,
278
+ "created_at": "2026-02-11T10:00:00Z"
279
+ }
280
+ ```
281
+
282
+ > **Note:** Syncing labels to WhatsApp requires a WhatsApp Business account. Use `GET /labels/business-check` to verify.
283
+
284
+ ---
285
+
286
+ ## Webhooks
287
+
288
+ Receive real-time notifications when events occur in your WhatsApp sessions.
289
+
290
+ | Method | Endpoint | Description |
291
+ |--------|----------|-------------|
292
+ | GET | `/webhooks` | List all webhooks |
293
+ | POST | `/webhooks` | Create a webhook |
294
+ | GET | `/webhooks/{id}` | Get webhook details |
295
+ | PATCH | `/webhooks/{id}` | Update a webhook |
296
+ | DELETE | `/webhooks/{id}` | Delete a webhook |
297
+ | POST | `/webhooks/{id}/test` | Send a test delivery |
298
+
299
+ ### Supported Events
300
+
301
+ | Event | Description |
302
+ |-------|-------------|
303
+ | `message.received` | Inbound message received |
304
+ | `message.sent` | Outbound message sent |
305
+ | `session.connected` | Session connected to WhatsApp |
306
+ | `session.disconnected` | Session disconnected |
307
+ | `lead.detected` | New lead detected |
308
+ | `group.message` | Message in a monitored group |
309
+
310
+ ### Create Webhook
311
+
312
+ **POST** `/webhooks`
313
+
314
+ ```json
315
+ {
316
+ "name": "CRM Integration",
317
+ "url": "https://example.com/webhooks/moltflow",
318
+ "events": ["message.received", "lead.detected"],
319
+ "secret": "whsec_mysecretkey123"
320
+ }
321
+ ```
322
+
323
+ **Response** `201 Created`:
324
+
325
+ ```json
326
+ {
327
+ "id": "wh-uuid-...",
328
+ "name": "CRM Integration",
329
+ "url": "https://example.com/webhooks/moltflow",
330
+ "events": ["message.received", "lead.detected"],
331
+ "is_active": true,
332
+ "created_at": "2026-02-11T10:00:00Z"
333
+ }
334
+ ```
335
+
336
+ ### Webhook Payload
337
+
338
+ Deliveries include an HMAC-SHA256 signature in the `X-Webhook-Signature` header (if a secret is configured). Verify this to ensure authenticity.
339
+
340
+ ```json
341
+ {
342
+ "event": "message.received",
343
+ "timestamp": "2026-02-11T10:05:00Z",
344
+ "data": {
345
+ "session_id": "a1b2c3d4-...",
346
+ "chat_id": "5511999999999@c.us",
347
+ "message": "Hello!",
348
+ "direction": "inbound"
349
+ }
350
+ }
351
+ ```
352
+
353
+ ---
354
+
355
+ ## Examples
356
+
357
+ ### Full workflow: Create session and send first message
358
+
359
+ ```bash
360
+ # 1. Create a session
361
+ curl -X POST https://apiv2.waiflow.app/api/v2/sessions \
362
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
363
+ -H "Content-Type: application/json" \
364
+ -d '{"name": "Sales Team"}'
365
+
366
+ # 2. Start the session (triggers QR)
367
+ curl -X POST https://apiv2.waiflow.app/api/v2/sessions/{session_id}/start \
368
+ -H "X-API-Key: $MOLTFLOW_API_KEY"
369
+
370
+ # 3. Get QR code (scan with WhatsApp)
371
+ curl https://apiv2.waiflow.app/api/v2/sessions/{session_id}/qr \
372
+ -H "X-API-Key: $MOLTFLOW_API_KEY"
373
+
374
+ # 4. Send a message (after session status is "working")
375
+ curl -X POST https://apiv2.waiflow.app/api/v2/messages/send \
376
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
377
+ -H "Content-Type: application/json" \
378
+ -d '{
379
+ "session_id": "{session_id}",
380
+ "chat_id": "5511999999999@c.us",
381
+ "message": "Hello from MoltFlow!"
382
+ }'
383
+ ```
384
+
385
+ ### Set up a webhook for incoming messages
386
+
387
+ ```bash
388
+ curl -X POST https://apiv2.waiflow.app/api/v2/webhooks \
389
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
390
+ -H "Content-Type: application/json" \
391
+ -d '{
392
+ "name": "Incoming Messages",
393
+ "url": "https://myapp.com/webhooks/whatsapp",
394
+ "events": ["message.received", "session.connected"],
395
+ "secret": "whsec_my_secret"
396
+ }'
397
+ ```
398
+
399
+ ### Monitor a group for keywords
400
+
401
+ ```bash
402
+ # List available groups from a connected session
403
+ curl https://apiv2.waiflow.app/api/v2/groups/available/{session_id} \
404
+ -H "X-API-Key: $MOLTFLOW_API_KEY"
405
+
406
+ # Add a group to monitoring
407
+ curl -X POST https://apiv2.waiflow.app/api/v2/groups \
408
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
409
+ -H "Content-Type: application/json" \
410
+ -d '{
411
+ "session_id": "{session_id}",
412
+ "wa_group_id": "120363012345678901@g.us",
413
+ "monitor_mode": "keywords",
414
+ "monitor_keywords": ["urgent", "support"]
415
+ }'
416
+ ```
417
+
418
+ ---
419
+
420
+ ## Error Responses
421
+
422
+ All endpoints return standard error responses:
423
+
424
+ ```json
425
+ {
426
+ "detail": "Session not found"
427
+ }
428
+ ```
429
+
430
+ | Status | Meaning |
431
+ |--------|---------|
432
+ | 400 | Bad request (invalid input) |
433
+ | 401 | Unauthorized (missing or invalid auth) |
434
+ | 403 | Forbidden (plan limit or permission) |
435
+ | 404 | Resource not found |
436
+ | 429 | Rate limited |
437
+ | 500 | Internal server error |
438
+
439
+ ---
440
+
441
+ ## Rate Limits
442
+
443
+ API requests are rate-limited per tenant. Limits vary by plan:
444
+
445
+ | Plan | Requests/min |
446
+ |------|-------------|
447
+ | Free | 10 |
448
+ | Starter | 20 |
449
+ | Pro | 40 |
450
+ | Business | 60 |
451
+
452
+ Rate limit headers are included in every response: `X-RateLimit-Remaining`, `X-RateLimit-Reset`.
453
+
454
+ ---
455
+
456
+ ## Related Skills
457
+
458
+ - **moltflow-outreach** -- Bulk Send, Scheduled Messages, Custom Groups
459
+ - **moltflow-leads** -- Lead detection, pipeline tracking, bulk operations, CSV/JSON export
460
+ - **moltflow-ai** -- AI-powered auto-replies, voice transcription, RAG knowledge base, style profiles
461
+ - **moltflow-a2a** -- Agent-to-Agent protocol, encrypted messaging, content policy
462
+ - **moltflow-reviews** -- Review collection and testimonial management
463
+ - **moltflow-admin** -- Platform administration, user management, plan configuration