Saturday 21 June 2014

#Salesforce Integration With Twilio

I was searching Twilio integration with salesforce on the web but didn't find any, so am posting this a simple POC of sending SMS to the mobile using Twilio from the Salesforce UI.

Its simple but just you need to do something extra two make this functionality working.

We will go step by step for this
First of all create a new account on Twilio click here 
Twilio will provide you a number, via which it will sent you SMS.

Now login to your salesforce account and create a Remote Site Setting.
In Remote Site URL enter, like shown below

And then create a custom setting named as Twilio Configuration.
We are gonna use them in our apex classes.
Create fields on the custom setting you've just created, with same API name as below shown.

Now we need to provide some values to the fields ofthe custom setting click on Manage button shown above.

Before entering any values to the fields click on these links
For Auth Token and Account SID Click Here
For Test Credetials i.e. Test Account SID and Test Auth Token Click Here

For Account Name enter the name from which you registered like your email id.
For From Phone Number enter that number which got when you created account on Twilio.
After that save your custom setting.

Custom Setting should look something like this

After that you can save the code provided here GitHub 

Page will look something like this

See that was a piece of cake :)
Hope everything works just fine.
Happy coding..!!!


  1. I am unable to receive the sms via twilio in sale force see this link I doing correct way are not can some one please help me

  2. GitHub link does not work.....

  3. I already have the Github code, where can I enter it?

  4. Hi Abhi ,
    I tried the above integration , but not able to send message ,

    I am getting "Phone number is not valid" issue . Can you please tell me what is the issue .
    I am entering proper mobile number with +91 code .Please help!!!

  5. Please send the issue on community and send me the link I will help you brief there, above code works if you go steps mentioned above.

  6. Hi Abhi ,
    I figured out the problem , Thanks for the response .
    By the way ,its a great blog .Keep it up :)

  7. Abhi , instead of json , can we send the data through xml?

  8. Hi Abhi,

    I am getting this issue.
    'Phone number is not valid'

    Could you help me for this?

    1. Hi Abhi,

      This Issue has been resolved but i am unable to get message on my Phone number.

    2. Twillio work for only few message to send on a particular number if you using free account. Which type of account you are using ?

    3. Yes i am sending Message to the Number which is Verified from Twilio because In case of Trail Account we can only use one number that is verified from Twilio as you said But still Unable to get message on that number.

    4. Please recheck your code, that everything is working fine, and your not getting any exception, are getting response from twillio ?

    5. I already checked it there is no Exception.
      If you want I can show you Response Which I got.

    6. Hi Abhi,

      This Issue has been Resolved Now I am able to Receive Message on Provided Mobile Number.
      Actually there was Some Mobile Network Issue .
      I Talked with Twilio Support and They Solved This Issue.

      Thank you for your Support.
      Still I have one Question Regarding This Integration.
      could You help me for this?

  9. This comment has been removed by the author.

  10. I already checked it there is no Exception.
    If you want I can show you Response Which I got.