0

E.g.->If agent A makes a call to a user and now agent A transfers the call the agent B now how can i disconnect agent A from the call and let user and B still on the call.

1.When I make the call I use this TwiML.

<Response>
        <Dial  callerId="id">
            <Number  statusCallback="statusCallbackurl" statusCallbackMethod="POST">ag1_num</Number>
        </Dial>
        <Redirect>music_url</Redirect> 
    </Response>

2.I am transferring the call by using update method and dialing the other agent by using this code-

function transfer_call($Sid,&ag2_num){
    $childCalls = $this->client->calls->read(array("ParentCallSid" => $Sid));
    $childSid = $childCalls[0]->sid;
    $rr = array(
        "url" => "tr_url".$ag2_num,
        "method" => "POST"

    );
    $call = $this->client->calls($childSid)->update($rr);
    return $call->to;

}

and on the tr_url I used TwiML-

<Response>
  <Dial>ag2_num</Dial>
  <Redirect>disconnectedcallurl-usingemptyqueue(todisconnectthefirstagent)</Redirect>
</Response> 

and to disconnect the call I called this method and pass the callsid-

function disconnect_call($callsid){
        $rr = array("status" => "completed");

        $call = $this->client->calls($callsid)->update($rr);
        echo $call->direction;
    }

I use the call sid to disconnect the agent from the call and it disconnect the whole call.

philnash
  • 70,667
  • 10
  • 60
  • 88
Aman Singh
  • 80
  • 7
  • Can you share a bit more of your code please? – philnash Feb 21 '17 at 05:47
  • Okay sure I will add in my question. – Aman Singh Feb 21 '17 at 06:10
  • When you redirect the other end of the call away, the 1st agent who was dialled should just hang up. Is that not happening? – philnash Feb 21 '17 at 06:31
  • yes you r right .//*that is what I want(the 1st agent who was dialled should just hang up), but what is happening is it disconnect the whole call (every on the call get disconnected).*// – Aman Singh Feb 21 '17 at 06:40
  • Are there any errors in your [Twilio debugger](https://www.twilio.com/console/dev-tools/debugger)? – philnash Feb 21 '17 at 07:05
  • no there are not errors on debugger. – Aman Singh Feb 21 '17 at 07:09
  • did you figure out anything? – Aman Singh Feb 21 '17 at 10:18
  • What Sid are you using in the disconnect call method? And when do you call that? – philnash Feb 21 '17 at 10:21
  • I m using the callsid to disconnect the first agent(ag1_num) from the call and I m using it right after my transfer_call method=> `function transfer_call($Sid,&ag2_num){ $childCalls = $this->client->calls->read(array("ParentCallSid" => $Sid)); $childSid = $childCalls[0]->sid; $rr = array( "url" => "tr_url".$ag2_num, "method" => "POST" ); $call = $this->client->calls($childSid)->update($rr); $this->disconnect_call($childSid ); }`. – Aman Singh Feb 21 '17 at 10:32

1 Answers1

0

Twilio developer evangelist here.

In the comments you say you are using the disconnect_call method straight after the transfer and you are using the same sid for both. This means that you transfer the call, which hangs up from the first agent, but then you instantly hang up the transferred call too, so it never calls the second agent.

You shouldn't need to disconnect the first agent, transferring the call away from them will do that. Remove your call to disconnect_child and try again.

philnash
  • 70,667
  • 10
  • 60
  • 88