TwilioWhatsApp Data Connector

TwilioWhatsApp() → {object}

The Twilio WhatsApp Data Connector extends the functionality of the Twilio Data Connector. It provides functionality for sending WhatsApp messages.

Returns:
object

The Twilio WhatsApp Data Connector.

Members

createWhatsAppAuthenticationTemplate

Creates a new WhatsApp authentication content template.

WhatsApp authentication templates are used to deliver one-time passwords with a copy code button. The button text and code expiration can be customised.

See:
Example:
const actions = [
  {
    type: connectors.verjio.twilio.content.actionType.COPY_CODE,
    copy_code_text: 'Copy code'
  }
];

// Set the one-time code to expire after 15 minutes
const sid = connectors.verjio.twilio.content.createWhatsAppAuthenticationTemplate(
  name,
  actions,
  15
);

createWhatsAppCardTemplate

Creates a new WhatsApp card content template.

WhatsApp card templates are made up of either header text or media, followed by a message and an optional footer. WhatsApp cards also include one or more action buttons as defined in the actions array.

See:
Example:
const actions = [
  {
    type: connectors.verjio.twilio.content.actionType.PHONE_NUMBER,
    title: 'Call us to book',
    phone: '+441234567890'
  }
];

const sid = connectors.verjio.twilio.content.createWhatsAppCardTemplate(
  'happy_birthday_offer_wa',
  'Happy birthday from Sandy\'s! Why not celebrate with some free ice cream?',
  actions,
  null, // No header, as we are using media
  'https://sandy.verj.cloud/images/birthday-cake.png'
);

Functions

getWhatsApp(messageId) → (nullable) {object}

Gets details of a WhatsApp message that was sent via Twilio. This includes the status, the date and time the message was created and the date and time the message was sent.

Parameters:
Name Type Description
messageId string

The ID of the message to retrieve. This is included as the sid property of the response object of sendSms.

Returns:
object

Details of the message including sending status. Returns null if one or more parameters are omitted or invalid.

Example:
var response = connectors.verjio.twilio.getWhatsApp(tables.messages.messageId.value);
	if (response.status === connectors.verjio.twilio.sentStatus.SENT) {
		event.owner.addInfoMessage(`The message was sent ${response.date_sent}`);
	}

sendWhatsApp(to, contentId, contentDataopt, from, paramsopt) → (nullable) {object}

Send a WhatsApp message to a specified phone number.

Parameters:
Name Type Attributes Description
to string  

A phone number in E.164 format.

contentId string  

SID of the preconfigured content template.

contentData object <optional>

Optional object containing the values of any placeholder variables in the content template.

from string | object  

Message sender. This can be the SID of a Messaging Service, a phone number as a string or an object, as returned by Twilio.getPhoneNumber. The sender must be available to the Twilio account. This must be a pre-configured WhatsApp sender.

params object <optional>

Additional parameters to send.

See:
Returns:
object

Details of the message, or null if there was an error.

Example:
// Send a WhatsApp message
// A Messaging Service is used as the sender
var response = connectors.verjio.twilio.sendWhatsApp(
	connectors.verjio.twilio.helpers.formatPhoneNumber(tables.customer.mobile.value),
	'HX0cc2dc920fdcfcd834fa77dab742dbc6',
	{ 1: tables.customer.name.value },
	'MG5f55b8305e167f2563498a4bb41c2712'
);

Type definitions

WhatsAppCategory

Constants used to identify WhatsApp template categories.

These can be accessed via connectors.verjio.twilio.content.whatsAppCategory.

Properties:
Name Type Description
UTILITY string

The content template is usually triggered by a user action. Utility templates may provide confirmation or alerts, send feedback surveys or continue a conversation begun via a different messaging channel.

MARKETING string

The content template may generate product awareness, drive sales or promote products and services.

AUTHENTICATION string

The content template includes a one-time code. Authentication templates must conform to WhatsApp's preconfigured authentication messages.

See:
Copyright Ebase Technology 2024