Search code examples
apisalesforcetwiliovoicemail

Twilio integration


I am using twilio from salesforce (On a custom object) to call some numbers. Is there any way to send voicemails to those numbers without ringing there phone or with ring as least as possible . Will appreciate your help . Thanks!


Solution

  • Twilio developer evangelist here.

    The voicemail of someone else's phone is not under control by Twilio. So you can't directly leave a voicemail without ringing them. You also cannot control the number of rings someone else's phone will make before going to voicemail.

    Using Twilio, you could make calls to the numbers and play a message when they or their voicemail answers. This would either directly deliver the message to the user or record it on their voicemail.

    [edit]:

    After the discussion in comments below, here is an updated answer.

    I'll give an overview of the system I think you need to build. I can't be more specific, because I have little details of your system or what you've tried.

    I think you need to build in Twilio Client to your Salesforce application. You can watch a video on how to integrate Twilio Client with Salesforce.

    You can use this to generate the calls to your customers and speak to them from within Salesforce.

    To add to this, you also want to leave a message if you get a voicemail. You will need to do a few things to achieve this.

    First, you will need to store the Call Sid of the call you made in the browser. You can get this from the parameters attribute of the Twilio.Connection.

    You will need to add a button to your interface that is active when you are on an active call. This button needs to hook up to an endpoint in your Salesforce app. The button should send the Call Sid you saved from your connection to the app.

    Within the Salesforce app, you will need to build the endpoint for the above. This will receive the Call Sid as an argument. This Call Sid is the parent call and represents your connection to the call. We need to get the Child Call, which is the other end. We do this by calling on the Calls resource passing the Call Sid as the ParentCallSid parameter. This will get you access to the child call.

    You now need to redirect the child call using the REST API to another endpoint that has the TwiML to <Play> your recorded message for voicemail.

    Then, when your user is on a call and it goes to voicemail, they should press the button in the interface. This will redirect the child call away and consequently hang up on the user in salesforce.

    Let me know if this helps at all.