@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,473 @@
1
+ ---
2
+ name: moltflow-ai
3
+ description: "AI-powered WhatsApp features: auto-replies, voice transcription, RAG knowledge base, and style profiles. Use when: ai reply, transcribe voice, knowledge base, upload document, train style, learn mode."
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 AI Features
17
+
18
+ AI-powered capabilities for WhatsApp automation: voice transcription, RAG knowledge base, style profile learning, and intelligent reply generation.
19
+
20
+ ## When to Use
21
+
22
+ - "Transcribe a voice message" or "convert audio to text"
23
+ - "Upload a document to knowledge base" or "ingest PDF"
24
+ - "Search knowledge base" or "find in documents"
25
+ - "Train style profile" or "learn my writing style"
26
+ - "Generate an AI reply" or "auto-reply to customer"
27
+ - "Preview AI response" or "test reply generation"
28
+ - "List knowledge sources" or "delete document"
29
+
30
+ ## Prerequisites
31
+
32
+ 1. **MOLTFLOW_API_KEY** -- Generate from the [MoltFlow Dashboard](https://molt.waiflow.app) under Settings > API Keys
33
+ 2. **Pro plan or higher** ($29.90/mo) -- AI features are not available on the Starter plan
34
+ 3. Base URL: `https://apiv2.waiflow.app/api/v2`
35
+ 4. All AI endpoints are under the `/ai` prefix
36
+
37
+ ## Authentication
38
+
39
+ Every request must include one of:
40
+
41
+ ```
42
+ Authorization: Bearer <jwt_token>
43
+ ```
44
+
45
+ or
46
+
47
+ ```
48
+ X-API-Key: <your_api_key>
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Voice Transcription
54
+
55
+ Transcribe WhatsApp voice messages using Whisper AI. Transcription runs asynchronously via a Celery worker.
56
+
57
+ | Method | Endpoint | Description |
58
+ |--------|----------|-------------|
59
+ | POST | `/ai/voice/transcribe` | Queue a voice message for transcription |
60
+ | GET | `/ai/voice/status/{task_id}` | Check transcription task status |
61
+ | GET | `/ai/messages/{message_id}/transcript` | Get the transcript for a message |
62
+
63
+ ### Queue Transcription
64
+
65
+ **POST** `/ai/voice/transcribe`
66
+
67
+ ```json
68
+ {
69
+ "message_id": "msg-uuid-..."
70
+ }
71
+ ```
72
+
73
+ **Response** `200 OK`:
74
+
75
+ ```json
76
+ {
77
+ "task_id": "celery-task-id-...",
78
+ "message_id": "msg-uuid-...",
79
+ "status": "queued"
80
+ }
81
+ ```
82
+
83
+ ### Check Status
84
+
85
+ **GET** `/ai/voice/status/{task_id}`
86
+
87
+ ```json
88
+ {
89
+ "task_id": "celery-task-id-...",
90
+ "status": "completed",
91
+ "result": {
92
+ "transcript": "Hello, I wanted to ask about...",
93
+ "language": "en",
94
+ "confidence": 0.95
95
+ }
96
+ }
97
+ ```
98
+
99
+ Status values: `queued`, `processing`, `completed`, `failed`
100
+
101
+ ### Get Transcript
102
+
103
+ **GET** `/ai/messages/{message_id}/transcript`
104
+
105
+ ```json
106
+ {
107
+ "message_id": "msg-uuid-...",
108
+ "transcript": "Hello, I wanted to ask about...",
109
+ "language": "en",
110
+ "confidence": 0.95,
111
+ "transcribed_at": "2026-02-11T10:05:00Z"
112
+ }
113
+ ```
114
+
115
+ ---
116
+
117
+ ## RAG Knowledge Base
118
+
119
+ Upload documents to build a searchable knowledge base. The AI uses this context when generating replies, providing accurate answers grounded in your business data.
120
+
121
+ | Method | Endpoint | Description |
122
+ |--------|----------|-------------|
123
+ | POST | `/ai/knowledge/ingest` | Upload and index a document |
124
+ | POST | `/ai/knowledge/search` | Semantic search across documents |
125
+ | GET | `/ai/knowledge/sources` | List all indexed documents |
126
+ | DELETE | `/ai/knowledge/{source_id}` | Delete a document |
127
+
128
+ ### Upload Document
129
+
130
+ **POST** `/ai/knowledge/ingest` (multipart/form-data)
131
+
132
+ | Field | Type | Description |
133
+ |-------|------|-------------|
134
+ | `file` | File | PDF or TXT file (max 100MB) |
135
+
136
+ **Response** `200 OK`:
137
+
138
+ ```json
139
+ {
140
+ "id": "src-uuid-...",
141
+ "name": "product-catalog.pdf",
142
+ "source_type": "application/pdf",
143
+ "chunk_count": 47,
144
+ "status": "indexed",
145
+ "task_id": "celery-task-id-..."
146
+ }
147
+ ```
148
+
149
+ Supported file types: `application/pdf`, `text/plain` (`.pdf`, `.txt`)
150
+
151
+ ### Search Knowledge Base
152
+
153
+ **POST** `/ai/knowledge/search`
154
+
155
+ ```json
156
+ {
157
+ "query": "What is the return policy?",
158
+ "top_k": 5
159
+ }
160
+ ```
161
+
162
+ **Response** `200 OK`:
163
+
164
+ ```json
165
+ {
166
+ "query": "What is the return policy?",
167
+ "results": [
168
+ {
169
+ "source_id": "src-uuid-...",
170
+ "content_type": "application/pdf",
171
+ "content_preview": "Our return policy allows returns within 30 days...",
172
+ "metadata": {"page": 12, "chunk": 3},
173
+ "similarity": 0.92
174
+ }
175
+ ],
176
+ "count": 1
177
+ }
178
+ ```
179
+
180
+ Optional filters:
181
+
182
+ ```json
183
+ {
184
+ "query": "shipping costs",
185
+ "filters": {"source_type": "application/pdf"},
186
+ "top_k": 10
187
+ }
188
+ ```
189
+
190
+ ### List Documents
191
+
192
+ **GET** `/ai/knowledge/sources`
193
+
194
+ ```json
195
+ [
196
+ {
197
+ "id": "src-uuid-...",
198
+ "name": "product-catalog.pdf",
199
+ "source_type": "application/pdf",
200
+ "chunk_count": 47,
201
+ "status": "indexed",
202
+ "created_at": "2026-02-11T09:00:00Z",
203
+ "indexed_at": "2026-02-11T09:02:00Z"
204
+ }
205
+ ]
206
+ ```
207
+
208
+ Document status values: `processing`, `indexed`, `failed`
209
+
210
+ ### Delete Document
211
+
212
+ **DELETE** `/ai/knowledge/{source_id}` -- Returns `204 No Content`
213
+
214
+ ---
215
+
216
+ ## Style Profiles (Learn Mode)
217
+
218
+ Train the AI to match your writing style by analyzing your message history from specific chats. Style profiles can be scoped to individual conversations (per-chat) or trained across all messages (general profile). The AI auto-selects the best matching profile when generating replies.
219
+
220
+ | Method | Endpoint | Description |
221
+ |--------|----------|-------------|
222
+ | POST | `/ai/style/train` | Start training a style profile |
223
+ | GET | `/ai/style/status/{task_id}` | Check training status |
224
+ | GET | `/ai/style/profile` | Get a style profile |
225
+ | GET | `/ai/style/profiles` | List all style profiles |
226
+ | DELETE | `/ai/style/profile/{profile_id}` | Delete a style profile |
227
+
228
+ ### Train Style Profile
229
+
230
+ **POST** `/ai/style/train`
231
+
232
+ ```json
233
+ {
234
+ "session_id": "session-uuid-...",
235
+ "wa_chat_id": "5511999999999@c.us",
236
+ "name": "Sales"
237
+ }
238
+ ```
239
+
240
+ | Field | Type | Required | Description |
241
+ |-------|------|----------|-------------|
242
+ | `contact_id` | string | No | Legacy — use `wa_chat_id` instead |
243
+ | `session_id` | UUID | No | Session to scope training to |
244
+ | `wa_chat_id` | string | No | Chat to scope training to (WhatsApp JID). Omit for general profile |
245
+ | `name` | string | No | Profile name (e.g., "Sales", "Support", "Family") |
246
+
247
+ **Note:** Omit both `session_id` and `wa_chat_id` to train a general profile from all messages.
248
+
249
+ **Response** `200 OK`:
250
+
251
+ ```json
252
+ {
253
+ "task_id": "celery-task-id-...",
254
+ "tenant_id": "tenant-uuid-...",
255
+ "contact_id": "5511999999999@c.us",
256
+ "status": "queued"
257
+ }
258
+ ```
259
+
260
+ Training runs asynchronously. Check progress with the status endpoint.
261
+
262
+ ### Get Style Profile
263
+
264
+ **GET** `/ai/style/profile?contact_id=5511999999999@c.us`
265
+
266
+ ```json
267
+ {
268
+ "id": "profile-uuid-...",
269
+ "tenant_id": "tenant-uuid-...",
270
+ "contact_id": "5511999999999@c.us",
271
+ "name": "Sales",
272
+ "session_id": "session-uuid-...",
273
+ "wa_chat_id": "5511999999999@c.us",
274
+ "features": {
275
+ "avg_sentence_length": 12.5,
276
+ "formality_score": 0.7,
277
+ "emoji_frequency": 0.15,
278
+ "vocabulary_richness": 0.82
279
+ },
280
+ "sample_count": 150,
281
+ "last_trained_at": "2026-02-11T09:30:00Z"
282
+ }
283
+ ```
284
+
285
+ ### List All Profiles
286
+
287
+ **GET** `/ai/style/profiles`
288
+
289
+ ```json
290
+ [
291
+ {
292
+ "id": "profile-uuid-1",
293
+ "tenant_id": "tenant-uuid-...",
294
+ "name": "Sales",
295
+ "session_id": "session-uuid-...",
296
+ "wa_chat_id": "5511999999999@c.us",
297
+ "features": { "formality_score": 0.7 },
298
+ "sample_count": 150,
299
+ "last_trained_at": "2026-02-11T09:30:00Z"
300
+ },
301
+ {
302
+ "id": "profile-uuid-2",
303
+ "tenant_id": "tenant-uuid-...",
304
+ "name": "General",
305
+ "session_id": null,
306
+ "wa_chat_id": null,
307
+ "features": { "formality_score": 0.5 },
308
+ "sample_count": 420,
309
+ "last_trained_at": "2026-02-11T10:00:00Z"
310
+ }
311
+ ]
312
+ ```
313
+
314
+ ### Delete Profile
315
+
316
+ **DELETE** `/ai/style/profile/{profile_id}` -- Returns `204 No Content`
317
+
318
+ ---
319
+
320
+ ## AI Reply Generation
321
+
322
+ Generate intelligent reply suggestions using RAG context and style profiles. The AI considers conversation history, knowledge base content, and your communication style.
323
+
324
+ | Method | Endpoint | Description |
325
+ |--------|----------|-------------|
326
+ | POST | `/ai/generate-reply` | Generate a reply suggestion |
327
+ | GET | `/ai/preview` | Preview a reply without tracking usage |
328
+
329
+ ### Generate Reply
330
+
331
+ **POST** `/ai/generate-reply`
332
+
333
+ ```json
334
+ {
335
+ "contact_id": "5511999999999@c.us",
336
+ "context": "Customer asks: Do you offer international shipping?",
337
+ "use_rag": true,
338
+ "apply_style": true,
339
+ "profile_id": "profile-uuid-...",
340
+ "session_id": "session-uuid-..."
341
+ }
342
+ ```
343
+
344
+ **Response** `200 OK`:
345
+
346
+ ```json
347
+ {
348
+ "reply": "Yes, we ship internationally to over 50 countries! Shipping typically takes 7-14 business days. You can find our full shipping policy on our website.",
349
+ "rag_sources": ["product-catalog.pdf"],
350
+ "style_applied": true,
351
+ "model": "gpt-4o-mini",
352
+ "tokens_used": 245,
353
+ "requires_approval": false
354
+ }
355
+ ```
356
+
357
+ ### Parameters
358
+
359
+ | Field | Type | Default | Description |
360
+ |-------|------|---------|-------------|
361
+ | `contact_id` | string | required | WhatsApp JID of the contact |
362
+ | `context` | string | required | Conversation context or customer question (max 2000 chars) |
363
+ | `use_rag` | boolean | `true` | Include knowledge base context in generation |
364
+ | `apply_style` | boolean | `true` | Apply trained style profile to response |
365
+ | `profile_id` | UUID | `null` | Specific style profile to use (skips auto-selection cascade) |
366
+ | `session_id` | UUID | `null` | Session for cascade profile resolution |
367
+ | `approved` | boolean | `false` | Set `true` to confirm an approval-required reply |
368
+
369
+ **Note:** If `profile_id` is omitted and `apply_style` is true, the API auto-selects the best profile using the cascade: exact chat match → session-level → tenant-level general → no style.
370
+
371
+ ### Preview Reply
372
+
373
+ **GET** `/ai/preview?contact_id=5511999999999@c.us&context=What+are+your+hours&use_rag=true&apply_style=true`
374
+
375
+ Same response format as `generate-reply`, but does not count toward usage metrics.
376
+
377
+ ### Safety Features
378
+
379
+ AI reply generation includes built-in safety:
380
+
381
+ - **Input sanitization** -- Detects and blocks prompt injection attempts
382
+ - **Intent verification** -- Flags ambiguous or high-risk intents for confirmation
383
+ - **Output filtering** -- Screens generated content for PII, secrets, and policy violations
384
+ - **Content policy** -- Tenant-configurable rules (see moltflow-a2a skill)
385
+
386
+ ---
387
+
388
+ ## Examples
389
+
390
+ ### Upload a knowledge base document
391
+
392
+ ```bash
393
+ curl -X POST https://apiv2.waiflow.app/api/v2/ai/knowledge/ingest \
394
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
395
+ -F "file=@product-catalog.pdf"
396
+ ```
397
+
398
+ ### Generate an AI reply using RAG
399
+
400
+ ```bash
401
+ curl -X POST https://apiv2.waiflow.app/api/v2/ai/generate-reply \
402
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
403
+ -H "Content-Type: application/json" \
404
+ -d '{
405
+ "contact_id": "5511999999999@c.us",
406
+ "context": "Customer asks: What is your return policy?",
407
+ "use_rag": true,
408
+ "apply_style": true
409
+ }'
410
+ ```
411
+
412
+ ### Generate reply with specific profile
413
+
414
+ ```bash
415
+ curl -X POST https://apiv2.waiflow.app/api/v2/ai/generate-reply \
416
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
417
+ -H "Content-Type: application/json" \
418
+ -d '{
419
+ "contact_id": "5511999999999@c.us",
420
+ "context": "Customer asks: What is your return policy?",
421
+ "use_rag": true,
422
+ "apply_style": true,
423
+ "profile_id": "profile-uuid-..."
424
+ }'
425
+ ```
426
+
427
+ ### Train a style profile
428
+
429
+ ```bash
430
+ curl -X POST https://apiv2.waiflow.app/api/v2/ai/style/train \
431
+ -H "X-API-Key: $MOLTFLOW_API_KEY" \
432
+ -H "Content-Type: application/json" \
433
+ -d '{
434
+ "session_id": "session-uuid-...",
435
+ "wa_chat_id": "5511999999999@c.us",
436
+ "name": "Sales"
437
+ }'
438
+ ```
439
+
440
+ ---
441
+
442
+ ## Plan Requirements
443
+
444
+ | Feature | Starter | Pro ($29.90/mo) | Business ($69.90/mo) |
445
+ |---------|---------|-----------------|------------|
446
+ | Voice Transcription | -- | Yes | Yes |
447
+ | RAG Knowledge Base | -- | Yes (10 docs) | Yes (unlimited) |
448
+ | Style Profiles | -- | Yes (3 profiles) | Yes (unlimited) |
449
+ | AI Reply Generation | -- | Yes | Yes |
450
+
451
+ ---
452
+
453
+ ## Error Responses
454
+
455
+ | Status | Meaning |
456
+ |--------|---------|
457
+ | 400 | Bad request (invalid input, unsupported file type) |
458
+ | 401 | Unauthorized (missing or invalid auth) |
459
+ | 403 | Forbidden (feature requires Pro plan or higher) |
460
+ | 404 | Resource not found (message, document, profile) |
461
+ | 413 | File too large (exceeds 100MB limit) |
462
+ | 429 | Rate limited |
463
+
464
+ ---
465
+
466
+ ## Related Skills
467
+
468
+ - **moltflow** -- Core API: sessions, messaging, groups, labels, webhooks
469
+ - **moltflow-outreach** -- Bulk Send, Scheduled Messages, Custom Groups
470
+ - **moltflow-leads** -- Lead detection, pipeline tracking, bulk operations, CSV/JSON export
471
+ - **moltflow-a2a** -- Agent-to-Agent protocol, encrypted messaging, content policy
472
+ - **moltflow-reviews** -- Review collection and testimonial management
473
+ - **moltflow-admin** -- Platform administration, user management, plan configuration