我正在构建一个应用程序,在这个应用程序中,我们为一次重要的讨论增加了20人,假设有一两个参与者(来自会议的20人)不可用,而且他们的语音邮件是活跃的,那么在一次重要的讨论中,这些预先录制的语音邮件/音频开始了,这对会议中的其他人来说是非常烦人的。我想防止这种事发生。
我试过使用ifMachine,但是它没有帮助,MachineDetection回调网址不是也没有被调用,AnsweredBy也是如此。
我在跟踪MachineDetection。
我的代码如下
const Twilio = require('twilio');
const client = new Twilio(account_sid, authToken);
mobileArr.forEach(function(number,ind) {
console.log("mobile array iteration",ind, number,' '+twilioCallBackUrl+'twilioMachineWebhook');
client
.conferences(conferences.title)
.participants.create({
machineDetection: 'Enable',
url:twilioMachinecallback,
to: number,
from: user.twilioDetails.number,
statusCallback: twilioCallWebhook,
statusCallbackMethod: 'POST',
statusCallbackEvent: ['initiated', 'ringing', 'answered', 'completed'],
Timeout: '15',
method: 'GET',
}, function(err, participant) {
if (err) {
console.error('conf failed because: '+ err + ' ' + helper.authToken + ' ' +client.accountSid);
} else {
}
})
})我是新来的,如果我做错了什么,请给我建议和帮助。
发布于 2018-05-14 04:07:07
发布于 2018-05-18 14:56:42
嗯,事实证明AMD机器检测不是一个可靠的选择。
是可靠的。这些步骤如下:
const Twilio = require('twilio');
const client = new Twilio(account_sid, authToken);
mobileArr.forEach(function(number,ind) {
client.calls
.create({
url: 'CallScreening call url',
from: user.twilioDetails.number,
to: number,
statusCallback: 'Your call status callback url',
statusCallbackMethod: 'POST',
statusCallbackEvent: ['initiated', 'ringing', 'answered', 'completed'],
Timeout: '15',
method: 'POST'
})
.then(call => {
console.log(call)
})
}); const VoiceResponse = require('twilio').twiml.VoiceResponse;
exports.callScreeningWebhook = (req, res) => {
console.log('callScreeningWebhook');
console.log(req.body);
const twiml = new VoiceResponse();
const gather = twiml.gather({
input:'dtmf',
timeout: 20,
numDigits: 1,
action: twilioCallBackUrl+'gatherAction'
});
gather.say('Please enter any digits to join conference');
// Render the response as XML in reply to the webhook request
res.type('text/xml');
res.send(twiml.toString());
}exports.gatherAction = (req, res) => {
console.log('gatherAction');
console.log(req.body);
const twiml = new VoiceResponse();
if (req.body.Digits) {
var input = parseInt(req.body.Digits)
console.log('HEllo',typeof input);
if (!isNaN(input)){
console.log('JoIN conference data');
twiml.say('You are being merged to conference');
const dial = twiml.dial();
dial.conference({
statusCallbackMethod: 'POST',
statusCallbackEvent: 'start end join leave',
statusCallback: twilioCallBackUrl+'twilioConferenceWebhook'
}, conference.title);
console.log(twiml.toString());
console.log('JoIN Complete')
res.type('text/xml');
res.send(twiml.toString());
}else{
console.log('input parsing error');
twiml.say('Invalid input, Please try again')
twiml.redirect(twilioCallBackUrl+'callScreeningWebhook');
res.type('text/xml');
res.send(twiml.toString());
}
}else{
console.log('no input');
twiml.say('No input, Please try again')
twiml.pause({length: 10});
twiml.redirect(twilioCallBackUrl+'gatherFailure');
res.type('text/xml');
res.send(twiml.toString());
}}
gatherFailure的代码如下所示
exports.gatherFailure = (req, res) => {
console.log('gatherFailure');
console.log(req.body);
const twiml = new VoiceResponse();
twiml.hangup();
res.type('text/xml');
res.send(twiml.toString());
}这样,通过使用聚集,任何人调用都可以检测呼叫是否被人应答,并执行所需的任何适当操作。
再次向表示感谢。
https://stackoverflow.com/questions/50271503
复制相似问题