Twilio Conference - Rejoin after hanguponstart

135 Views Asked by At

We have a Twilio conference setup in place, and the main user (moderator) is able to do some management of the conference from a conference menu. To access this, they press *.

This is set when the conference is first created as follows (from within Functions):

exports.handler = function(context, event, callback) {

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

    twiml.dial({
        hangupOnStar: true,
        action: "https://" + context.DOMAIN_NAME + "/clientConferenceMenu",
        method: 'POST'
    }).conference(twilio_call_id, {
        startConferenceOnEnter: true,
        endConferenceOnExit: false,
        statusCallbackEvent: "join end leave hold",
        statusCallback: "https://" + context.DOMAIN_NAME + "/callStatus",
        record: "record_from_start",
        participantLabel: "Client"
    });
    return callback(null, twiml);
});

Once the user has entered the conference menu, they can go back into the conference using a specific option - in this case press 3 (or say return).

If they press option 3, if attempts to add them back into the conference:

client.conferences(conference_id)
  .fetch()
  .then((conference) => {
    console.log("Conference: ", conference);
    twiml.dial({
      hangupOnStar: true,
      action: "https://" + context.DOMAIN_NAME + "/clientConferenceMenu",
      method: 'POST'
    }).conference(conference.friendlyName, {
      startConferenceOnEnter: true,
      endConferenceOnExit: false,
      statusCallbackEvent: "join end leave hold",
      statusCallback: "https://" + context.DOMAIN_NAME + "/callStatus",
      record: "record_from_start",
      participantLabel: "Client"
    });
    return callback(null, twiml);
  });

However... what it actually does, is create a new conference with the same name, but a different actual room. I think I either need to add them back using the conference-SID, but I don't see a way of doing that, or somehow, take them off hold.

Any help gratefully received :)

1

There are 1 best solutions below

0
On

Twilio Support came good.

My original "rejoin" twiml:

twiml.dial({
    hangupOnStar: true,
    action: "https://" + context.DOMAIN_NAME + "/clientConferenceMenu",
    method: 'POST'
}).conference(twilio_call_id, {
    startConferenceOnEnter: true,
    endConferenceOnExit: false,
    statusCallbackEvent: "join end leave hold",
    statusCallback: "https://" + context.DOMAIN_NAME + "/callStatus",
    participantLabel: "Client"
});

Their suggestion was to take out the conference "options":

twiml.dial({
    hangupOnStar: true,
    action: "https://" + context.DOMAIN_NAME + "/clientConferenceMenu",
    method: 'POST'
}).conference(twilio_call_id);

That did the trick! :)