@gamastudio/sendwave-provider
v1.0.3
Published
Librería para interactuar con Sendwave usando configuración dinámica.
Downloads
582
Maintainers
Readme
📖 Sendwaves Provider
A dynamic library for integrating and managing Sendwave instances for WhatsApp bot development.
🚀 Installation
npm install @gamastudio/sendwave-provider🔧 Basic Usage
Creating a Provider Instance
import { createSendWaveProvider } from "@gamastudio/sendwave-provider";
const provider = createSendWaveProvider({
name: "MyBot",
apiKey: "your-api-key-here",
port: 3000,
});
// Initialize the provider
await provider.initAll(provider.globalVendorArgs.port);📤 Sending Messages
Text Messages
await provider.sendText({
from: "573123456789",
text: "Hello! Welcome to our service.",
});Interactive Polls (New! 📊)
await provider.sendPoll({
from: "573123456789",
poll: {
name: "¿Qué te parece el nuevo proveedor?",
values: ["Excelente", "Bueno", "Mejorable"],
selectableCount: 1 // Optional, default: 1
}
});Intelligent Buttons (Easier! 🔘)
The provider is now "intelligent" and accepts multiple formats for buttons.
// 1. Super Simple (Quick Replies)
await provider.sendButton({
from: "573123456789",
title: "Main Menu",
buttons: ["🛒 Catalog", "🎁 Promotions", "📞 Support"]
});
// 2. Mixed Format (Text & Functional buttons)
await provider.sendButton({
from: "573123456789",
title: "Payment Options",
body: "Select your preferred method",
buttons: [
{ type: "reply", displayText: "Cash" },
{ type: "url", displayText: "Visit Web", url: "https://example.com" },
{ type: "copy", displayText: "Copy Coupon", copyText: "SAVE20" },
{ type: "pix", displayText: "Pay with Pix", keyType: "email", key: "[email protected]" }
]
});Supported Button Types:
reply: Standard quick reply button.url: Opens a website.call: Triggers a phone call.copy: Copies text or code to clipboard.pix: Brazilian payment system integration.
Intelligent Lists (Simple & Advanced 📜)
// Simple List (Array of strings)
await provider.sendList({
from: "573123456789",
list: {
title: "Select an option",
button: "View Options",
content: ["Option 1", "Option 2", "Option 3"],
},
});
// Advanced List with sections
await provider.sendList({
from: "573123456789",
list: {
title: "Product Categories",
button: "Select Category",
content: [
{
title: "Electronics",
rows: [
{ title: "Smartphones", description: "Latest models" },
{ title: "Laptops", description: "Gaming and office" },
],
},
],
},
});Media Messages
// Images, Videos, Documents, and Voice
await provider.sendImage({ from: "573123456789", url: "https://...", text: "Caption" });
await provider.sendVideo({ from: "573123456789", url: "https://...", text: "Caption" });
await provider.sendFile({ from: "573123456789", url: "https://...", fileName: "file.pdf" });
await provider.sendVoice({ from: "573123456789", url: "https://..." });🔄 Queue Flow System (100% Automatic)
The Queue Flow system manages user sessions, handling timeouts and inactive users automatically.
const provider = createSendWaveProvider({
name: "MyBot",
apiKey: "your-key",
queueFlow: {
enabled: true,
warningTimeout: 30 * 60 * 1000, // 30 mins
endTimeout: 2 * 60 * 1000, // 2 mins after warning
warningMessage: "⏳ You seem inactive. Still there?",
},
});🎯 Event System
provider.on('ready', (isReady) => console.log('Connected:', isReady));
provider.on('message', (ctx) => console.log(`From ${ctx.from}: ${ctx.body}`));🏗️ Architecture
- Provider Layer: Main SendWaveProvider class.
- Sender Layer: Intelligent message transformation.
- Queue Flow: Automatic session management.
📜 License
ISC License © 2026 - Ameth Galarcio
