问题
There is an ongoing call between 2 numbers (Twilio to Twilio, or Twilio to any PTSN number). It is not a conference call, just a normal 1-to-1 call using Twilio Voice.
How can I add another person to that call?
This is my current scenario. I first create a normal call (that has a ‘timeout’ and then redirects to voicemail via the ‘action’ verb). This is working, so a call now exists between 2 parties.
Then if the call initiator wants to add a 2nd number (ie create a conference call), I need to move both the call initiator and the 1st called number into a named conference.
However, I don’t know the Sid of the 1st called number’s leg of the call (I only know the Sid of the parent call), so how can this be done?
Assuming I did manage to create a conference call with the 2 initial numbers, how can I add further numbers to the conference, and automatically terminate the conference when there is only 1 party left?
回答1:
Twilio developer evangelist here.
If you are looking to add people to a call, then I would recommend you start with a conference call as it's going to be much easier than moving the two legs (though you can find a call by it's parent sid by listing calls and filtering by ParentCallSid).
Once you have a conference call with your callers in, you can add a new participant by making a POST request to the participants endpoint.
To end the conference when there is only one participant left, you could set up to receive conference status callback events when participants leave. When you receive the webhook you could then use the conference SID to look up how many participants are in the conference and end it if there is only one left.
Let me know if that helps at all.
来源:https://stackoverflow.com/questions/52778446/twilio-voice-add-another-participant-to-existing-call