Members
content.createCallToActionTemplate
Creates a new call to action
content template.
Call to action templates include one or more buttons for the user to interact with. Each button triggers an action and is defined in the actions
array.
-
See:
-
Example:
const actions = [
{
type: connectors.verjio.twilio.content.actionType.URL,
title: 'Order details',
url: 'https://lunar.example.com/order.eb?id={{1}}',
},
{
type: connectors.verjio.twilio.content.actionType.URL,
title: 'Store locations',
url: 'https://lunar.example.com/branches.eb?postcode={{2}}',
},
{
type: connectors.verjio.twilio.content.actionType.PHONE_NUMBER,
title: 'Discuss your order',
phone: '+441234567890'
}
];
const variables = {
1: 'order_number',
2: 'post_code'
};
connectors.verjio.twilio.content.createCallToActionTemplate(
'cta_order_complete',
'Your Lunar Emporium order (#{{1}}) is now ready for collection.',
actions,
variables
);
content.createCardTemplate
Creates a new card
content template.
Card templates are made up of a title. Optionally, a subtitle and media can be specified. 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'
}
];
connectors.verjio.twilio.content.createCardTemplate(
'happybirthdayoffer',
'Happy birthday from Sandy\'s!',
'Why not celebrate with some free ice cream?',
actions,
'https://sandy.verj.cloud/images/birthday-cake.png'
);
content.createCarouselTemplate
Creates a new carousel
content template.
Carousel templates display a horizontal, scrolling list of cards
. Each card contains text, one or two action buttons and either an image or video. The cards are defined in the cards
array.
-
See:
-
Example:
const actions = [
{
type: connectors.verjio.twilio.content.actionType.URL,
title: 'Order now',
url: 'https://sandy.verj.cloud/shop.eb'
}
];
const cards = [
{
title: 'Pumpkin pie',
body: 'Cinnamon spiced pumpkin goodness.',
media: 'https://sandy.verj.cloud/images/pumpkin-pie.jpg',
actions: actions
},
{
title: 'Toffee apple',
body: 'Sweet, rich toffee with candied apple pieces.',
media: 'https://sandy.verj.cloud/images/toffee-apple.jpg',
actions: actions
}
];
const sid = connectors.verjio.twilio.content.createCarouselTemplate(
'autumn_flavours',
'Check our our new ice cream flavours for autumn!',
cards
);
content.createListPickerTemplate
Creates a new list picker
content template.
List picker templates contain a menu of up to 10 list items that a user can select from to trigger an action.
-
See:
-
Examples:
// Populate list from a Table
const services = [];
const rows = tables.services.fetchTable();
while (rows.next()) {
services.push({
id: `service-${tables.services.service_id.value.toLowerCase()}`,
item: tables.services.name.value,
description: tables.services.description.value
});
}
connectors.verjio.twilio.content.createListPickerTemplate(
'service_picker',
'Thank you for contacting the Lunar Emporium. How can we help?',
'Select a service',
services,
);
// Populate list from an array of values
const items = ['Cod', 'Haddock', 'Pollock', 'Plaice'].map(fish => ({
id: `product-${fish.toLowerCase()}`,
item: fish,
}));
connectors.verjio.twilio.content.createListPickerTemplate(
'fish_picker',
'Thank you for ordering fish and chips with Salty\'s. What fish would you like to eat?',
'Pick your fish',
items,
);
content.createLocationTemplate
Creates a new location
content template.
Location templates contain a location pin and an optional label.
-
See:
-
Example:
connectors.verjio.twilio.content.createLocationTemplate(
'big_ben_location',
51.510357,
-0.116773,
'Big Ben'
);
content.createMediaTemplate
Creates a new media
content template.
Media templates are made up of a textual message and a media file, defined as a URL.
The media URL can make use of variables but only after the domain, e.g. https://example.com/img/{{1}}
.
-
See:
-
Example:
connectors.verjio.twilio.content.createMediaTemplate(
'testimonial_with_logo',
'Hi {{1}}, as requested, here are some testimonials about our business: {{2}}',
'https://sandy.verj.cloud/clients/{{3}}',
{
1: 'first_name',
2: 'testimonial'
3: 'client_logo'
}
);
content.createQuickReplyTemplate
Creates a new quick reply
content template.
Quick reply templates let the user tap an action button, rather than type, to respond to a message.
-
See:
-
Example:
const actions = [
{
type: connectors.verjio.twilio.content.actionType.QUICK_REPLY,
title: 'Book a table',
id: 'book_table',
},
{
type: connectors.verjio.twilio.content.actionType.QUICK_REPLY,
title: 'Change reservation',
id: 'change_reservation',
}
];
connectors.verjio.twilio.content.createQuickReplyTemplate(
'table_booking_quick_reply',
'Hi, {{1}}. Thank you for contacting us. How can we help?',
actions,
{ 1: 'first_name' }
);
content.createTemplate
Create a new content template. The template, including its type(s), is defined using the params
object.
This method is used internally by the createXTemplate
methods, for example content.createMediaTemplate
.
content.createTextTemplate
Creates a new text
content template.
Text templates are the simplest templates and contain only a textual message.
-
See:
-
Examples:
const sid = connectors.verjio.twilio.content.createTextTemplate(
'simpleorderconfirmation',
'Your order {{1}} has been received.',
{ 1: 'order_number' }
);
fields.content_sid.value = sid;
// Specify a template in another language
connectors.verjio.twilio.content.createTextTemplate(
'germanorderconfirmation',
'Ihre Bestellung {{1}} ist eingegangen.',
{ 1: 'order_number' },
'de'
);
content.deleteTemplate
Delete a specified content template.
Example:
if (connectors.verjio.twilio.content.deleteTemplate(fields.content_sid.value)) {
event.owner.addInfoMessage('Template deleted successfully.');
}
content.getAllTemplates
Retrieve all existing content templates.
Example:
try {
const templates = connectors.verjio.twilio.content.getAllTemplates();
if (templates) {
event.owner.addInfoMessage(`Fetched ${templates.length} templates.`);
}
}
catch (e) {
event.owner.addErrorMessage(`Error when attempting to fetch templates: ${e.message}`);
}
content.getTemplate
Retrieve a specified content template.
Example:
const template = connectors.verjio.twilio.content.getTemplate(fields.content_sid.value);
content.getTemplateApprovalStatus
Retrieve approval status for a specified content template.
Example:
const content = connectors.verjio.twilio.content.getTemplateApprovalStatus(fields.content_sid.value);
if (content) {
event.owner.addInfoMessage(`WhatsApp approval status: ${content.whatsapp.status}`);
}
content.searchTemplates
Retrieve existing content templates that match specified searches.
-
See:
-
Examples:
// Search for all templates that include the phrase 'birthday'
const templates = connectors.verjio.twilio.content.searchTemplates('birthday');
event.owner.addInfoMessage(`Found ${templates.length} matching templates.`);
// Search for all templates created before a timestamp
const start = new Date('October 2, 2024 09:30:00').toISOString();
connectors.verjio.twilio.content.searchTemplates(null, { DateCreatedBefore: start });
content.submitTemplateForApproval
Submit an existing content template for approval for a specified messaging service.
Example:
// Fetch a content template and submit it for approval
const template = connectors.verjio.twilio.content.getTemplate(fields.content_sid.value);
connectors.verjio.twilio.content.submitTemplateForApproval(
template.sid,
template.friendly_name,
connectors.verjio.twilio.messagingService.WHATSAPP,
{ category: connectors.verjio.twilio.content.whatsAppCategory.UTILITY }
);
helpers.validateTemplateName
Validates a content template name..
helpers.validateTwilioId
Validates a Twilio ID. Each ID type has its own two-letter prefix. Note that this is just an indication of whether the ID is in the correct format and does not attempt to determine whether the ID is in use.
Example:
// Validate a Twilio Account SID
if (connectors.twilio.helpers.validateTwilioId(accountSid, 'AC')) {
log('Account SID is valid!');
}
helpers
A collection of helper methods for formatting and querying API data.
Example:
connectors.verjio.twilio.helpers.formatPhoneNumber('5555551234', '1');