Send messages and templates
Use a configured WhatsAppClient from Install and verify. Examples below assume it is named whatsapp. Application callbacks such as db, myDatabase, and queue are supplied by your app; fileBlob is the Blob you intend to upload.
Messages
await whatsapp.messages.sendText("201234567890", "Text body");
await whatsapp.messages.sendImage("201234567890", {
link: "https://example.com/image.jpg",
caption: "Image caption",
});
await whatsapp.messages.sendDocument("201234567890", {
id: "MEDIA_ID",
filename: "invoice.pdf",
});
await whatsapp.messages.react("201234567890", "wamid.message-id", "👍");
await whatsapp.messages.markRead("wamid.inbound-message-id");Templates
await whatsapp.templates.createTemplate({
name: "order_update",
language: "en_US",
category: "UTILITY",
components: [
{ type: "BODY", text: "Your order {{1}} is ready.", example: { body_text: [["A100"]] } },
],
});
const templates = await whatsapp.templates.listTemplates();
const template = await whatsapp.templates.getTemplateByName("order_update");
if (template?.id) {
await whatsapp.templates.updateTemplate(template.id, {
components: [{ type: "BODY", text: "Your order {{1}} has shipped." }],
});
}
await whatsapp.templates.deleteTemplate("order_update");Send an approved template:
await whatsapp.messages.sendTemplate("201234567890", {
name: "order_update",
language: { code: "en_US" },
components: [
{
type: "body",
parameters: [{ type: "text", text: "A100" }],
},
],
});Source captured: 2026-10-11