twilio join two outbound calls not working in node js

148 Views Asked by At

As per the documentation here, I have created the below script but its not working.

const accountSid = 'xxxxxxxxxxxxxxx';
const authToken = 'xxxxxxxxxxxxxx';
const client = require('twilio')(accountSid, authToken);

connectNumbers('+1xxxxxxxxxxx','+1xxxxxxxxx');

function connectNumbers(number1, number2) {
  [number1, number2].forEach(function(number) {
    client.calls.create({
      url: 'https://2f3b18f01640.ngrok.io/voice/callConference.xml',
      to: number,
      from: '+1xxxxxxxxxxx',
    })
    .then((call) => process.stdout.write(`Called ${number}`));
  })
}

Twiml link produces the following xml:

<Response>
<Dial>
<Conference>My conference</Conference>
</Dial>
</Response>

Can anyone please tell me what I did wrong.

1

There are 1 best solutions below

1
On

As per the post here found the solution. Returned HTTP status code 405 that means I missed to add 'GET' method. Now its working fine.

function connectNumbers(number1, number2) {
  [number1, number2].forEach(function(number) {
    client.calls.create({
      method: 'GET',
      url: 'https://2f3b18f01640.ngrok.io/voice/callConference.xml',
      to: number,
      from: '+1xxxxxxxxxxx',
    })
    .then((call) => process.stdout.write(`Called ${number}`));
  })
}