Skip to content Skip to sidebar Skip to footer

Twilio: Put Caller On Hold

Is it possible in twilio to put a caller on hold then the agent can call someone to verify something. Then after verifying the agent will get back to the hold caller. Thank You,

Solution 1:

Twilio developer evangelist here.

I think you will find most of the information you're looking for here. But in summary, using the REST api you can put users on/off hold and do much more.

Using the CallSid you can do anything with a call via the Rest API. Have a look at Twilio change call state for more information.

You can wait for the agent to press Hold (or any button you choose depending on which experience you're using – VOIP or PSTN) and can then use the REST API to update that call sending it to a queue using the verb for example.

Then you can retrieve the call using the CallSid to update it and send it back to the agent.

Here's an example of how you could redirect a running call to a different URL that would return a message. you can change that URL to be anything on your server.

var accountSid = '{{ account_sif }}';
var authToken = "{{ auth_token }}";
var client = require('twilio')(accountSid, authToken);

client.calls({{ call_sid }}).update({
    url: "https://demo.twilio.com/docs/voice.xml",
    method: "POST"
}, function(err, call) {
    console.log(call.to);
});

Hope this helps


Solution 2:

this is what I did.

I have a hold button in the client side. A caller came in and I accepted the call. The caller wants to talk to verify something but the agent doesn't know anything. So the agent told the caller that he will be put on hold. So I clicked the button hold. So what I did, I get the callsid and send it to the php server side.

CLIENT SIDE

jQuery.ajax({
                    url: "<?php echo base_url();>agent/call_controls/redirect_to_hold",
                    type: 'POST',
                    data:{'CallSid':child_callsid},
                    dataType: 'json',
                    success:function(data)
                    {
                        console.log(data);
                    }
                });

PHP SERVER SIDE

$client = new Services_Twilio($account_sid, $auth_token);
    $call = $client->account->calls->get($_POST["CallSid"]);
    $call->update(array(
        "Url" => HTTP_BASE_URL."agent/call_controls/forward_hold",
        "Method" => "POST"
    ));

and then I redirected it the hold url.

$response = new Services_Twilio_Twiml;
    $response->say("You are put on hold");
    $response->play("https://api.twilio.com/cowbell.mp3", array('loop' => 100));
    print $response;

The caller is now put on hold. How can I retrieved him again as the agent who put him on hold.

Thank You very much


Post a Comment for "Twilio: Put Caller On Hold"