Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

twilio-labs/frontline-salesforce-serverless-quickstart

Repository files navigation

Twilio Frontline Salesforce CRM Integration

NOTE: Effective February 9, 2023, Twilio Frontline is limited to existing Frontline accounts only. New and existing Twilio customers without previous access to Frontline will not be able to get Frontline through Twilio's Console nor access developer documentation. For more information, please check out the Twilio Frontline Support documentation.

This Twilio Functions service implements the Frontline callbacks and Conversations callbacks to faciliate inbound and outbound SMS and WhatsApp support for Twilio Frontline based on Contact ownership in Salesforce.

How it works

The Functions implement the following Frontline and Conversations callbacks:

Frontline

Conversations

Screenshots

The following screenshots show the Frontline worker screens for SMS as well as Frontline worker WhatsApp template selection and customer receipt of the WhatsApp template:

Customer List and Details

Outbound SMS Conversation

Outbound WhatsApp Templates

Pre-requisites

To deploy these Frontline Functions, you will need:

  • An active Twilio account with Frontline and approved WhatsApp Senders and Templates
  • SSO configured for your Frontline instance. This ensures that the Salesforce and Frontline accounts can be linked securely using a common SSO identity provider.
  • A new, unique Sync service SID within the Frontline Twilio account to cache Salesforce access tokens
  • npm version 5.0.0 or later installed (type npm -v in your terminal to check)
  • Node.js version 12 or later installed (type node -v in your terminal to check)
  • Twilio CLI along with the Serverless Plugin. Run the following commands to install them:
    # Install the Twilio CLI
    npm install twilio-cli -g
    # Install the Serverless Plugin
    twilio plugins:install @twilio-labs/plugin-serverless
  • Salesforce Developer or Sandbox Org. with System Administrator access

Salesforce Connected App

Create a Salesforce Connected App under Salesforce Setup > App Manager > New Connected App with at least Access and manage your data (api) and Perform requests on your behalf at any time (refresh_token, offline_access) OAuth scopes. The Callback URL can be https://login.salesforce.com/services/oauth2/success and is only used during the initial setup.

Select "Use digital signatures" and follow Salesforce's instructions to Create a Private Key and Self-Signed Digital Certificate

  • Upload the resulting server.crt file to Salesforce by selecting "Choose File" next to "Use digital signatures"
  • Place your private key server.key in a cloned version of this respository at the path assets/server.private.key
  • Authorize your Salesforce Org. Using the JWT Bearer Flow

Functions Setup

  1. Clone this repo:
git clone https://github.com/twilio-labs/frontline-salesforce-serverless-quickstart
  1. Install the dependencies
# Install the dependencies of the Twilio Functions
npm install
  1. Copy the .env.example file
cp .env.example .env
  1. Edit .env:
  ACCOUNT_SID=Found at https://www.twilio.com/console
  AUTH_TOKEN=Found at https://www.twilio.com/console 
  SF_CONSUMER_KEY=Your Salesforce Connected App OAuth Client ID
  SF_USERNAME=The username to make JWT bearer token Salesforce API calls for inbound callbacks lacking user context to the webhook request
  SFDC_INSTANCE_URL=Your Salesforce instance URL, e.g. https://abc-dev-ed.my.salesforce.com
  WHATSAPP_NUMBER=WhatsApp number for outbound conversations proxy address
  SMS_NUMBER=SMS number for outbound conversations proxy address
  DEFAULT_WORKER=The default Frontline worker for inbound conversation routing if no matching Contact Owner is found in Salesforce
  SYNC_SERVICE_SID=The Sync Service SID used to store Salesforce access tokens

Development

In order to develop locally, you can use the twilio-run CLI by running (from the root directory):

# Start Twilio Functions
twilio serverless:start

This will automatically start up the Twilio Serverless local development server. Your app will run on http://localhost:3000.

Deploy

When you are ready, deploy your Twilio Functions:

twilio serverless:deploy

About

A code example of integrating salesforce for Frontline callbacks

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published