Channels

WhatsApp

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

OptionTypeMeaning
transportWhatsAppTransportRequired provider delivery implementation.
pluginsWhatsAppPlugin[]Optional transforms run before delivery.
hooksWhatsAppHooksOptional callbacks for delivery activity.

Message options

ShapeRequired fieldsUse
Templateto, template.name, template.languageBusiness-initiated delivery.
Textto, textAn 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

Learn more

Next

On this page