node.js - 如何使用 twilio 将两个匿名调用者连接在一起

标签 node.js twilio twilio-click-to-call

我目前正在使用 Node js twilio 模块来实现我正在为客户开发的项目中的功能。基本上,服务器将使用 twilio api 发起一个调用,调用某个人 A,并将他连接到另一个人 B。我是 twilio 新手,所以我仍然是菜鸟,但这是我到目前为止编写的代码。请我需要你们提供如何实现这一目标的意见。干杯

var client = require('twilio')(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);

exports.makeCall = function(callDetails, cb) {

  client.makeCall({
    to:'+16515556677', // Any number Twilio can call
    from: TWILIO_CALLER_ID,
    url: 'https://demo.twilio.com/welcome/voice' // A URL that produces an XML document (TwiML) which contains instructions for the call
  }, function(err, responseData) {

      //executed when the call has been initiated.
      console.log(responseData.from); // outputs "+14506667788"

      var resp = new client.TwimlResponse();

      resp.say('Welcome to Acme Customer Service!')
        .gather({
          action:'http://www.example.com/callFinished.php',
          finishOnKey:'*'
      }, function() {
          this.say('Press 1 for customer service')
              .say('Press 2 for British customer service', { language:'en-gb' });
      });
  });
};

最佳答案

这里是 Twilio 开发者布道者。

您已完成此任务,但您不希望在对 client.makeCall 的调用的回调中创建 TwiML 响应。 responseData 是 Twilio 系统中调用的表示。

您需要做的是向 makeCall 函数提供一个 URL,该函数托管一些将调用连接到另一个电话号码的 TwiML。目前您已经有了演示 URL,因此您需要将其指向您拥有的 URL。

Twilio 网站上有一个非常好的深入教程,介绍如何完成所有这些工作,您可能会发现它对您有所帮助。 You can find the tutorial here ,尝试一下,如果有帮助请告诉我。

关于node.js - 如何使用 twilio 将两个匿名调用者连接在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26763267/

相关文章:

node.js - 从云函数内的请求主体访问各个字段

node.js - 使用 Webpack 构建后端 Express/WS Node 应用程序时的警告

node.js - 将 ChaiHttp 与 beforeEach 或 before 方法一起使用

javascript - 运行存储在对象中的函数

android - Twilio 应用程序调用应用程序在 Android 中关闭或终止时调用?

java - 在 Web 应用程序中使用 twilio 进行语音通话

node.js - 在 Twilio Voice 中将参与者添加到 session 时访问被拒绝

python-3.x - 如何让 flask 应用一一向用户提问并保留该用户的答案?

android - Twilio 调用在 iOS 和 Android 中不起作用