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, that is always looking at ways to solve these problems through voice and messaging. One great way to solve this case management is through SMS, one of the most efficient and ubiquitous ways to communicate. In this post, we’ll show you how to seamlessly integrate real-time SMS messaging into your Salesforce.com installation.
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.
Figure 1: Salesforce Case Management Screen
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…
- To begin, you’ll need an account with Twilio and a Twilio phone number (requires login).
- You’ll also need a Salesforce account where you can do the development.
- 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.
Create an “after insert” and “after update” trigger on Case.
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 Force.com 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:
- Gets the case details for creating the SMS message body
- Gets the list of case team members associated with the case
- Using the Twilio SMS API, sends a SMS to each of the case team member in real-time
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 Force.com, it’s easy to integrate with other Salesforce Objects or Case Management applications like ServiceMax.
In future posts, I’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 Force.com helper library, we can implement:
- Click to call: Easily integrate Click2Call within Site.com or any website
- Conferencing: Enable Conference calling within Salesforce
- Interactive Voice Response (IVR) System: Build context aware IVR systems based on Salesforce data