Improving Your Case Management Response Time with Twilio SMS

ameerAmeer is Solutions Architect at Twilio, specializing in building high volume, low latency solutions for customers. He has over 15 years of experience in building solutions. The following is syndicated content, originally published on Salesforce’s developer blog.

When it comes to case management, the shorter your response time is the happier your customers will be. I recently published an article on Salesforce’s development blog, showing you how to improve your case management response time using a Twilio SMS integration.

Situation Trigger SMS alerts to Case Team Members for High Priority Cases

One of your customers has called to report a critical issue. The call center agent
creates a “high” priority case and assigns a case team to work on the issue.


Creating the case fires a trigger that notifies the assigned team member(s) via SMS.  The entire team is simultaneously notified, enabling them to understand the issue and to start resolving it as quickly as possible.


Let’s dive into the code…


  1. To begin, you’ll need an account with Twilio and a Twilio phone number (requires 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.

Step 1:  Creating a trigger on Case Object

This trigger calls an Apex method, which has all the business logic to produce a list of case team members, and the message that needs to be communicated via SMS.

Step 2: Creating the Apex method to send SMS message

The Apex method “TwilioSMSAsync.sendSMSCaseTeamList” has the business logic
to determine when to send the SMS message. In our use case, we want to send the
SMS when the Priority of the case is ‘High’ (seen annotation 1 in Figure 1) and to
the entire assigned case team (see annotation 2 in Figure 1). The text message
is completely configurable by the developer. In the example code, we
specify the Case Number, Case Contact Name, their Account Name and a URL for the
SFDC case record in the SMS message.

Note: The method sendSMSCaseTeamList is specified as @future(callout=true) since
it asynchronously makes external calls to Twilio REST APIs when the trigger fires.

The Apex method does three things in the following order:

a) Gets the case details for creating the SMS message body
b) Gets the list of case team members associated with the case
c) Using the Twilio SMS API, sends a SMS to each of the case team member in


Now, you have a working example of sending SMS in real-time to case team
members, enabling the service support team to respond to critical customer
issues effectively. Since the Twilio REST API helper library is written natively in, it’s easy to integrate with other Salesforce Objects or Case Management
applications like ServiceMax.

In future posts, we’ll show you how to extend this further so your case team
members can respond to the SMS message, essentially, creating a bi-directional SMS
messaging system.

Twilio provides the tools to solve a wide range of communications needs. For
instance, with Twilio’s helper library, we can implement:

  • Click to call: Easily integrate Click2Call within or any website
  • Conferencing: Enable Conference calling within Salesforce
  • Interactive Voice Response (IVR) System: Build context aware IVR systems based on Salesforce data.

Find out more about Twilio solutions here