Twilio如何进行两个出站呼叫并使用Node JS加入(会议)它们 [英] Twilio how to make two outbound calls and join(conference) them using node js

查看:111
本文介绍了Twilio如何进行两个出站呼叫并使用Node JS加入(会议)它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须对两个随机手机号码进行两次出站呼叫,并使用node.js将它们都加入会议.有没有办法使使用twilio和node.js成为可能.

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.

推荐答案

此处是Twilio开发人员的福音.

Twilio developer evangelist here.

您说您将获得两个电话号码,您需要致电给他们两个,将他们加入会议.您可以使用 REST API进行调用,这是一个基本的使用 Node.js Twilio模块

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

当电话接通时,Twilio将向提供的URL发出HTTP请求.

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

然后,您需要在您自己的URL(代替上面的函数中的example.com)上使用服务器应用程序,该应用程序可能会返回会议.

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>

如果要在用户加入会议之前播放消息,只需使用

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.

这篇关于Twilio如何进行两个出站呼叫并使用Node JS加入(会议)它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆