@gamastudio/sendwave-provider 1.0.0 → 1.0.2
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 +70 -285
- package/build/core/interface/provider.interface.d.ts +2 -1
- package/build/core/interface/types.d.ts +45 -7
- package/build/package.json +1 -1
- package/build/provider/provider.d.ts +2 -1
- package/build/provider/provider.js +4 -0
- package/build/provider/sender.d.ts +2 -1
- package/build/provider/sender.js +68 -16
- package/build/utils/detectorMedia.js +5 -3
- package/bun.lock +602 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 📖
|
|
1
|
+
# 📖 Sendwaves Provider
|
|
2
2
|
|
|
3
3
|
**A dynamic library for integrating and managing Sendwave instances for WhatsApp bot development.**
|
|
4
4
|
|
|
@@ -23,80 +23,90 @@ const provider = createSendWaveProvider({
|
|
|
23
23
|
|
|
24
24
|
// Initialize the provider
|
|
25
25
|
await provider.initAll(provider.globalVendorArgs.port);
|
|
26
|
-
await provider.initVendor();
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
## 📤 Sending Messages
|
|
29
|
+
|
|
30
|
+
### Text Messages
|
|
30
31
|
|
|
31
32
|
```typescript
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
linkPreview: true, // Enable/disable link previews
|
|
40
|
-
message: {
|
|
41
|
-
mergeMessage: false, // Enable message buffering
|
|
42
|
-
timeMergeMessage: 3, // Buffer timeout in seconds
|
|
43
|
-
},
|
|
44
|
-
queueFlow: {
|
|
45
|
-
enabled: true, // Enable queue flow system
|
|
46
|
-
warningTimeout: 30 * 60 * 1000, // 30 minutes before warning
|
|
47
|
-
endTimeout: 2 * 60 * 1000, // 2 minutes after warning to end session
|
|
48
|
-
warningMessage: "⏳ You seem to be inactive. Are you still there?",
|
|
49
|
-
},
|
|
50
|
-
};
|
|
33
|
+
await provider.sendText({
|
|
34
|
+
from: "573123456789",
|
|
35
|
+
text: "Hello! Welcome to our service.",
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Interactive Polls (New! 📊)
|
|
51
40
|
|
|
52
|
-
|
|
41
|
+
```typescript
|
|
42
|
+
await provider.sendPoll({
|
|
43
|
+
from: "573123456789",
|
|
44
|
+
poll: {
|
|
45
|
+
name: "¿Qué te parece el nuevo proveedor?",
|
|
46
|
+
values: ["Excelente", "Bueno", "Mejorable"],
|
|
47
|
+
selectableCount: 1 // Optional, default: 1
|
|
48
|
+
}
|
|
49
|
+
});
|
|
53
50
|
```
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
### Intelligent Buttons (Easier! 🔘)
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
The provider is now "intelligent" and accepts multiple formats for buttons.
|
|
58
55
|
|
|
59
56
|
```typescript
|
|
60
|
-
|
|
57
|
+
// 1. Super Simple (Quick Replies)
|
|
58
|
+
await provider.sendButton({
|
|
61
59
|
from: "573123456789",
|
|
62
|
-
|
|
60
|
+
title: "Main Menu",
|
|
61
|
+
buttons: ["🛒 Catalog", "🎁 Promotions", "📞 Support"]
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// 2. Mixed Format (Text & Functional buttons)
|
|
65
|
+
await provider.sendButton({
|
|
66
|
+
from: "573123456789",
|
|
67
|
+
title: "Payment Options",
|
|
68
|
+
body: "Select your preferred method",
|
|
69
|
+
buttons: [
|
|
70
|
+
{ type: "reply", displayText: "Cash" },
|
|
71
|
+
{ type: "url", displayText: "Visit Web", url: "https://example.com" },
|
|
72
|
+
{ type: "copy", displayText: "Copy Coupon", copyText: "SAVE20" },
|
|
73
|
+
{ type: "pix", displayText: "Pay with Pix", keyType: "email", key: "pix@bot.com" }
|
|
74
|
+
]
|
|
63
75
|
});
|
|
64
76
|
```
|
|
65
77
|
|
|
66
|
-
|
|
78
|
+
**Supported Button Types:**
|
|
79
|
+
- `reply`: Standard quick reply button.
|
|
80
|
+
- `url`: Opens a website.
|
|
81
|
+
- `call`: Triggers a phone call.
|
|
82
|
+
- `copy`: Copies text or code to clipboard.
|
|
83
|
+
- `pix`: Brazilian payment system integration.
|
|
84
|
+
|
|
85
|
+
### Intelligent Lists (Simple & Advanced 📜)
|
|
67
86
|
|
|
68
87
|
```typescript
|
|
88
|
+
// Simple List (Array of strings)
|
|
69
89
|
await provider.sendList({
|
|
70
90
|
from: "573123456789",
|
|
71
91
|
list: {
|
|
72
92
|
title: "Select an option",
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
content: ["🛒 Catalog", "🎁 Promotions", "📞 Support"],
|
|
76
|
-
footerText: "Powered by Sendwave", // Optional
|
|
93
|
+
button: "View Options",
|
|
94
|
+
content: ["Option 1", "Option 2", "Option 3"],
|
|
77
95
|
},
|
|
78
96
|
});
|
|
79
97
|
|
|
80
|
-
// Advanced
|
|
98
|
+
// Advanced List with sections
|
|
81
99
|
await provider.sendList({
|
|
82
100
|
from: "573123456789",
|
|
83
101
|
list: {
|
|
84
102
|
title: "Product Categories",
|
|
85
|
-
description: "Browse our products by category",
|
|
86
103
|
button: "Select Category",
|
|
87
104
|
content: [
|
|
88
105
|
{
|
|
89
106
|
title: "Electronics",
|
|
90
107
|
rows: [
|
|
91
|
-
{ title: "Smartphones", description: "Latest models
|
|
92
|
-
{ title: "Laptops", description: "Gaming and office
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
title: "Clothing",
|
|
97
|
-
rows: [
|
|
98
|
-
{ title: "Men's Fashion" },
|
|
99
|
-
{ title: "Women's Fashion" },
|
|
108
|
+
{ title: "Smartphones", description: "Latest models" },
|
|
109
|
+
{ title: "Laptops", description: "Gaming and office" },
|
|
100
110
|
],
|
|
101
111
|
},
|
|
102
112
|
],
|
|
@@ -107,268 +117,43 @@ await provider.sendList({
|
|
|
107
117
|
### Media Messages
|
|
108
118
|
|
|
109
119
|
```typescript
|
|
110
|
-
// Images
|
|
111
|
-
await provider.sendImage({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// Videos
|
|
118
|
-
await provider.sendVideo({
|
|
119
|
-
from: "573123456789",
|
|
120
|
-
url: "https://example.com/video.mp4",
|
|
121
|
-
text: "Product demonstration",
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// Documents
|
|
125
|
-
await provider.sendFile({
|
|
126
|
-
from: "573123456789",
|
|
127
|
-
url: "https://example.com/catalog.pdf",
|
|
128
|
-
fileName: "Product Catalog 2024.pdf",
|
|
129
|
-
text: "Here's our complete catalog",
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// Voice Messages
|
|
133
|
-
await provider.sendVoice({
|
|
134
|
-
from: "573123456789",
|
|
135
|
-
url: "https://example.com/audio.mp3",
|
|
136
|
-
});
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Button Messages
|
|
140
|
-
|
|
141
|
-
```typescript
|
|
142
|
-
await provider.sendButton({
|
|
143
|
-
from: "573123456789",
|
|
144
|
-
title: "Customer Support",
|
|
145
|
-
body: "How can we help you today?",
|
|
146
|
-
description: "Choose one of the options below",
|
|
147
|
-
footer: "We're here to help!",
|
|
148
|
-
buttons: [
|
|
149
|
-
{ type: "reply", text: "Technical Support" },
|
|
150
|
-
{ type: "reply", text: "Billing Questions" },
|
|
151
|
-
{ type: "url", text: "Visit Website" },
|
|
152
|
-
],
|
|
153
|
-
});
|
|
120
|
+
// Images, Videos, Documents, and Voice
|
|
121
|
+
await provider.sendImage({ from: "573123456789", url: "https://...", text: "Caption" });
|
|
122
|
+
await provider.sendVideo({ from: "573123456789", url: "https://...", text: "Caption" });
|
|
123
|
+
await provider.sendFile({ from: "573123456789", url: "https://...", fileName: "file.pdf" });
|
|
124
|
+
await provider.sendVoice({ from: "573123456789", url: "https://..." });
|
|
154
125
|
```
|
|
155
126
|
|
|
156
|
-
## 🔄 Queue Flow System
|
|
157
|
-
|
|
158
|
-
The Queue Flow system **automatically** manages user sessions, handling timeouts and inactive users to optimize bot performance. Just enable it in the configuration and everything works automatically.
|
|
127
|
+
## 🔄 Queue Flow System (100% Automatic)
|
|
159
128
|
|
|
160
|
-
|
|
129
|
+
The Queue Flow system manages user sessions, handling timeouts and inactive users automatically.
|
|
161
130
|
|
|
162
131
|
```typescript
|
|
163
132
|
const provider = createSendWaveProvider({
|
|
164
133
|
name: "MyBot",
|
|
165
134
|
apiKey: "your-key",
|
|
166
135
|
queueFlow: {
|
|
167
|
-
enabled: true,
|
|
168
|
-
warningTimeout: 30 * 60 * 1000, // 30
|
|
169
|
-
endTimeout: 2 * 60 * 1000, // 2
|
|
170
|
-
warningMessage: "⏳ You seem inactive. Still there?",
|
|
136
|
+
enabled: true,
|
|
137
|
+
warningTimeout: 30 * 60 * 1000, // 30 mins
|
|
138
|
+
endTimeout: 2 * 60 * 1000, // 2 mins after warning
|
|
139
|
+
warningMessage: "⏳ You seem inactive. Still there?",
|
|
171
140
|
},
|
|
172
141
|
});
|
|
173
142
|
```
|
|
174
143
|
|
|
175
|
-
**✨ What happens automatically when enabled:**
|
|
176
|
-
- User timeouts are reset on every message (no code needed)
|
|
177
|
-
- Warning messages are sent after inactivity period
|
|
178
|
-
- Users are automatically removed from queue after timeout
|
|
179
|
-
- `END_FLOW` event is triggered for BuilderBot integration
|
|
180
|
-
- No additional code required in your flows!
|
|
181
|
-
|
|
182
|
-
### Queue Flow Methods
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
// Reset user timeout (called automatically on user messages)
|
|
186
|
-
provider.resetUserTimeout("573123456789", "John Doe");
|
|
187
|
-
|
|
188
|
-
// Clear user timeout manually
|
|
189
|
-
provider.clearUserTimeout("573123456789");
|
|
190
|
-
|
|
191
|
-
// Force remove user from system
|
|
192
|
-
provider.forceClearUser("573123456789");
|
|
193
|
-
|
|
194
|
-
// Check if user is ignored
|
|
195
|
-
const isIgnored = provider.isUserIgnored("573123456789");
|
|
196
|
-
|
|
197
|
-
// Get system statistics
|
|
198
|
-
const stats = provider.getQueueFlowStats();
|
|
199
|
-
console.log(stats); // { activeTimeouts: 5, ignoredUsers: 2, config: {...} }
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Queue Flow Events
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
// Listen to user inactivity events
|
|
206
|
-
provider.onQueueFlowEvent('userInactive-573123456789', (data) => {
|
|
207
|
-
if (data.isActive) {
|
|
208
|
-
console.log(`Warning sent to ${data.from}`);
|
|
209
|
-
} else {
|
|
210
|
-
console.log(`User ${data.from} removed due to inactivity`);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
// Remove event listeners
|
|
215
|
-
provider.offQueueFlowEvent('userInactive-573123456789');
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## 🤖 BuilderBot Integration
|
|
219
|
-
|
|
220
|
-
### Flow Implementation Examples
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
import { addKeyword, EVENTS, utils } from "@builderbot/bot";
|
|
224
|
-
import { SendWaveProvider as Provider } from "@gamastudio/sendwave-provider";
|
|
225
|
-
|
|
226
|
-
// Welcome Flow
|
|
227
|
-
export const flowWelcome = addKeyword<Provider>(EVENTS.WELCOME)
|
|
228
|
-
.addAnswer([
|
|
229
|
-
"¡Hello! I'm *Max*, your virtual assistant. 😊",
|
|
230
|
-
"Welcome to our service.",
|
|
231
|
-
])
|
|
232
|
-
.addAction(async (_, { gotoFlow }) => await gotoFlow(flowMainMenu));
|
|
233
|
-
|
|
234
|
-
// End Flow (integrates with Queue Flow system)
|
|
235
|
-
export const flowEnd = addKeyword<Provider>(utils.setEvent("END_FLOW"))
|
|
236
|
-
.addAction(async (ctx, { endFlow, provider }) => {
|
|
237
|
-
// Clean up user from queue flow system
|
|
238
|
-
provider.forceClearUser(ctx.from);
|
|
239
|
-
endFlow("Chat closed due to inactivity. Write again if you need help!");
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
// Customer Support Flow
|
|
243
|
-
export const flowSupport = addKeyword<Provider>("SUPPORT")
|
|
244
|
-
.addAction(async (ctx, { blacklist, endFlow, provider }) => {
|
|
245
|
-
// Add to blacklist and clean queue
|
|
246
|
-
blacklist.add(ctx.from);
|
|
247
|
-
provider.forceClearUser(ctx.from);
|
|
248
|
-
|
|
249
|
-
return endFlow(
|
|
250
|
-
"An agent will contact you shortly. Thanks for your patience! 👨💻"
|
|
251
|
-
);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// Interactive Menu Flow
|
|
255
|
-
export const flowMainMenu = addKeyword<Provider>("MAIN_MENU")
|
|
256
|
-
.addAction(async (ctx, { provider }) => {
|
|
257
|
-
await provider.sendList({
|
|
258
|
-
from: ctx.from,
|
|
259
|
-
list: {
|
|
260
|
-
button: "View Menu",
|
|
261
|
-
title: "",
|
|
262
|
-
description: "Select an option from the menu. Let's get started! 👇",
|
|
263
|
-
content: ["🛒 Catalog", "🎁 Promotions", "📞 Support"],
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
})
|
|
267
|
-
.addAction({ capture: true }, async (ctx, { gotoFlow, fallBack }) => {
|
|
268
|
-
const option = ctx.body.trim();
|
|
269
|
-
|
|
270
|
-
switch (option) {
|
|
271
|
-
case "🛒 Catalog":
|
|
272
|
-
await gotoFlow(flowCatalog);
|
|
273
|
-
break;
|
|
274
|
-
case "🎁 Promotions":
|
|
275
|
-
await gotoFlow(flowPromotions);
|
|
276
|
-
break;
|
|
277
|
-
case "📞 Support":
|
|
278
|
-
await gotoFlow(flowSupport);
|
|
279
|
-
break;
|
|
280
|
-
default:
|
|
281
|
-
fallBack("I didn't understand that option. Please select from the list.");
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### Delayed Response Handling (100% Automatic)
|
|
288
|
-
|
|
289
|
-
The Queue Flow system automatically handles users who take time to respond with **zero configuration needed**:
|
|
290
|
-
|
|
291
|
-
```typescript
|
|
292
|
-
// ✅ AUTOMATIC PROCESS:
|
|
293
|
-
// 1. User sends message -> timeout resets automatically
|
|
294
|
-
// 2. After 30 minutes of inactivity -> warning message sent automatically
|
|
295
|
-
// 3. After 2 more minutes -> user session ends with END_FLOW event automatically
|
|
296
|
-
// 4. User is cleaned from queue automatically
|
|
297
|
-
|
|
298
|
-
// 🎯 ONLY THING YOU NEED: Handle the END_FLOW event in your flows
|
|
299
|
-
export const flowEnd = addKeyword<Provider>(utils.setEvent("END_FLOW"))
|
|
300
|
-
.addAction(async (ctx, { endFlow }) => {
|
|
301
|
-
// This runs automatically when user is inactive for too long
|
|
302
|
-
endFlow("Session ended due to inactivity. Contact us again anytime!");
|
|
303
|
-
// ✨ Queue cleanup happens automatically, no code needed!
|
|
304
|
-
});
|
|
305
|
-
```
|
|
306
|
-
|
|
307
144
|
## 🎯 Event System
|
|
308
145
|
|
|
309
146
|
```typescript
|
|
310
|
-
|
|
311
|
-
provider.on('
|
|
312
|
-
console.log('Connection status:', isReady ? 'Connected' : 'Disconnected');
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
provider.on('auth_failure', (error) => {
|
|
316
|
-
console.error('Authentication failed:', error);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
// Message events
|
|
320
|
-
provider.on('message', (ctx) => {
|
|
321
|
-
console.log(`Message from ${ctx.from}: ${ctx.body}`);
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
provider.on('user-message', (data) => {
|
|
325
|
-
console.log(`User message: ${data.body}`);
|
|
326
|
-
// Timeout automatically resets here if queue flow is enabled
|
|
327
|
-
});
|
|
147
|
+
provider.on('ready', (isReady) => console.log('Connected:', isReady));
|
|
148
|
+
provider.on('message', (ctx) => console.log(`From ${ctx.from}: ${ctx.body}`));
|
|
328
149
|
```
|
|
329
150
|
|
|
330
|
-
## 🛠️ Development Scripts
|
|
331
|
-
|
|
332
|
-
| Script | Description |
|
|
333
|
-
| --------------- | ------------------------------------------------ |
|
|
334
|
-
| `npm run dev` | Run library in development mode with auto-reload |
|
|
335
|
-
| `npm run build` | Compile TypeScript and resolve path aliases |
|
|
336
|
-
| `npm run test` | Run basic test file |
|
|
337
|
-
|
|
338
|
-
## 📦 Package Structure
|
|
339
|
-
|
|
340
|
-
When you install `@gamastudio/sendwave-provider`:
|
|
341
|
-
|
|
342
|
-
- Compiled code in `/build` directory
|
|
343
|
-
- TypeScript declarations (`.d.ts`) included
|
|
344
|
-
- Main entry point: `build/index.js`
|
|
345
|
-
- Full TypeScript support with path aliases resolved
|
|
346
|
-
|
|
347
|
-
## 📋 Requirements
|
|
348
|
-
|
|
349
|
-
- **Node.js** 18+
|
|
350
|
-
- **npm** or **pnpm**
|
|
351
|
-
- **TypeScript** 5+
|
|
352
|
-
- Valid Sendwave API credentials
|
|
353
|
-
|
|
354
|
-
## 🔥 Important Notes
|
|
355
|
-
|
|
356
|
-
This library is in **beta** state and subject to internal changes.
|
|
357
|
-
|
|
358
|
-
**Recommendations:**
|
|
359
|
-
- Use in testing or controlled environments initially
|
|
360
|
-
- Update beta versions as new releases become available
|
|
361
|
-
- Monitor the queue flow system performance with your user base
|
|
362
|
-
|
|
363
151
|
## 🏗️ Architecture
|
|
364
152
|
|
|
365
|
-
- **Provider Layer**: Main SendWaveProvider class
|
|
366
|
-
- **
|
|
367
|
-
- **
|
|
368
|
-
- **Queue Flow**: Advanced user session management with timeout handling
|
|
369
|
-
- **Utils**: Media detection, message parsing, and flow utilities
|
|
153
|
+
- **Provider Layer**: Main SendWaveProvider class.
|
|
154
|
+
- **Sender Layer**: Intelligent message transformation.
|
|
155
|
+
- **Queue Flow**: Automatic session management.
|
|
370
156
|
|
|
371
157
|
## 📜 License
|
|
372
158
|
|
|
373
|
-
ISC License ©
|
|
374
|
-
|
|
159
|
+
ISC License © 2026 - Ameth Galarcio
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SendOptions } from "@builderbot/bot/dist/types";
|
|
2
|
-
import { ReadMessage, SendButton, SendList, SendLocation, SendMedia, SendMessage, SendPresence, SendReaction } from "../interface/types";
|
|
2
|
+
import { ReadMessage, SendButton, SendList, SendLocation, SendMedia, SendMessage, SendPoll, SendPresence, SendReaction } from "../interface/types";
|
|
3
3
|
export interface ProviderInterface {
|
|
4
4
|
sendMessage?: (number: string, message: string, options?: SendOptions) => Promise<any>;
|
|
5
5
|
sendText: (data: SendMessage) => Promise<any>;
|
|
@@ -13,6 +13,7 @@ export interface ProviderInterface {
|
|
|
13
13
|
sendList: (data: SendList) => Promise<any>;
|
|
14
14
|
sendPresence: (data: SendPresence) => Promise<any>;
|
|
15
15
|
sendButton: (data: SendButton) => Promise<any>;
|
|
16
|
+
sendPoll: (data: SendPoll) => Promise<any>;
|
|
16
17
|
sendLocation: (data: SendLocation) => Promise<any>;
|
|
17
18
|
sendReaction: (data: SendReaction) => Promise<any>;
|
|
18
19
|
readMessages: (data: ReadMessage) => Promise<any>;
|
|
@@ -80,6 +80,9 @@ export interface SendMessage {
|
|
|
80
80
|
from: string;
|
|
81
81
|
delay?: number;
|
|
82
82
|
text?: string;
|
|
83
|
+
quoted?: any;
|
|
84
|
+
everyOne?: boolean;
|
|
85
|
+
mentioned?: string[];
|
|
83
86
|
}
|
|
84
87
|
export interface SendMedia extends SendMessage {
|
|
85
88
|
mediaType?: "image" | "video" | "document" | "audio";
|
|
@@ -90,15 +93,50 @@ export interface SendPresence extends SendMessage {
|
|
|
90
93
|
delay?: number;
|
|
91
94
|
presence?: "composing" | "recording";
|
|
92
95
|
}
|
|
96
|
+
export type TypeButton = 'reply' | 'copy' | 'url' | 'call' | 'pix';
|
|
97
|
+
export type BaseButton<T> = T & {
|
|
98
|
+
type: TypeButton;
|
|
99
|
+
id?: string;
|
|
100
|
+
displayText: string;
|
|
101
|
+
};
|
|
102
|
+
export type Button = BaseButton<{
|
|
103
|
+
type: 'reply';
|
|
104
|
+
displayText: string;
|
|
105
|
+
}> | BaseButton<{
|
|
106
|
+
type: 'url';
|
|
107
|
+
displayText: string;
|
|
108
|
+
url: string;
|
|
109
|
+
}> | BaseButton<{
|
|
110
|
+
type: 'call';
|
|
111
|
+
displayText: string;
|
|
112
|
+
phoneNumber: string;
|
|
113
|
+
}> | BaseButton<{
|
|
114
|
+
type: 'copy';
|
|
115
|
+
displayText: string;
|
|
116
|
+
copyText: string;
|
|
117
|
+
copyCode?: string;
|
|
118
|
+
}> | BaseButton<{
|
|
119
|
+
type: 'pix';
|
|
120
|
+
displayText: string;
|
|
121
|
+
keyType: KeyType;
|
|
122
|
+
key: string;
|
|
123
|
+
currency?: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
}>;
|
|
93
126
|
export interface SendButton extends SendMessage {
|
|
94
127
|
title: string;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
thumbnailUrl?: string;
|
|
129
|
+
body?: string;
|
|
130
|
+
description?: string;
|
|
131
|
+
footer?: string;
|
|
132
|
+
buttons: Button[] | string[];
|
|
133
|
+
}
|
|
134
|
+
export interface SendPoll extends SendMessage {
|
|
135
|
+
poll: {
|
|
136
|
+
name: string;
|
|
137
|
+
values: string[];
|
|
138
|
+
selectableCount?: number;
|
|
139
|
+
};
|
|
102
140
|
}
|
|
103
141
|
export interface SendLocation extends SendMessage {
|
|
104
142
|
name: string;
|
package/build/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { ProviderClass } from "@builderbot/bot";
|
|
|
2
2
|
import Queue from "queue-promise";
|
|
3
3
|
import { SendWaveCore } from "./core";
|
|
4
4
|
import { BotContext, BotCtxMiddlewareOptions } from "@builderbot/bot/dist/types";
|
|
5
|
-
import { GlobalVendorArgs, ReadMessage, SendButton, SendList, SendLocation, SendMedia, SendMessage, SendPresence, SendReaction } from "../core/interface/types";
|
|
5
|
+
import { GlobalVendorArgs, ReadMessage, SendButton, SendList, SendLocation, SendMedia, SendMessage, SendPoll, SendPresence, SendReaction } from "../core/interface/types";
|
|
6
6
|
import { SenderMessage } from "./sender";
|
|
7
7
|
import { ParsedMessage } from "../core/interface";
|
|
8
8
|
export declare class SendWaveProvider extends ProviderClass<SendWaveCore> {
|
|
@@ -55,6 +55,7 @@ export declare class SendWaveProvider extends ProviderClass<SendWaveCore> {
|
|
|
55
55
|
sendPresence(data: SendPresence): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
56
56
|
sendVoice(data: SendMedia): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
57
57
|
sendButton(data: SendButton): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
58
|
+
sendPoll(data: SendPoll): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
58
59
|
sendReaction(data: SendReaction): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
59
60
|
sendLocation(data: SendLocation): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
60
61
|
sendMedia(data: SendMedia): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
@@ -195,6 +195,7 @@ class SendWaveProvider extends bot_1.ProviderClass {
|
|
|
195
195
|
sendVoice: this.sendVoice,
|
|
196
196
|
sendPresence: this.sendPresence,
|
|
197
197
|
sendButton: this.sendButton,
|
|
198
|
+
sendPoll: this.sendPoll,
|
|
198
199
|
readMessages: this.readMessages,
|
|
199
200
|
provider: this,
|
|
200
201
|
blacklist: opts === null || opts === void 0 ? void 0 : opts.blacklist,
|
|
@@ -495,6 +496,9 @@ class SendWaveProvider extends bot_1.ProviderClass {
|
|
|
495
496
|
sendButton(data) {
|
|
496
497
|
return this.sender.sendButton(data);
|
|
497
498
|
}
|
|
499
|
+
sendPoll(data) {
|
|
500
|
+
return this.sender.sendPoll(data);
|
|
501
|
+
}
|
|
498
502
|
sendReaction(data) {
|
|
499
503
|
return this.sender.sendReaction(data);
|
|
500
504
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GlobalVendorArgs, ProviderInterface, SendButton, SendList, SendMedia, SendMessage, SendPresence, SendLocation, SendReaction, ReadMessage } from "../core/interface";
|
|
1
|
+
import { GlobalVendorArgs, ProviderInterface, SendButton, SendList, SendMedia, SendMessage, SendPresence, SendPoll, SendLocation, SendReaction, ReadMessage } from "../core/interface";
|
|
2
2
|
export declare class SenderMessage implements ProviderInterface {
|
|
3
3
|
private sendwaveApi?;
|
|
4
4
|
private globalVendorArgs?;
|
|
@@ -15,6 +15,7 @@ export declare class SenderMessage implements ProviderInterface {
|
|
|
15
15
|
sendVideo(data: SendMedia): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
16
16
|
sendVoice(data: SendMedia): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
17
17
|
sendButton(data: SendButton): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
18
|
+
sendPoll(data: SendPoll): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
18
19
|
sendLocation(data: SendLocation): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
19
20
|
sendReaction(data: SendReaction): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|
|
20
21
|
readMessages(data: ReadMessage): Promise<import("axios").AxiosResponse<any, any, {}> | undefined>;
|