Skip to content

Messaging

// Send a pre-approved template.
await client.messages.sendTemplate('15551234567', {
name: 'hello_world',
language: { code: 'en_US' },
});
// Send an interactive message with up to three reply buttons.
await client.messages.sendInteractiveButtons('15551234567', {
body: 'Did this answer your question?',
buttons: [
{ id: 'yes', title: 'Yes' },
{ id: 'no', title: 'No' },
],
});

Pass replyToMessageId as the trailing SendOptions argument on any sender to thread the outbound message as a reply. The SDK injects a root-level context: { message_id } into the request body.

// `incomingMessageId` is the WAMID of the message you are replying to.
await client.messages.sendText('15551234567', 'Thanks, got it!', undefined, {
replyToMessageId: incomingMessageId,
});
await client.messages.sendInteractiveCtaUrl('15551234567', {
body: 'Browse our latest collection.',
displayText: 'Open store',
url: 'https://example.com/store',
});

Prompts the user for a delivery address. country is required (IN or SG), and camelCase fields are mapped to the API’s snake_case shape for you. The submitted address arrives via webhook as an interactive nfm_reply whose response_json is a raw JSON string you parse yourself (see Webhooks).

await client.messages.sendAddressMessage('15551234567', {
body: 'Where should we deliver your order?',
country: 'IN',
values: { name: 'Ada Lovelace', phoneNumber: '15551234567', inPinCode: '560001' },
});

Mark an inbound message as read and show a typing indicator. It is dismissed once you send a message or after about 25 seconds.

await client.messages.sendTypingIndicator('wamid.HBgL...');

Independent open-source project. Not affiliated with, endorsed by or sponsored by Meta or WhatsApp. Released under the MIT licence. Source on GitHub.