首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >两次会议语音信箱/机器检测

两次会议语音信箱/机器检测
EN

Stack Overflow用户
提问于 2018-05-10 11:06:41
回答 2查看 842关注 0票数 2

我正在构建一个应用程序,在这个应用程序中,我们为一次重要的讨论增加了20人,假设有一两个参与者(来自会议的20人)不可用,而且他们的语音邮件是活跃的,那么在一次重要的讨论中,这些预先录制的语音邮件/音频开始了,这对会议中的其他人来说是非常烦人的。我想防止这种事发生。

我试过使用ifMachine,但是它没有帮助,MachineDetection回调网址不是也没有被调用,AnsweredBy也是如此。

我在跟踪MachineDetection

我的代码如下

代码语言:javascript
复制
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 {

            }
        })
    })

我是新来的,如果我做错了什么,请给我建议和帮助。

EN

回答 2

Stack Overflow用户

发布于 2018-05-14 04:07:07

两位开发人员在这里传道。

在创建直接进入会议的调用时,参数作为可用参数。这是因为这个API调用将一个参与者直接拨到电话会议中。

要处理机器检测,您需要使用常规的呼叫资源进行调用。在这个API请求中,您可以将machineDetection设置为Enable并设置Url。您将需要您的URL能够处理AnsweredBy参数,如果是human,则返回TwiML将用户拨号到或机器上的。

如果这有帮助的话请告诉我。

票数 1
EN

Stack Overflow用户

发布于 2018-05-18 14:56:42

嗯,事实证明AMD机器检测不是一个可靠的选择。

因此,我选择了可供选择的,也称为呼叫筛选

是可靠的。这些步骤如下:

  1. 您必须创建要添加到会议中的所有电话。
代码语言:javascript
复制
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. 然后,您必须在url中使用CallScreening:'CallScreening call url'
代码语言:javascript
复制
    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. 然后使用收集方法回调将所有这些调用添加到特定的会议。
代码语言:javascript
复制
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的代码如下所示

代码语言:javascript
复制
    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());

}

这样,通过使用聚集,任何人调用都可以检测呼叫是否被人应答,并执行所需的任何适当操作。

再次向表示感谢。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50271503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档