Code Monkey home page Code Monkey logo

frontline-serverless's Introduction

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": "[email protected]",
};

Customers list

Example:

const customers = [
  {
    customer_id: 98,
    display_name: "Bobby Shaftoe",
    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",
      },
    ],
    worker: "[email protected]",
  },
];

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.

frontline-serverless's People

Contributors

bdm1981 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.