In my last post, we looked at improving case management response time by sending real-time SMS.  In this post, we will incorporate real-time voice communication with case team members.  Case Management brings together ad hoc teams to assess, diagnose and resolve customer issues.  And, SLAs (Service Level Agreements) drive resolution urgency.  But, what happens if issues aren’t communicated in a timely manner?  What about the liabilities associated with missing your SLAs?

Twilio is a communications API platform company, which is always looking at ways to solve these problems through voice and SMS messaging.  In this post, you’ll learn to seamlessly integrate real-time voice conferencing into

Situation: A high priority Service Cloud case needs immediate resolution.  Initiate a voice conference call instantaneously and invite case team members to join the discussion.

As soon as your high value customer calls in to report a critical issue, the call center agent creates a case and assigns a case team to work on the issue. The case team manager decides to get the primary team members on a conference call and invite the secondary team members to join the conference in progress by sending details of the conference call via SMS message.

Figure 1: Salesforce Case Management Screen:

Clicking on the “Twilio Conference Call” button (Figure1: Annotation 1) triggers a conference call and calls the primary case team member(s) to join the conference in progress.  To make it user friendly, the call prompts the team member to press a key on the phone keypad to actually join to conference.  Additionally, the secondary case team member(s) are notified via SMS with details of the conference call in progress.

Figure 2: Received SMS from Salesforce via Twilio:

Figure 3: Conf call recording attached to case after the call:

Let’s dive into the code…


1) To begin, you’ll need an account with Twilio and a Twilio phone number (requires Twilio login).

2) You’ll also need a Salesforce account where you can do the development.

3) Next, you’ll need to install the Twilio Helper Library for Salesforce into your Salesforce org.

4) Finally, we need to create following custom object and fields:

a) Under User Object, create a custom field “Twilio_Conf_Number” of type Phone:


Next, Populate the Twilio Conf Number field in the user record (My Personal Information->Personal Information) with the phone number provisioned in step 1 for the current SFDC user.

b) Create a custom object called “Twilio_Case_Conf_Recording”.  The field “Case Number” has a master-detail relationship with the Case object.

Step 1:  Creating a button to initiate conference calling on Case Object

Create a button called ‘Twilio Conference Call” on the Case Object (Customize-> Cases-> Buttons, Links and Actions).    Add the following JavaScript code to the Detail Page Button.  This code executes an Apex web service (code follows in Step 2) and passes on parameters from the Case record to initiate the conference calling:

Step 2:  Creating the Apex Class to send conference call and SMS invite:

The Apex class has the sendConfInviteCaseTeam method that invokes the Twilio SMS and Voice APIs to send a SMS notification to the Case team members and outbound voice call to join the conference.

The method does the following:

1)    Gets the currently logged in user’s info (Name, Mobile Phone Number) as they will be the moderator of the conference call

2)    Instantiates a connection object to Twilio’s API

3)    Initiates an outbound voice call to the “moderator” of the conference and when answered, puts them into a Twilio conference

4)    Next, for each of the case team members:

  1. Sends a SMS with case details and the conference call phone number to dial-in
  2. For “Primary” case team members, also initiate a voice call and give them an option to join the call (Press 1 to join the call).

Note:  Replace variable SFDC_SiteUrl  in the code below with your Site Domain URL (

Step 3:  Creating the visualforce pages for Twilio callbacks:

As part of making an outbound voice call and callbacks from Twilio, following visualforce pages are needed.

Note: Please enable access to these pages for your site (App Setup->Develop->Sites)

Step 3.1: TwilioVoiceCaseConfCallModerator Visualforce page:

URL consulted by Twilio when dialing the moderator.

Step 3.2:  TwilioVoiceConfCaseCallParticipantGather Visualforce page:

URL consulted by Twilio when dialing the participants.

Step 3.4:  TwilioVoiceCaseConfCallPartGatherProc Visualforce page:

URL consulted by Twilio after the participant makes a selection.

Step 3.5:  TwilioVoiceCaseConfAfterRecording Visualforce page:

URL consulted by Twilio after the recording of the conference is ready.


By following the directions above, you should have an integrated conference calling feature within your Service Cloud instance.  If you have any questions or comments, please leave them below.

Twilio platform lets you provision phone numbers in real time, create conference calls, send and receive calls, send and receive SMS, create an IVR (Integrated Voice Response) to collect input, and record conference calls. Since the Twilio REST API helper library is written natively in, it’s easy to integrate with other Salesforce Objects or Case Management applications.

Ameer Badri is a Solutions Architect at Twilio focused on Fortune 500 companies and channel partner.  He has extensive experience implementing high volume and low latency transactional and analytics applications based on MPP architectures.  He loves disruptive technologies that challenge status quo and enable new business models.  Prior to Twilio, he worked at several startups, Salesforce and Oracle.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS