【问题标题】:twilio join two outbound calls not working in node jstwilio 加入两个在节点 js 中不起作用的出站呼叫
【发布时间】:2020-12-16 11:42:05
【问题描述】:

根据文档here,我创建了以下脚本,但它不起作用。

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 生成以下 xml:

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

谁能告诉我我做错了什么。

【问题讨论】:

  • 错误是什么?
  • 没有显示错误,但呼叫未连接。这是输出:“呼叫 +18778423210 呼叫 +16174025654”
  • @Alan 在 twilio 调试器中我发现以下消息:尝试从2f3b18f01640.ngrok.io/voice/callConference.xml 检索内容返回 HTTP 状态代码 405。但该 xms 仅有效
  • @Alan 我错过了添加“GET”方法。感谢您的回复。

标签: node.js twilio twilio-programmable-voice


【解决方案1】:

根据here 的帖子找到了解决方案。返回 HTTP 状态代码 405,这意味着我错过了添加“GET”方法。现在它工作正常。

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}`));
  })
}

【讨论】:

  • 太好了,另外,我注意到一个 .catch 块也丢失了(如果承诺失败),所以这可能也提供了一些见解。
猜你喜欢
  • 2017-10-10
  • 1970-01-01
  • 2018-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多