Twilio, How to transfer a in-progress call to another number

久未见 提交于 2019-12-22 12:35:33

问题


How to transfer a in-progress call to another number.The concept that I m using is to use the update method when the call is in in-progress and dial the number that I wanted To connect and It is working but the connection with the first caller is breaking/

Code for the process of transferring call-

1.process for dialing call-

 <Response>
  <Dial callerId="callerid">
    <Number statusCallbackEvent="initiated ringing answered completed" statusCallback="urltohadlestatus">user_number</Number>
  </Dial> 
</Response>

2. process to process to transfer the call- I have used the update method to transfer the call.

  function update_call1($CallSid, $admin_no) {
    $rr = array(
        "url" => "trurl?admin_no=".$admin_no,
        "method" => "POST"
    );
    $call = $this->client->calls($CallSid)->update($rr);
    return $call->to;
}

and used this TwiML

<Response>
        <Dial>admin_number_call_to_be_transfered</Dial>
</Response> 

what this does is transfer the call but when admin receives it,It disconnects the call. And what I need like when jack make call to jenny and now jack want to transfer the call to jhonny and when call is transferred to jhonny, jack shound be disconnected from the call.


回答1:


Twilio developer evangelist here.

You have two options here. Once the call is transferred away, the other caller will drop if it has nothing else to do. There are two ways you can achieve this.

You can either put the callers in a <Conference>. Then when the caller is transferred the other call remains in the conference room. There is a good tutorial on warm transfers using this technique, which might help.

Alternatively, if the side of the call that is dropping out right now is the one that generated the call from the Twilio REST API you can add more TwiML below the <Dial> verb to have the call continue. For example:

<Response>
  <Dial>OTHER_NUMBER</Dial>
  <Say loop="0">You are still on the call.</Say>
</Response>

Will just keep saying "You are still on the call" once the other end is transferred away.

You can also achieve this with the action attribute for <Dial>. Using the action attribute means that Twilio will make a webhook request to the URL you specify and use the TwiML from that response to carry on the call.



来源:https://stackoverflow.com/questions/42249790/twilio-how-to-transfer-a-in-progress-call-to-another-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!