Twilio - How to move an existing call to a conference

有些话、适合烂在心里 提交于 2019-11-27 04:31:57

问题


With twilio, on an existing call (2 legs - caller leg and called leg), I want to move the call into a conference room. Both legs have to be present into the room How to bridge the both legs without losing one or the other leg ?

Thank you

Regards


回答1:


The trick to prevent the call being dropped is by using “action” url for parent leg to dial into conference and modifying the child leg to move in the same conference.

Here’s the detailed flow to start calls between 2 person and then upgrade that to a conference

(1) Create a TwiML Response API to dial calls in conference(based suited to your business logic ) . Here’s a simple example TwiML (http://www.mocky.io/v2/584ac0f81000002b14fb0205)

<Response>
<Dial>
<Conference>letItGoSimple</Conference>
</Dial>
</Response>

(2) When you initiate the call , your Url parameter should be set to return TwiML like the one below (example Twiml : http://www.mocky.io/v2/584ac8a3100000c914fb0214 )

<Response>
<Dial action="http://www.mocky.io/v2/584ac0f81000002b14fb0205" method="GET">
<Number>+44xxxxxxxx</Number>
</Dial>
</Response>

Note that the action url has been set to TwiML from step one . It is very important in this flow as this would prevent the call from being dropped when you modify the Child Leg of the call .

(3) After step 2 is executed, the two parties would be on a direct call (no conference)

(4) When you want to upgrade the call to a conference , POST to the child call SID with Url set to Twiml To Dial into conference ,

Example : 
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxxx/Calls/CAyyyyyyyyyyyyyy -d "Url=http://www.mocky.io/v2/584ac0f81000002b14fb0205" -d "Method=GET"  -u ‘accountSID:authToken'

It is important that you modify the child leg of the call .

(5) Here is what will happen when you execute step 4

  • Child call will be redirected to the Url and would be dialed into the conference
  • Parent call will move to action and would be dialed in the same conference

Hope this helps.




回答2:


Twilio evangelist here.

So the best answer is to just put both calls into a conference to start. Its a little more difficult since you have to use the API to initiate the second leg, but it gives you a lot more flexibility to move call legs around.

If thats not possible, then it gets a bit more challenging since there isn't a great way today to get the SID of the second call. What you would likely need to do is use the Calls list resource in the REST API to find the SID of that second call. You can use the list filter parameters To and Status to find the specific call. Once you have the call resource of the second leg, it contains a parameter called parent_call_sid which is the SID of the original incoming call.

Now that you have the SID's for both call legs you can use the REST API to redirect both calls to new Voice Urls which return TwiML containing the <Conference> noun.

Hope that helps.




回答3:


Twilio employee here.

To add to am1704's answer, a variation on the same theme is to use the <Redirect> verb after <Dial>:

<Response>
  <Dial>
    <Number>+44xxxxxxxx</Number>
  </Dial>
  <Redirect method="GET">http://www.mocky.io/v2/584ac0f81000002b14fb0205</Redirect>
</Response>

Once the child call has been moved to the conference, the TwiML will continue with the verb after <Dial>.

Both techniques require knowledge of the call state. In some calls, the desired next step might be <Hangup>. In others, one might want to move the parent leg to a conference.



来源:https://stackoverflow.com/questions/22643800/twilio-how-to-move-an-existing-call-to-a-conference

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