Twilio 会议语音邮件/机器检测 [英] Twilio conference voicemail/machine detection

查看:24
本文介绍了Twilio 会议语音邮件/机器检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,我们将 20 人添加到会议中进行重要讨论,并且假设一两个参与者(从添加到会议的 20 人中)不可用并且他们的语音邮件处于活动状态,然后在重要讨论的中间那些预先录制的语音邮件消息/音频开始,这对会议中的其他人来说非常烦人.我想防止这种情况发生.

<块引用>

我尝试过使用 ifMachine 但它没有帮助,MachineDetection回调 URL 不是也没有被调用,AnswedBy 也是如此.

我正在关注 MachineDetection.>

我的代码如下

const Twilio = require('twilio');const client = new Twilio(account_sid, authToken);mobileArr.forEach(function(number,ind) {console.log("移动数组迭代",ind, number,' '+twilioCallBackUrl+'twilioMachineWebhook');客户.conferences(conferences.title).participants.create({machineDetection: '启用',网址:twilioMachinecallback,到:号码,来自:user.twilioDetails.number,statusCallback: twilioCallWebhook,statusCallbackMethod: 'POST',statusCallbackEvent: ['initiated', 'ringing', 'answered', 'completed'],超时:'15',方法:'获取',},功能(错误,参与者){如果(错误){console.error('conf 失败,因为:'+ err + ' ' + helper.authToken + ' ' +client.accountSid);} 别的 {}})})

我是 Twilio 的新手,如果我做错了什么,请提出建议和帮助.

解决方案

好吧,事实证明 AMD 机器检测并不是一个可靠的选择.

<块引用>

因此我去了alternatives-to-amd,也称为 呼叫筛选.

这是可靠的.步骤如下:

<块引用>

  1. 您必须创建要添加到会议的所有呼叫.

const Twilio = require('twilio');const client = new Twilio(account_sid, authToken);mobileArr.forEach(function(number,ind) {客户电话.创建({url: 'CallScreening 调用 url',来自:user.twilioDetails.number,到:号码,statusCallback: '您的通话状态回调网址',statusCallbackMethod: 'POST',statusCallbackEvent: ['initiated', 'ringing', 'answered', 'completed'],超时:'15',方法:'POST'}).then(调用 => {控制台日志(调用)})});

<块引用>

  1. 然后你必须在url中使用gather:'CallScreening call url'

 const VoiceResponse = require('twilio').twiml.VoiceResponse;export.callScreeningWebhook = (req, res) =>{console.log('callScreeningWebhook');控制台日志(req.body);const twiml = new VoiceResponse();const 收集 = twiml.gather({输入:'dtmf',超时:20,numDigits: 1,动作:twilioCallBackUrl+'gatherAction'});gather.say('请输入任意数字加入会议');//将响应呈现为 XML 以回复 webhook 请求res.type('文本/xml');res.send(twiml.toString());}

<块引用>

  1. 然后使用 Gather 方法将所有这些呼叫添加到特定会议回调.

exports.gatherAction = (req, res) =>{console.log('gatherAction');控制台日志(req.body);const twiml = new VoiceResponse();如果(req.body.Digits){var input = parseInt(req.body.Digits)console.log('你好',typeof input);如果(!isNaN(输入)){console.log('加入会议数据');twiml.say('你正在被合并到会议');const 拨号 = twiml.dial();拨号会议({statusCallbackMethod: 'POST',statusCallbackEvent: '开始结束加入离开',statusCallback: twilioCallBackUrl+'twilioConferenceWebhook'}, 会议.title);console.log(twiml.toString());console.log('加入完成')res.type('文本/xml');res.send(twiml.toString());}别的{console.log('输入解析错误');twiml.say('输入无效,请重试')twiml.redirect(twilioCallBackUrl+'callScreeningWebhook');res.type('文本/xml');res.send(twiml.toString());}}别的{console.log('无输入');twiml.say('没有输入,请重试')twiml.pause({长度: 10});twiml.redirect(twilioCallBackUrl+'gatherFailure');res.type('文本/xml');res.send(twiml.toString());}

}

gatherFailure的代码如下

exports.gatherFailure = (req, res) =>{console.log('gatherFailure');控制台日志(req.body);const twiml = new VoiceResponse();twiml.hangup();res.type('文本/xml');res.send(twiml.toString());}

通过这种方式,通过使用任何人呼叫来检测呼叫是否被人接听并执行所需的任何适当操作.

再次感谢philnash.

I am building an application in which we add 20 people to a conference for an important discussion, and suppose one or two of participants (From the 20 people added to the conference) is not available and their voicemail is active, then in the middle of an important discussion those prerecorded voicemail messages/audio starts, this is very annoying for others in the conference. I want to prevent this from happening.

I have tried using ifMachine but it did not help, MachineDetection callback URL is not is also not getting called, same is the case for AnsweredBy as well.

I am following MachineDetection.

My code is as follows

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 {

            }
        })
    })

I am new to Twilio please suggest and help if have I done anything wrong.

解决方案

Well, it turns out that AMD machine Detection is not a reliable option.

Hence I went for alternatives-to-amd which is also known as Call Screening.

It's reliable. The steps are as follows:

  1. You have to create all calls to be added to the conference.

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

  1. Then you have to use gather in url: 'CallScreening call url'

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

  1. Then add all these calls to a particular conference using the Gather method callback.

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

}

The code for gatherFailure is as follows

    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());

}

In this way by using gather anyone call detect whether call was answered by a human or not and perform any suitable action required.

Once again a big thank's to philnash.

这篇关于Twilio 会议语音邮件/机器检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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