Immediately calling a number after creating a conference

111 views Asked by At

I am handling outgoing calls using Twilio Functions. I am creating a conference every outgoing call but I want to immediately call the number after creating the conference.

if(event.To) {
  const dial = twiml.dial()
  dial.conference('My Room', {
      endConferenceOnExit: false,
      startConferenceOnEnter: false
  });
} else {
  twiml.say('Thanks for calling!');
}

I have tried this but it's not working:

if(event.To) {
  const dial = twiml.dial()
  dial.conference('My Room', {
      endConferenceOnExit: false,
      startConferenceOnEnter: false
  });
  dial.number(event.To);
} else {
  twiml.say('Thanks for calling!');
}
1

There are 1 answers

0
Alan On

A few different ways to do this. If you are using a URL with the Calls Resource (to initiate the outbound call), if the URL is accessed, the call was answered. You can then returned TwiML to tell Twilio what to do next.

Alternatively, can use the statusCallback of the Calls resource, to see if the call was answered. If it was answered, you can then execute additional code to take the next steps.