WhatsApp Cloud TS

Standard Messages API Reference

API definitions for sending free-form messages within the 24-hour customer service window.

All standard message functions require a to string (the recipient's WhatsApp ID) as the first parameter. Most also accept an optional MessageOptions parameter at the end to allow for replying to specific messages.

MessageOptions (Optional)

PropertyTypeDescription
replyToMessageIdstringProvide a wamid to send this message as a contextual reply to a previous message.
previewUrlbooleanIf true, Meta will attempt to load a rich preview for URLs present in a Text message.

sendText

client.sendText(to: string, text: string, options?: MessageOptions)

Sends a standard text message. Supports WhatsApp markdown formatting (*bold*, _italic_, ~strikethrough~).

sendImage / sendVideo / sendDocument

client.sendImage(to: string, url: string, caption?: string, options?: MessageOptions)
client.sendVideo(to: string, url: string, caption?: string, options?: MessageOptions)
client.sendDocument(to: string, url: string, filename?: string, caption?: string, options?: MessageOptions)

Sends media via a publicly accessible HTTP/HTTPS URL.

sendLocation

client.sendLocation(to: string, lat: number, lng: number, name?: string, address?: string, options?: MessageOptions)

sendInteractiveButtons

client.sendInteractiveButtons(
  to: string, 
  bodyText: string, 
  buttons: Array<{ id: string, title: string }>, 
  headerText?: string, 
  footerText?: string, 
  options?: MessageOptions
)
  • buttons: Max of 3 buttons. id max 256 chars. title max 20 chars.

sendReaction

client.sendReaction(to: string, messageId: string, emoji: string)

React to an existing message using a standard emoji character (e.g. "👍").