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.
问问题
2067 次
1 回答
5
Twilio 开发人员布道者在这里。
您说您收到了两个提供给您的号码,您需要同时拨打他们两个电话,将他们加入会议。您可以使用REST API 进行调用,下面是一个使用Node.js Twilio 模块创建这些调用的函数的基本示例:
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}`));
})
}
当调用连接时,Twilio 将向提供的 URL 发出 HTTP 请求。
然后,您将需要在您自己的 URL 上的服务器应用程序(代替example.com
上面的函数),它可以返回TwiML来设置会议。
<Response>
<Dial>
<Conference>Room Name</Conference>
</Dial>
</Response>
[编辑]
如果你想在用户加入会议之前播放消息,你只需要在你之前使用<Say>
TwiML动词<Dial>
。像这样:
<Response>
<Say voice="alice">This is a call from xyz.org</Say>
<Dial>
<Conference>Room Name</Conference>
</Dial>
</Response>
让我知道这是否有帮助。
于 2017-05-19T16:44:05.763 回答