Exemplo n.º 1
0
        public void TestSerializeNccoKitchenSink()
        {
            // arrage
            var expected = @"[{""dtmf"":{""timeOut"":3,""maxDigits"":1,""submitOnHash"":true},""speech"":{""uuid"":[""aaaaaaaa-bbbb-cccc-dddd-0123456789ab""],""endOnSilence"":1,""language"":""en-US"",""context"":[""dog"",""cat""],""startTimeout"":5,""maxDuration"":30},""action"":""input""}]";
            var settings = new SpeechSettings
            {
                Uuid         = new[] { "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" },
                EndOnSilence = 1,
                Language     = "en-US",
                Context      = new string[] { "dog", "cat" },
                StartTimeout = 5,
                MaxDuration  = 30
            };
            var dtmfSettings = new DtmfSettings {
                MaxDigits = 1, TimeOut = 3, SubmitOnHash = true
            };
            var inputAction = new MultiInputAction {
                Speech = settings, Dtmf = dtmfSettings
            };

            //act
            var ncco   = new Ncco(inputAction);
            var actual = ncco.ToString();

            //assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public void TestSerializeNccoKitchenEmpty()
        {
            // arrage
            var expected = @"[{""dtmf"":{},""speech"":{""uuid"":[""aaaaaaaa-bbbb-cccc-dddd-0123456789ab""]},""action"":""input""}]";
            var settings = new SpeechSettings
            {
                Uuid = new[] { "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" }
            };
            var inputAction = new MultiInputAction {
                Speech = settings
            };

            //act
            var ncco   = new Ncco(inputAction);
            var actual = ncco.ToString();

            //assert
            Assert.Equal(expected, actual);
        }
        public ActionResult Answer()
        {
            var responseUrl = $"{Request.Scheme}://{Request.Host}/webhooks/dtmf";
            var talkAction  = new TalkAction
            {
                Text    = "Hello please enter a digit.",
                BargeIn = "true"
            };
            var inputAction = new MultiInputAction
            {
                Dtmf = new DtmfSettings {
                    MaxDigits = 1
                },
                EventUrl    = new[] { responseUrl },
                EventMethod = "POST"
            };
            var ncco = new Ncco(talkAction, inputAction);

            return(Ok(ncco.ToString()));
        }
        public string Answer([FromQuery] Answer request)
        {
            var host = Request.Host.ToString();
            //Uncomment the next line if using ngrok with --host-header option
            //host = Request.Headers["X-Original-Host"];

            var eventUrl       = $"{Request.Scheme}://{host}/webhooks/asr";
            var speechSettings = new SpeechSettings {
                Language = "en-US", EndOnSilence = 1, Uuid = new[] { request.Uuid }
            };
            var inputAction = new MultiInputAction {
                Speech = speechSettings, EventUrl = new[] { eventUrl }
            };

            var talkAction = new TalkAction {
                Text = "Please speak now"
            };

            var ncco = new Ncco(talkAction, inputAction);

            return(ncco.ToString());
        }
        public IActionResult Answer()
        {
            var host = Request.Host.ToString();
            //Uncomment the next line if using ngrok with --host-header option
            //host = Request.Headers["X-Original-Host"];

            var eventUrl = $"{Request.Scheme}://{host}/webhooks/dtmf";

            var talkAction = new TalkAction()
            {
                Text = "Hello please press any key to continue"
            };
            var inputAction = new MultiInputAction()
            {
                EventUrl = new[] { eventUrl },
                Dtmf     = new DtmfSettings {
                    MaxDigits = 1
                }
            };
            var ncco = new Ncco(talkAction, inputAction);

            return(Ok(ncco.ToString()));
        }