This repository contains an example server-side web application that is required to use Twilio Frontline.
It creates the following routes that you will then need to add to your Twilio Frontline Console:
/callbacks/crm
/callbacks/outgoing-conversation
/callbacks/templates
/callbacks/routing
/callbacks/twilio-conversations
Detailed information can be found in the Node.js Quickstart.
- A Twilio Account. Don't have one? Sign up for free!
- Follow the quickstart tutorial.
- NodeJS (latest or LTS)
- Yarn
# install dependencies
yarn
# copy environment variables
cp .env.example .env
# run service
yarn run start
# Service variables
PORT # default 5001
# Twilio account variables
TWILIO_ACCOUNT_SID=ACXXX...
TWILIO_AUTH_TOKEN
# Variables for chat configuration
TWILIO_SMS_NUMBER # Twilio number for incoming/outgoing SMS
TWILIO_WHATSAPP_NUMBER # Twilio number for incoming/outgoing Whatsapp
The customer data can be configured in src/providers/customers.js.
For inbound routing: Used to determine to which worker a new conversation with a particular customer should be routed to.
{
customerAddress: workerIdentity
}
Example:
const customersToWorkersMap = {
'whatsapp:+87654321': '[email protected]'
}
In the CRM callback reponse, each customer object should look like this:
Example:
const customers = [
{
customer_id: 98, // required
display_name: 'Bobby Shaftoe', // required
worker: '[email protected]', // required
channels: [
{ type: 'email', value: '[email protected]' },
{ type: 'sms', value: '+123456789' },
{ type: 'whatsapp', value: 'whatsapp:+123456789' }
],
links: [
{ type: 'Facebook', value: 'https://facebook.com', display_name: 'Social Media Profile' }
],
},
//... more customer objects
];
Response format:
objects: {
customers: customers
}
If you experience issues running the Node.js server on port 5001
, you can use any other free port.
You can add PORT=xxxx
to the .env
.
Alternatively, you can edit it here. Note that the one from the .env
file will override the one on src/config.js.