我目前正在为我正在为客户工作的项目中使用 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' });
});
});
};