Combine the power of Salesforce and Twilio to send critical SMS alert from your salesforce Org.

Combine the power of Salesforce and Twilio to send critical SMS alert from your salesforce Org.

Twilio is an customer engagement platform. It helps organizations and brands to have a better engagement and communication with users. You can read more about Twilio at their official web site - https://www.twilio.com/

Twilio has a exclusive app for salesforce. You can use this app and can integrate the power of Twilio with Salesforce.

There can be very useful use cases where we can integrate Twilio with salesforce. Few of them are -

  • Sending welcome text to the users.
  • Sending any critical alert to admin.
  • Sending alert to the account manager when a case get escalated.
  • Sending reminders text.

There are numerous examples where we can use Twilio in salesforce. We can send customized and automatic SMS from process builders, Flows, record pages and also from REST API.

For this article, I have picked up a very basic use case that once a case gets created in the salesforce org and the case priority is High, send an SMS alert to the contact of that case.

Before we get started on our solution, we need to perform following tasks to get the Twilio up and running and also connected with our salesforce org.

  1. Sign up with Twilio , you can sign up for a trial account.
  2. Configure Twilio in Salesforce org.
  3. Build the Salesforce solution to integrate Twilio. We will create a record triggered flow for this article. You can also build process builder (I know at some point of time, process builder will go away) or you can also use Apex classes.
  4. Test your solution

Sign up with Twilio :

First steps is, we need to have a Twilio account set up. You can have a free trial account created and use that for demo purpose. You need to provide few basic details along with your email ID and phone number.

No alt text provided for this image

2. Install Twilio in your sandbox:

After you have successfully signed up, you will get an option to install Twilio in your salesforce org.

Once you login to your org with the user name and password. You need to choose that do you want to install it only for admin or for all users. This is same as installing any other app/package from app exchange so nothing special.

Please note Twilio creates few components in your org e.g. It installs few Apex classes, permission sets, objects etc.

No alt text provided for this image
No alt text provided for this image

3. Get a Phone Number from Twilio and set up your account:

Don't worry, you need to get a subscription for that but you will get a phone number immediately from your Twilio account. That phone number will be used for messaging service.

You will also need to set up a messaging service in your account. You will need this messaging service name in salesforce while setting up your flow.

Please refer below image for more information. Since I already got a trial phone number , so in my screen you will see that you already have a trial phone number.

Once you get a phone number, create a message service in your account. You just need to provide service name. That service name you will use later while building a solution in salesforce org.

No alt text provided for this image

4. Take a note of your Twilio account details:

Once your are in your account, you will see your account details. Two important things to note is - 1. Account ID 2. Token.

These two things, you will need in salesforce while establishing connection between the two platforms. So please take a note of these. These are like username and password.

No alt text provided for this image

5. Configure Salesforce to use Twilio account:

In Step #2, we have installed the Twilio package in salesforce and now its time to check few things.

Imp things which we need to check

  • Check that user has the permission for required Twilio permission sets before using Twilio. If not, assign below permission set to users:

No alt text provided for this image

  • Check that Twilio App is assigned to the user. If not please assign that. You need it for set up and configure the app.
  • Configure the Twilio account in Salesforce org:

From the app launcher select Twilio configuration. If you have done all above steps correctly and if the admin user which you are using for this configuration has the right permissions he will see below screen. If not, then please check that you haven't miss any configuration for the user.

Here you need to enter AccountID and authentication token as noted above and validate the credentials.

No alt text provided for this image

Now we have successfully set up the Twilio app in our salesforce org and ready to use the functionality provided by it.

There can be multiple use cases for Twilio SMS alert but the one which I picked up for this article is, if a High priority case gets created then send a text alert to the contact person and notify him about the case by sending a text message on his mobile phone.

Create a Flow:

As per our use case, when a "High" priority case gets created, send SMS alert to the contact of that account, if mobile number exists and if mobile number does not exists then send an email.

Below are the complete description of the flow-

A. Initiate a record triggered flow , when a case object is created with Priority as "High".

B. Use the Get Record element to get the contact ID for the created case, store the contact ID in a variable. To refer the created case (record who triggered the flow), you have to use $record Global variable.

C. Use Get Record element to query the contact object to store contact's email ID and Mobile number in respective variables for the contact ID (stored in a variable in above step #B).

D. Next, I have used a decision box to check, if the mobile number is not null for that contact.

1. If mobile number is present, send text alert (Details of that action given below)

2. If Email ID is present and mobile number is not present then send email.

Please take a look at the pictorial view of complete Flow diagram -

No alt text provided for this image
No alt text provided for this image

All other elements which are used to create this flow are the regular flow element besides Apex Action to send SMS. So lets dive deeper and understand that -

Apex Action (Send Text): -

Drop an apex action in your flow canvas and configure it. If you filter the action by Type and search Twilio, you will see an action with the name Twilio send SMS, select and configure it. You need to provide what you want to send (i.e. text message content) and where you want to send (i.e. mobile number). We have already stored contact mobile number in a variable and that we will use in below action configuration.

No alt text provided for this image
No alt text provided for this image

That's it and you are all set to test and activate this flow. Thank you for reading.






要查看或添加评论,请登录

Gaurav Jain的更多文章

社区洞察

其他会员也浏览了