0

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.

Arun
  • 728
  • 4
  • 16
  • 30
  • What is the error? – Alan Dec 16 '20 at 12:18
  • there is no error showing but calls are not connected. this is the output: "Called +18778423210 Called +16174025654" – Arun Dec 16 '20 at 12:21
  • @Alan in twilio debugger I found the following message: An attempt to retrieve content from https://2f3b18f01640.ngrok.io/voice/callConference.xml returned the HTTP status code 405. But that xms is valid only – Arun Dec 16 '20 at 12:28
  • 1
    @Alan i missed to add 'GET' method. Thank you for your response. – Arun Dec 16 '20 at 12:42

1 Answers1

0

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}`));
  })
}
Arun
  • 728
  • 4
  • 16
  • 30
  • Great, also, I noticed a .catch block is also missing (if the promise fails), so that may have also provided some insight. – Alan Dec 16 '20 at 13:15