Twilio for Salesforce Prerequisites
Create a Twilio Account, if you don’t have it yet.
MyDomain is configured for your Salesforce Instance.
Create Twilio Account and Login
To start working with the Twilio app, we have to create a Twilio account first by using the below link: https://www.twilio.com/try-twilio
To Login with Different Salesforce Account:
Open the above link and click on “Install in Sandbox” and When prompted, select Install for All Users:
Check the Yes, grant access to these third-party websites checkBox and then click on “Continue”
Once Twilio is successfully installed, search Twilio configuration from the Salesforce App Launcher and complete the below page:
Don't forget to check out: 3 Best SMS API Providers Other Than Twilio For SMS In Salesforce
Set Account SID and Auth Token (Validate)
Click on login and login with your credential that opens the Twilio console, if you have already created an account of Twilio otherwise go to STEP given in below Topic of Create a Twilio Account.
Now copy and paste the Account SID and Auth Token from Twilio console to Salesforce Twilio configuration page and click on “Validate Credentials”.
Create a messaging Service to Add On Salesforce
A Messaging Service is a pool of Twilio telephone numbers that are empowered with programming to forestall text encoding issues, give global telephone numbers, and scale informing limits. Twilio for Salesforce uses a messaging service to provide phone numbers for SMS.
Steps to create messaging service are given below:
Snap-on the "Programmable Messaging" symbol and Select "Informing Service", and afterwards click on the "Make Messaging Service" button. Presently, Give "Message Service Name" and pick "Informing Service Use Case" and afterwards click on the make Button.
Now, Give “Message Service Name” and choose “Messaging Service Use Case” and then click on create Button.
Add Phone Numbers to your Messaging Service
We’ll add a phone number to your Messaging Service by which we can send SMS to the user.
In the left sidebar click on the “Phone Number” icon, then click on “Buy a Number”.
Select the country to buy the number of that country and click on the “Search” button.
After clicking on the Search button, there is a list of Numbers displayed on the Screen.
Now, you can choose any one by clicking on the “Buy” button.
Whenever you've bought your first telephone number, you should see it show up in your Messaging Service:
Receiving Message in Salesforce By Creating a webHook
Then, we need to give directions to disclose to Twilio how to deal with inbound messages. This progression is vital for you to see your approaching messages inside Salesforce.
On the off chance that this isn't arranged, your approaching messages will be set apart as Failed Error: 30008 and won't be matched up to Salesforce.
To handle inbound requests, we need to create a TwiML Bin with an empty <Response /> TwiML verb and then add that TwiML Bin’s handler URL as our webhook.
NOTE: Twilio uses webhooks to let your application know when events happen, such as receiving an SMS message or getting an incoming phone call.
Go to TwiML Bin > Create new TwiML Bin >
Create a TwiMl Bin with Name: TwiML Bin with an empty which is given as follows.
Click on Create and then Copy :
Then Click On Save Button
Now, Go to Your Message Service “Connect to Salesforce” and then Click on Integration and Copy the callback URL.
And Finally, click on Save.
Add Twilio Component to Salesforce Page Layout
Open the contact page Layout in your salesforce org and go to the edit page Layout.
Click on the Visualforce page and Drag-drop the “Twilio- Two Message” component to the layout and click on Save.
Add User to Twilio Permission Set
Twilio usefulness ought to be split between the two new authorization sets that were added to your association during establishment: Twilio User and Twilio Administrator.
On the Permission Set page, click on Manage Assignments and assign a user.
Now, we are able to send and receive one to one messages on the contact record page.