Frontline Integration Service Example

This repository contains an example server-side web application that is required to use Twilio Frontline.

Prerequisites

  • A Twilio Account. Don't have one? Sign up for free!
  • Follow the quickstart tutorial here.
  • NodeJS (latest or LTS)
  • Yarn

How to start development service

# install dependencies
yarn

# copy environment variables
cp .env.example .env

# run service
yarn run start

Environment variables

# Service variables
PORT # default 5000

# Twilio account variables
TWILIO_ACCOUNT_SID=ACXXX...
TWILIO_AUTH_TOKEN
TWILIO_SSO_REALM_SID=JBXXX...

# Variables for chat configuration
TWILIO_SMS_NUMBER # Twilio number for incoming/outgoing SMS
TWILIO_WHATSAPP_NUMBER # Twilio number for incoming/outgoing Whatsapp

Setting up customers and mapping

The customer data can be configured in src/routes/callbacks/crm.js.

Quick definition of customer's objects can be found below.

Map between customer address + worker identity pair.

{
    customerAddress: workerIdentity
}

Example:

const customersToWorkersMap = {
    'whatsapp:+87654321': 'john@example.com'
}

Customers list

Example:

const customers = [
    {
        customer_id: 98,
        display_name: 'Bobby Shaftoe',
        channels: [
            { type: 'email', value: 'bobby@example.com' },
            { type: 'sms', value: '+123456789' },
            { type: 'whatsapp', value: 'whatsapp:+123456789' }
        ],
        links: [
            { type: 'Facebook', value: 'https://facebook.com', display_name: 'Social Media Profile' }
        ],
        worker: 'joe@example.com'
    }
];

Detailed information can be found in Quickstart, provided by Frontline team.