When you are working as a support user and a high-priority case is created in Salesforce, we can automate the process of sending an email using a flow.
Now, what if we also want to send an SMS from Salesforce when any condition is met to defined criteria? Therefore, we need to use a third-party messaging app or API integration for this purpose.
In this blog, we will understand how to configure Twilio in Salesforce and send SMS from Salesforce using Twilio.
What is Twilio?
Twilio is a cloud communications platform-as-a-service (CPaaS) that enables developers to add communication features, such as voice, messaging, video, and email, to their applications using APIs.
It enables businesses to create and manage customer engagement experiences across various channels, including contact centers, SMS notifications, and more.
Twilio offers an app for Salesforce that enables seamless integration of Twilio’s power with Salesforce. There can be many use cases where we can integrate Twilio with Salesforce.
Below, you can see some of the use cases of integrating Twilio with Salesforce:
- We can send a welcome text to the users or customers.
- We can send a critical alert to administrators, notifying them about urgent changes or issues within the Salesforce organization.
- Sending an alert to the account manager when a case gets escalated.
Set Up the Twilio Platform
Before we begin our solution, we need to set up Twilio. To get Twilio up and running, we need to complete the following tasks to connect it to our Salesforce organization.
1. Sign Up for Twilio
You can read more about and get the Twilio tool you need to navigate at their official website.
In the first step, we need to set up a Twilio account. To do so, click the “Start for free” button and use it for demo purposes.
Then the signup page will open. There, you need to provide a few basic details, including your name, email address, and password. Then click the continue button.

After you have successfully signed up, you will receive an OTP at the email address you provided. You need to enter that OTP, and then you will be redirected to the phone number page.
As you provide the phone number, click the “Send code via SMS” button, or choose an alternative option. After that, you will receive the OTP that you need to provide for verification.

2. Create a New Twilio Account
Now you need to click the Create New Account button, then provide the details for the purpose you are going to use the Twilio platform.
After filling in the details, click the “Get Started with Twilio” button.

3. Twilio Installation and Setup in Salesforce
Now, on the Twilio dashboard, you will see the search bar. There, you need to search for Salesforce and then select the App Installation and Setup to install Twilio in Salesforce.

Then, scroll down, and you will find the ‘Install and Configure Your Setup‘ section. There, you will get the AppExchange link. We need to open that link to install the Twilio app.

As you click on the link, you will see the screen below. There, you need to click on Install in Sandbox or Install in Production as per your requirement.
As you click the Install button, you need to log in to your org with your username and password.

As you click the Log In button, you need to choose whether you want to install it only for the admin or for all users.
Then click the Install button to install the App in Salesforce. This process is the same as installing any other app or package from the AppExchange.

After the app is installed, you can check it by clicking on the App Launcher, and from there, you can search for Twilio. Then, under “Apps,” you can see that the app has been installed successfully.

4. Get a Twilio Phone Number for Trial
Now navigate to the Twilio dashboard to get the phone number. You will get a phone number immediately from your Twilio account. That phone number will be used for the messaging service in Salesforce.
Here, you need to click the ‘Get Number‘ option. 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.
Once you get a phone number, create a message service in your account. You need to provide the service name. That service name you will use later while building a solution in the Salesforce Org.

Once you are in your account, you will see your account details. So here we have two important details to note:
- Account ID.
- Auth Token.
We will need these two things in Salesforce to establish a connection between the two platforms. These are like a username and a password.

5. Important Step
In the above steps, we have installed the Twilio package in Salesforce, and now it’s time to check a few things. This is a very important step because we need to assign permission to our users that comes with the package.
For that, navigate to the logged user account and open the Permission Set Assignment. There, we need to give Twilio permission to the user.
There, we need to check that the user has the required Twilio permission sets before using Twilio. If not, assign the below permission set to users:

Check out Atlas Reasoning Engine in Salesforce Agentforce
Configure the Twilio account in the Salesforce org
In the steps below, I will explain how to connect the Twilio account to Salesforce and how to enable the messaging service for Salesforce.
1. Connect Twilio to Salesforce Org
Now, from the App Launcher, select the Twilio app and open the Twilio Configuration tab.
If you have completed all the above steps correctly and the admin user you are using for this configuration has the necessary permissions, they will see the screen below.
Here, you need to enter the Account SID and the Auth Token as noted in the above step, and click the Validate Credentials button.

Now, again, we need to provide some details. So, first we need to Select Message Service. As you click on it, you will not see anything because first we need to create a service.
Therefore, navigate to your Twilio account again, and we will create a messaging service for Salesforce.

2. Create Messaging Service
A messaging service in Twilio consists of a group of phone numbers that are managed together, which helps us to:
- Avoid problems with text message formatting.
- Use phone numbers from different countries.
- Send mass messages more smoothly.
To create a messaging service, open the Messaging Services page in the Twilio Console and click on Create Messaging Service.

Now, the Messaging Service Setup will open, and we need to provide our messaging service name, which can be found in the Salesforce org. For example, Connect to Salesforce.
After that, click the Create Messaging Service button to establish the new messaging service.
Check out Best Practices For Implementing Agents in Salesforce Agentforce

We already have the phone number created in the ‘Get a Twilio Phone Number for Trial’ step. We can now proceed through the messaging service setup wizard.
For now, click the “Skip Setup” button. Then, we will go through each setup step one by one, later, and in more detail.

Now the messaging service is ready, we just need to click the Save button to create it. After creating the service, we need to add a phone number to the created service.

You can now see that the Connect to Salesforce messaging service has been created successfully. To add the phone number, we need to open the service that we have created.

As you open the service, you will see the Sender Pool. There, you need to click the “Add Senders” button.
Then, on the Add Senders panel, ensure the Sender Type is set to ‘Phone Number’ and click ‘Continue’.

Now select the number that we added, and click the Add Phone Number button. After that, it will get assigned to the messaging service that we created for Salesforce.

3. Select Messaging Service in Salesforce
Now, again, navigate to Salesforce, open the Twilio app, and the Twilio Configuration tab. You can now select your messaging service that we created in the above step from the Select Message Service drop-down. Then, click Validate Credentials.

Once your Twilio Account SID, Auth Token, and messaging service have been validated, you’ll see the full list of configuration options appear on the Twilio Configuration page:
Now we have successfully set up the Twilio app in our Salesforce org and are ready to use the functionality provided by it.

Create a Flow to Send SMS From Salesforce
There are multiple use cases for Twilio SMS alerts, so we will create a flow to send an SMS when a high-priority case is created. Then, we will send a text alert to the contact person and notify them about the case by sending a text message to their mobile phone.
As per our use case, when a “High” priority case is created, send an SMS alert to the contact of that account, if a mobile number exists. If a mobile number does not exist, send an email instead.
In the following steps, I will explain how we can create a flow to send SMS to the contact.
Check out Create Image Cropper in Salesforce Lightning Web Component
1. Create Record-Triggered Flow
Click on the Setup. -> Home Page. -> In Quick Find Box, Search for Flows. You will see an option under Process Automation. -> Click on Flows.
Click the New Flow button -> Start From Scratch -> Record-Triggered Flow -> Create.
Now, we will create the following elements in the flow according to the flow diagram displayed in the following diagram.
In our scenario, we want to send an SMS when a new case is created. I have selected the Case object in the Object field, and in Configure Trigger, I have selected ‘A Record is created‘.
Then, we have to Set Entry Conditions, and in the Condition Requirement option, we have to select All Conditions Are Met(AND).
The flow should trigger only when the Priority field value is High.
In the Optimize for option, we need to select Action and Related Records.

Now create a Text Variable to store the contact ID to refer to the created case.

2. Add Assignment Element
Then add the Assignment Element to store contact IDs of newly created cases. Then in the Variable, add the created variable from the above step, which equals the Contact ID from the Case object.

3. Add Get Records Element
Now, add the Get Record element to get the contact details because we need to get the phone number and email from the contact object.

4. Add Twilio Send SMS Message Action Element
Add the Action element to send the SMS from Salesforce using the Twilio app. Then, in the Search Action bar, search for the SMS. There, you will find the Twilio Send SMS Message action. Click on it.

In the action element, provide a Label, and the API Name will be automatically populated.
Then we need to set input values for the selected action.
In the Message option here, I have created a Text Template where I customized the Message. In the next step, I have shown the text template image.
Then, in the To Mobile Number option, we need to provide the customer’s phone number. In our scenario, this is already available in the contact object.

Below, you can see I created a Text Template resource type and customized the message with some case fields. Then, I added this template to the Action element in the Message option.

5. Save, Debug, and Activate Flow
After creating the flow, we need to save it. Then, before activating the flow, we should always debug the flow to check whether it is working correctly. Finally, we can activate the flow.

Check out Agentforce 2.0 | Digital Labor Platform in Salesforce
Proof of Concept
After activating, navigate to the app console, where I will demonstrate whether Salesforce can send SMS to the number by creating a new contact and case.
First, I have created a contact and provided a name for clarity. You must provide your name as per your requirements. When entering your mobile number, ensure you include the country code to receive the SMS.

Now I’m creating a case for the contact that I’ve just created. You can see I provided the subject, priority set too high because SMS will be sent only to the high-priority cases that we added the condition.

Now, as you navigate to the Message tab on the Twilio app, you will see that the message record has been created. There, you can see the message details like from number, to number, and delivery status.
It took the number we provided in the contact record and the From number we obtained when creating the Twilio account.

Finally, you can see the message that the receiver received, with the customized message we created in the Text Template resource within the flow.

In this way, we can send SMS from Salesforce using Twilio.
Conclusion
I hope you have got an idea about how to configure Twilio in Salesforce and send SMS from Salesforce using Twilio.
I have explained each step in detail, from creating a Twilio account, obtaining a phone number, installing the Twilio app, and connecting to the Salesforce org. After that, we set up some configuration of the Twilio app, and after creating the flow, we saw the proof of concept of how SMS is sent from Salesforce.
You may like to read:
- Create a Custom Spinner In Salesforce Lightning Web Components
- Agentforce 2.0 | Digital Labor Platform in Salesforce
- How to Send Email with Flows in Salesforce [ 2 ways]
- Send Email in Salesforce | Send Email through Quick Action Salesforce
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.