6

I have to make two outbound calls to two random mobile numbers and join both of them in conference using node.js. Is there a way to make it possible using twilio and node.js.

user3172208
  • 91
  • 1
  • 5
  • Hey, what kind of code have you already tried? Have a look at this article to get started. https://www.twilio.com/docs/guides/how-to-create-conference-calls-in-node-js#basic-conference-call – Marcos Placona May 12 '17 at 09:02
  • Hi @MarcosPlacona, tried conference calls `https://www.twilio.com/docs/guides/how-to-create-conference-calls-in-node-js#where-to-next` and outbound calls `https://www.twilio.com/docs/guides/how-to-make-outbound-phone-calls-node-js#make-an-outbound-phone-call` but in the conference i see the possibility of setting only one number dynamically not both the numbers (as others needs to be configured in My Conference) correct me if i am wrong. In my case i will be getting couple of numbers as parameters to my HTTP api and i need to join make outbound calls to them and join both into a conference. – user3172208 May 15 '17 at 03:08

1 Answers1

8

Twilio developer evangelist here.

You say you are getting two numbers provided to you and you need to make calls to both of them, joining them up in a conference. You can use the REST API to make the calls and here's a basic example of a function that would create those calls using the Node.js Twilio module:

const accountSid = 'your_account_sid';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

function connectNumbers(number1, number2) {
  [number1, number2].forEach(function(number) {
    client.calls.create({
      url: 'https://example.com/conference',
      to: number,
      from: 'YOUR_TWILIO_NUMBER',
    })
    .then((call) => process.stdout.write(`Called ${number}`));
  })
}

When the calls connect, Twilio will make an HTTP request to the URL supplied.

You would then need a server application on your own URL (in place of example.com in the function above) that could return the TwiML to set up the conference.

<Response>
  <Dial>
    <Conference>Room Name</Conference>
  </Dial>
</Response>

[edit]

If you want to play a message before users join the conference, you just need to use the <Say> TwiML verb before you <Dial>. Like this:

<Response>
  <Say voice="alice">This is a call from xyz.org</Say>
  <Dial>
    <Conference>Room Name</Conference>
  </Dial>
</Response>

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Hey, Sorry for the late reply.. n thanks it works.. :) :) – user3172208 Jun 27 '17 at 06:08
  • Is there any way to configure the above program to give a short voice message(like this is call from xyz.org) on start of a call to each participant and then they can continue with normal conference call. – user3172208 Jun 27 '17 at 06:22
  • Yes you can. You just need to use ``. I've updated my answer above. – philnash Jun 27 '17 at 09:39
  • Is there a way to first call one person, wait till the person entered the room and the call the other person ? – Simon Ludwig Apr 06 '20 at 19:16
  • 1
    @SimonLudwig Yes, absolutely. I'd make the first call, then when the webhook fires that returns the TwiML to add the first person into the room also fire off the second API request to dial the second person. – philnash Apr 06 '20 at 23:34