0

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!');
}
martinii
  • 141
  • 10
  • It's not clear from you explanation what you are trying to do. Can you explain the use case? From above, you are making an initial outbound call using a Twilio Function. Then when the person answers, you want to add them into a conference and then make another outbound call and add another party to the same conference? – Alan Sep 29 '20 at 12:24
  • I edited the code. The use case is I want to establish a call after the outbound call is answered, not when a conference is created. – martinii Sep 29 '20 at 13:26

1 Answers1

0

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.

Alan
  • 10,465
  • 2
  • 8
  • 9