简体   繁体   English

收集来自twilio呼叫的数字并发送到webhook

[英]Gather digit from twilio call and send to webhook

I need to implement a way for call recipients to unsubscribe from calls made from my system. 我需要实现一种方法,使呼叫接收者可以取消订阅系统发出的呼叫。 To do this, I added a line in my script that says "press 9 if you no longer wish to receive these calls.". 为此,我在脚本中添加了一行,内容为“如果您不再希望接听这些电话,请按9。” When the recipient presses 9, I would like for the recipients number and digit pressed to be sent to my REST api so that I can remove them from my system. 当收件人按9时,我希望将按的收件人编号和数字发送到我的REST api,以便可以将其从系统中删除。 I attempted to accomplish this with the code below but I cannot get a response to be sent to Request bin. 我尝试使用下面的代码来完成此操作,但是无法将响应发送到请求bin。 What am I doing wrong? 我究竟做错了什么?

var twiml = new VoiceResponse();
            var gather = new Gather(input: "dtmf", action: new Uri("https://requestb.in/17lr5671"), method: "POST",
                timeout: 5, finishOnKey: "9", numDigits: 1);
            gather.Say(script, Say.VoiceEnum.Woman);
            twiml.Append(gather);
            return new TwiMLResult(twiml);

I solved this. 我解决了 The finishOnKey setting was causing the call to end and not pick up the digit. finishOnKey设置导致呼叫结束而不接听数字。 Instead, I removed the finishOnKey setting and left the numDigits parameter set to 1. This way, no matter what digit the recipient presses, the call will end and send the digits to my API. 取而代之的是,我删除了finishOnKey设置,并将numDigits参数设置为1。这样,无论接收者按什么数字,调用都会结束并将这些数字发送到我的API。 Below is the updated code: 下面是更新的代码:

var twiml = new VoiceResponse();
        var gather = new Gather(input: "dtmf", action: new Uri("https://requestb.in/17lr5671"), method: "POST",
            timeout: 5, numDigits: 1);
        gather.Say(script, Say.VoiceEnum.Woman);
        twiml.Append(gather);
        return new TwiMLResult(twiml);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM