5

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.

John Ambrose
  • 167
  • 1
  • 11

1 Answers1

4

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.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • How can i Disconnect the first number who transfer the call to another number? – John Ambrose Feb 15 '17 at 13:20
  • If you want to disconnect a caller you can use the REST API to modify the live call. [Setting a call's status to "completed"](https://www.twilio.com/docs/api/rest/change-call-state#list-get-example-2) will disconnect them. – philnash Feb 15 '17 at 13:51
  • Okay would it disconnect all the callers or just caller who initiated the call transfer. And what I need is for example- A calls B and they talk for a while and then A transfer the call to C then how can I disconnect only A from the call let rest of two B and C on the call. – John Ambrose Feb 16 '17 at 04:54
  • You would disconnect the call SID that you modified. If that call was in a simple bridge to another number, using ``, then the other side would be disconnected too (unless it had more TwiML to perform). I recommend the [tutorial on warm transfers](https://www.twilio.com/docs/tutorials/walkthrough/warm-transfer/php/laravel) that I linked in this answer for a full walk through on how to transfer a caller. Have you taken a look at that yet? – philnash Feb 16 '17 at 10:04
  • 1
    Yes I have but I thing its using the conference methods which I can't use in my case. – John Ambrose Feb 17 '17 at 06:49
  • Ok, but I gave another option to conferences in my answer. If you don't want to use conferences then you need to make sure the original `` has more TwiML after it or an `action` attribute it can carry on to. Did you try that? – philnash Feb 17 '17 at 09:05
  • can i disconnect the call using parent_call_sid? – John Ambrose Feb 17 '17 at 13:30
  • Yes you could. Though make sure you select the right child call if the call you're trying to disconnect isn't the parent. – philnash Feb 17 '17 at 14:25
  • 1
    @JohnAmbrose if you have found solution, pls share here ? – Rajesh RK Jun 02 '17 at 11:55
  • 1
    I came here for the comment but maybe too early. @JohnAmbrose if you have the solution can you share here. – Finn May 19 '18 at 11:01
  • @philnash can you look into : https://stackoverflow.com/questions/66365132/how-to-connect-multiple-phones-to-conference-call-using-twilio – NomanJaved Feb 25 '21 at 16:09