【问题标题】:Twilio conference voicemail/machine detectionTwilio 会议语音邮件/机器检测
【发布时间】:2018-10-20 15:24:33
【问题描述】:

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

我尝试过使用 ifMachine 但没有帮助,MachineDetection 回调 URL 不是也没有被调用,同样是 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 {

            }
        })
    })

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

【问题讨论】:

    标签: node.js twilio twilio-api twilio-programmable-voice


    【解决方案1】:

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

    因此我选择了alternatives-to-amd,也称为Call Screening

    这是可靠的。步骤如下:

    1. 您必须创建所有呼叫才能添加到会议中。
    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 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. 然后使用Gather 回调方法将所有这些呼叫添加到特定会议。
    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());
    
    }
    

    通过这种方式,通过使用收集任何人的呼叫来检测呼叫是否由人接听并执行所需的任何合适的操作。

    再次非常感谢 philnash

    【讨论】:

      【解决方案2】:

      这里是 Twilio 开发者宣传员。

      participants resource does not list the machineDetection or Url parameter 在直接将呼叫创建到会议中时作为可用参数。这是因为此 API 调用将参与者直接拨入电话会议。

      要处理机器检测,您需要使用常规的Calls resource 进行调用。在此 API 请求中,您可以将 machineDetection 设置为 Enable 并设置 Url。您需要您的 URL 能够处理 AnsweredBy 参数,如果它是 human,则返回 TwiML 以将您的用户拨入计算机上的 <Conference> 或只是 <Hangup>

      让我知道这是否有帮助。

      【讨论】:

      • 据此link machineDetection 仅在选定的国家/地区启用。同样根据上面link machineDetection 接受参数Enable,但正如你所提到的,我会坚持下去。
      • 你能给我一个想法或参考,我可以使用Call Screening和上面的会议创建代码。
      • 你说得对,machineDetectionEnable 为论据,我的错误。重要的部分是创建会议参与者不支持machineDetection,但创建导致会议的呼叫。
      • 至于呼叫筛选,如果您按照我的建议创建呼叫,您可以使用任何 TwiML 在呼叫进入会议之前引导呼叫。因此,与其直接将<Dial> 输入<Conference>,不如直接<Say> 发送消息并让用户输入密码或仅使用键盘响应并使用<Gather> 获得响应并有条件地引导他们进入<Conference>.
      • 所以基本上,1. 我必须创建一个呼叫 2. 然后我必须使用收集 3. 然后将所有这些呼叫添加到特定会议这个过程对吗?您能否提供该过程的参考或示例。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多