Skip to content

bdm1981/frontline-serverless

Repository files navigation

Frontline Integration Service Example

This repository contains an example serverless 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)
  • Twilio CLI - Setup Instructions

How to start development service

# install dependencies
npm install

# copy environment variables
cp example.env .env

# run service
npm start

# deploy project
npm run deploy

Environment variables

# Twilio account variables
ACCOUNT_SID=ACXXX...
AUTH_TOKEN

# Variables for chat configuration
SMS_NUMBER # Twilio number for incoming/outgoing SMS
WHATSAPP_NUMBER # Twilio number for incoming/outgoing Whatsapp

CUSTOMER_SOURCE=JSON

# OPTIONAL: Twilio Sync
SYNC_SERVICE=
SYNC_CUSTOMER_MAP=

Setting up customers and mapping

The customer data can be configured in functions/crm.protected.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",
  },
];

Optional Sync configuration

By default the customers list is sourced from the assets/customers.private.json file. This can also be stored in Twilio Sync. To pull contact information from Sync perform the following additional steps:

  1. Create a SYNC map in your Twilio account to store the customer data.
  2. Populate the Sync map with contact information in the same format referenced above.
  3. Update the .env file your SYNC_SERVICE, SYNC_CUSTOMER_MAP SIDs.
  4. Set the CUSTOMER_SOURCE=SYNC

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

About

This is a serverless version of Twilio Frontline Node.js Quickstart found here: https://www.twilio.com/docs/frontline/frontline-integration-service

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published