从 twilio 呼叫中收集数字并发送到网络钩子



我需要实现一种方法,让呼叫接收者取消订阅从我的系统发出的呼叫。为此,我在脚本中添加了一行,上面写着"如果您不再希望接听这些电话,请按 9"。当收件人按 9 时,我希望将按下的收件人编号和数字发送到我的 REST api,以便我可以将它们从我的系统中删除。我试图用下面的代码完成此操作,但我无法获得发送到请求箱的响应。我做错了什么?

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

我解决了这个问题。finishOnKey设置导致呼叫结束并且不拾取数字。相反,我删除了 finishOnKey 设置,并将 numDigits 参数设置为 1。这样,无论收件人按哪个数字,调用都将结束并将数字发送到我的 API。以下是更新的代码:

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

最新更新