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 https://api.twilio.com, 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..!!!

22 comments:

  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 https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AZPi

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

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

    ReplyDelete
  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!!!

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

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

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

    ReplyDelete
  8. Hi Abhi,

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

    Could you help me for this?

    ReplyDelete
    Replies
    1. Hi Abhi,

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

      Delete
    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 ?

      Delete
    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.

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

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

      Delete
    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?

      Delete
  9. This comment has been removed by the author.

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

    ReplyDelete