public string Answer()
        {
            Ncco ncco;

            if (Request.Query.ContainsKey("to") && Request.Query["to"] == "12012971365")
            {
                var talkAction = new TalkAction {
                    Text = "Please wait while you're connected to the call"
                };
                var connectAction = new ConnectAction
                {
                    Timeout  = "20",
                    From     = "12012854946",
                    Endpoint = new[] { new Nexmo.Api.Voice.Nccos.Endpoints.AppEndpoint
                                       {
                                           User = "******"
                                       } }
                };
                ncco = new Ncco(talkAction, connectAction);
            }
            else
            {
                var talkAction = new TalkAction {
                    Text = "Please wait while you're connected to the call"
                };
                var connectAction = new ConnectAction
                {
                    Timeout  = "20",
                    From     = "12012854946",
                    Endpoint = new[] { new Nexmo.Api.Voice.Nccos.Endpoints.PhoneEndpoint
                                       {
                                           Number = "12018747427"
                                       } }
                };
                ncco = new Ncco(talkAction, connectAction);
            }

            return(ncco.ToString());
        }
        public string Answer()
        {
            var webSocketAction = new ConnectAction()
            {
                Endpoint = new[]
                {
                    new WebsocketEndpoint()
                    {
                        Uri         = $"wss://{BASE_URL}/ws",
                        ContentType = "audio/l16;rate=8000",
                        Headers     = new Dictionary <string, string>()
                        {
                            { "language", LANGUAGE }
                        }
                    }
                }
            };

            var ncco = new Ncco(webSocketAction);

            return(ncco.ToString());
        }
예제 #3
0
        private Response OnAnswerRecording()
        {
            var recordAction = new RecordAction()
            {
                EventUrl = new [] { $"{SiteBase}/webhook/record" }
            };

            var sb = new StringBuilder("Hello - we are now recording this call I will now count to 10 ");

            for (int i = 1; i <= 10; i++)
            {
                sb.Append(i + " ");
            }

            var talkAction = new TalkAction()
            {
                Text = sb.ToString()
            };
            var ncco = new Ncco(recordAction, talkAction);

            return(ncco.ToString());
        }
예제 #4
0
        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 request        = WebhookParser.ParseQuery <Answer>(Request.Query);
            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(Ok(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()));
        }
예제 #6
0
        private Response OnAnswerRecordMessage()
        {
            var talkAction = new TalkAction()
            {
                Text = "Please leave a message after the tone, then press pound."
            };

            var recordAction = new RecordAction()
            {
                EndOnKey  = "#",
                BeepStart = "True",
                EventUrl  = new[] { $"{SiteBase}/webhook/record" }
            };

            var secondTalkAction = new TalkAction()
            {
                Text = "Thank you for your message. Goodbye"
            };

            var ncco = new Ncco(talkAction, recordAction, secondTalkAction);

            return(ncco.ToString());
        }
        public string Answer()
        {
            var YOUR_SECOND_NUMBER = Environment.GetEnvironmentVariable("YOUR_SECOND_NUMBER") ?? "YOUR_SECOND_NUMBER";
            var VONAGE_NUMBER      = Environment.GetEnvironmentVariable("VONAGE_NUMBER") ?? "VONAGE_NUMBER";

            var talkAction = new TalkAction()
            {
                Text      = "Thank you for calling",
                VoiceName = "Kimberly"
            };

            var secondNumberEndpoint = new PhoneEndpoint()
            {
                Number = YOUR_SECOND_NUMBER
            };
            var connectAction = new ConnectAction()
            {
                From = VONAGE_NUMBER, Endpoint = new[] { secondNumberEndpoint }
            };

            var ncco = new Ncco(talkAction, connectAction);

            return(ncco.ToString());
        }
        public ActionResult Answer()
        {
            var host            = Request.Host.ToString();
            var webSocketAction = new ConnectAction()
            {
                Endpoint = new[]
                {
                    new WebsocketEndpoint()
                    {
                        Uri         = $"ws://{host}/ws",
                        ContentType = "audio/l16;rate=16000",
                        Headers     = new Translation
                        {
                            UUID               = Request.Query["uuid"].ToString(),
                            LanguageSpoken     = "en-US",
                            LanguageTranslated = "es-MX"
                        }
                    }
                }
            };
            var ncco = new Ncco(webSocketAction);

            return(Ok(ncco.ToString()));
        }
예제 #9
0
 public CallResponse CreateCall(Endpoint toEndPoint, string fromNumber, Ncco ncco)
 {
     return(CreateCallAsync(toEndPoint, fromNumber, ncco).GetAwaiter().GetResult());
 }
예제 #10
0
 public CallResponse CreateCall(string toNumber, string fromNumber, Ncco ncco)
 {
     return(CreateCallAsync(toNumber, fromNumber, ncco).GetAwaiter().GetResult());
 }