Remove participent from call while ringing Twillio

37 Views Asked by At

I want to remove participant from conference call. My case is call the multiple participants in a conference call at once. If any one first pick the call then disconnect the call from all other participants. I want to do this during ringing. Like first pick the call and others are still ringing I want to disconnect all ringing calls.

 foreach ($participants as $participantPhoneNumber) {
    $conferenceOptions = ['startConferenceOnEnter' => true, 'endConferenceOnExit' => true];

    $dial = $response->dial('');
    $dial->conference($conferenceName, $conferenceOptions);
    
    $toPerson = "client:" . $participantPhoneNumber . "?typeOfCall=" . $typeOfCall . "&minimumMinutes=" . $minimumMinutes . "&language=" . $language . "&speciality=" . $speciality;

    $participant = $twilio->conferences($conferenceName)->participants->create("client:".$from, $toPerson, [
        "conferenceStatusCallback" => "http://****/**/**/status-callback.php",
        "conferenceStatusCallbackEvent" => "start end join leave mute hold modify speaker announcement",
        "conferenceStatusCallbackMethod" => "POST",
        "beep" => "false",
    ]);
}

    
$conferences = $twilio->conferences->read([
    "status" => "in-progress",
    "friendlyName" => $conferenceName,
]);

foreach ($conferences as $conference) {
    $participantsIDs = $twilio->conferences($conference->sid)->participants->read([], 20);
    foreach ($participantsIDs as $record) {
      //need to remove/disconnect all other participants that are still ringing if one already picked the call. 
    }
}

    

 

1

There are 1 best solutions below

0
jassent On

The outcome you are seeking can be achieved using the Dial verb with the Number noun. It is not necessary to use a Conference.

You can use up to ten nouns within a verb to simultaneously call all of them at once. The first call to pick up is connected to the current call and the rest are hung up. For each noun you can specify what call progress events you want to receive webhooks for.

If you must use a Conference, you could redirect the first person who answered into a Conference.

In either method, you will need to deal with voicemails as it could appear that a person answered when it was actually a voicemail.

A more reliable approach would be to have all workers in a Conference, know that they are available, and then connect the available worker to the call. You can do this with or without Taskrouter.