Node.js SDK
Messegy is the ultimate WhatsApp management tool for your business.
The official Node.js SDK enables your team to seamlessly integrate and send WhatsApp messages.
View on NPMInstallation
Install the package using npm:
npm install messegy
Quick Start
Here is a basic example of how to send a WhatsApp template message using the SDK:
import { sendWhatsAppMessage } from "messegy";
const res = await sendWhatsAppMessage({
phone: "7376750302",
templateName: "welcome_template",
variables: ["Rishabh"],
type: "utility",
language: "en",
apiKey: "your_project_key",
apiSecret: "your_project_secret",
});
console.log(res);
Parameters
The sendWhatsAppMessage function accepts the following parameters object:
| Field | Type | Required | Description |
|---|---|---|---|
phone |
string | Required | User phone number (auto-formatted to 91 if 10 digits) |
templateName |
string | Required | WhatsApp template name |
variables |
array | Optional | Template variables |
apiKey |
string | Required | Messegy Project Key |
apiSecret |
string | Required | Messegy Project Secret |
language |
string | Optional | Default: en |
type |
string | Optional | Template category (e.g. utility) |
Example with Media & Buttons
If your template includes a media header or interactive buttons, you can pass them as follows:
import { sendWhatsAppMessage } from "messegy";
const res = await sendWhatsAppMessage({
phone: "917376750302",
templateName: "messegy_welcome_user_v1",
variables: ["Rishabh"],
type: "utility",
language: "en",
apiKey: "your_project_key",
apiSecret: "your_project_secret",
// 🔹 Header (Required if template has a header)
header: {
type: "image", // image | video | document | text
value: "https://messegy.com/public/web/assets/images/logo.png",
},
// 🔹 Button (Optional)
button: {
type: "url", // url | quick_reply
value: "https://messegy.com",
},
});
console.log(res);
Response Format
The SDK returns a standard promise response:
// On Success
{
success: true,
data: { ... }
}
// On Error
{
success: false,
error: "Something went wrong"
}