Twilio Studio/Functions and Conference calls

215 Views Asked by At

I'm using the Studio flow to manage authenticating an end user calling into our number, and assuming they pass authentication, they then get added to a conference call - however so that I can set the various parameters for starting the conference call, I'm trying to initiate the join conference function in a Functions called from Studio.

So example: End user if confirmed, and the next step in the Studio flow calls a Function called "Start Call". A variable passed to the start call function includes the Conference Name.

 exports.handler = function(context, event, callback) {
  console.log('Function - /startCall');
  const conference_id = event.conference_id;

  
  let twiml = new Twilio.twiml.VoiceResponse();

  twiml.say('Please wait while we dial you into the call.');
  twiml.dial().conference(conference_id);
  
  console.log('TWIML',twiml);
  
  return callback(null, twiml);
  };

This then returns back to the Studio Flow, so as a test, my next part is to dial a 3rd party into the same conference call - so another request from the flow to a function called conferenceOperator:

 exports.handler = function (context, event, callback) {
  console.log('Function - /conferenceOperator');
  
  const conference_id = event.conference_id;

  console.log('CONFERENCE',conference_id );
  
  const twilioClient = context.getTwilioClient();
  console.log(twilioClient.studio);
  twilioClient.studio.flows('FWxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').executions.create({ 
    to: '+44xxxxxxxxxxxx', 
    from: '+44xxxxxxxxxx', 
    parameters: JSON.stringify({
      call_id: conference_id 
    })
  })
  .then(function(execution) { 
    console.log(execution.sid); 
    callback(null, execution.sid);        
  })
  .catch(error => {
    console.error(`problem with request: ${error.message}`);
    callback(error.message);
  });

The number is dialed, and is put on hold waiting for the conference to start. However the moment this flow starts, the original inbound call is dropped. Looking at the logs for the Studio flow, it shows as still executing.

So questions:

  • why does the inbound call drop?
  • am I handling transferring the inbound call across to the conference via the function correctly?
  • what gotchas have I missed?

Thanks

1

There are 1 best solutions below

0
On

I have now resolved this - there was an odd error in another part of the flow, which was returning an http-error 500 - this caused the whole flow to fail, and thus end the call without reporting back!