首页 > 解决方案 > Twilio 功能读取多个语音输入

问题描述

用例是使用 twilio 中的可编程语音呼叫 IVR 系统。基于 IVR 问题,使用 twilio 函数和 TWIML 发送答案。我怎样才能做到这一点?到目前为止,我已经使用 Twilio 进行了调用,并在回调 webhook 下方进行了参考。

 [HttpPost]
    public TwiMLResult Index(string message)
    {
        var response = new VoiceResponse(); 

        var gather = new Gather(input: new List<Gather.InputEnum>()
        {
            Gather.InputEnum.Speech
        } , 
            timeout: 5,  action:new Uri("https://url-sample/GatherSample"));

        gather.Say("Please press 1 or say sales for sales.");
        response.Append(gather);
        LogWriter.Debug($"Message : {response.ToString()}");
        return new TwiMLResult(response);
    }

还有 Twilio 功能代码。

    exports.handler = function(context, event, callback) {
  const twiml = new Twilio.twiml.VoiceResponse();

  const command = event.SpeechResult.toLowerCase();

  twiml.say(`You said ${command}. I'll give you a ${command} fact.`);

  callback(null, twiml);
};

标签: c#twilio

解决方案


推荐阅读