Channels
Send template or session text messages through a WhatsApp transport.
Use WhatsApp for customer messages sent through a WhatsApp provider transport. Send a template for business-initiated delivery, or text during an open customer-service window.
The one rule
Use templates for business-initiated messages outside the 24-hour customer-service window.
import { createWhatsAppSender } from "sently/whatsapp";
import { WhatsAppCloudTransport } from "sently/transports/whatsapp-cloud";
const whatsapp = createWhatsAppSender({
transport: new WhatsAppCloudTransport({
accessToken: process.env.WHATSAPP_TOKEN!,
phoneNumberId: process.env.WHATSAPP_PHONE_NUMBER_ID!,
}),
});const result = await whatsapp.send({
to: "15551234567",
template: {
name: "welcome",
language: "en_US",
},
});
console.log(result.messageId);Sender configuration
| Option | Type | Meaning |
|---|---|---|
transport | WhatsAppTransport | Required provider delivery implementation. |
plugins | WhatsAppPlugin[] | Optional transforms run before delivery. |
hooks | WhatsAppHooks | Optional callbacks for delivery activity. |
Message options
| Shape | Required fields | Use |
|---|---|---|
| Template | to, template.name, template.language | Business-initiated delivery. |
| Text | to, text | An open 24-hour customer-service window. |
Template messages may include template.components for header, body, or button parameters.
await whatsapp.send({
to: "15551234567",
text: "Thanks—we received your reply.",
});Troubleshooting
Free text is valid only during an open customer-service window. Use a pre-approved template outside that window.
Yes. Construct the sender with another WhatsAppTransport; message shapes remain template or text.
whatsapp.verify() delegates to the transport when available; otherwise it reports a successful sender result.