How to make a call to multiple clients and how to add one of them into conference call in twilio

227 Views Asked by At

Client A make a calls to Client B,C,D,E simultaneously if one of them picks a call we have to end up a call to remaining of them.later we if we want to add Client X we can add them into a conference call.like this i have to do.but the thing is it is adding all clients who picks the call they are come to the call.for example if Client B,C,D,E picks call they all are coming into the call with a Client A.and if i hangup the call it is not hanging up to the all clients. this is my code what id did.this code is making calls to all clients simultaneously but if a Client A Hangup call it is not hanging up to the Client B,C,D,E.how to do that and how to hangup rest of them end up from the call if one of them picks a call.please help me on this

  Roomno='randomname';
 ['B','C','D','E'].forEach(vendorarrayid=>{
    client.calls.create({
      to: "client:"+vendorarrayid,
      from: ,"client:"+'A',
      method: 'GET',
      timeout:30,
      callReason:'i have know that reason',
      url: siteUrl+'/join_conference?id=' + Roomno+'&clientid='+ClientID,
      statusCallbackEvent:['completed','answered'],
      statusCallback:siteUrl+'/handleConfeerence?roomno='+Roomno+'&clientid='+ClientID,
      statusCallbackMethod:'GET'
    }).then(call =>console.log(call.sid));
  });


       dial.conference(Roomno, {
     waitUrl: "http://twimlets.com/holdmusic?Bucket=com.twilio.music.rock",
     statusCallbackEvent:"leave join",
     statusCallback:siteUrl+'/leave?roomno='+Roomno+'&clientid='+ClientID,
     statusCallbackMethod:'GET',
     endConferenceOnExit:'true'
   });
   response.type('text/xml');
   console.log(voiceResponse.toString());
0

There are 0 best solutions below