Beispiel #1
0
        private static VoiceResponse CreateVoiceResponsePolly(BotReponse botResponse)
        {
            var voiceResponse = new VoiceResponse();

            if (botResponse.endCall)
            {
                var text = "https://feedbackbotjp.azurewebsites.net/api/Polly" + "?text=" + System.Web.HttpUtility.UrlEncode(botResponse.ResponseText);
                voiceResponse.Append(new Play(new Uri(text)));
                voiceResponse.Hangup();

                // at this point we could persist our result in a db or put on a queue
            }
            else
            {
                var input = new List <InputEnum> {
                    InputEnum.Speech
                };
                var gather = new Gather(input: input, timeout: 30, numDigits: 1, language: "en-GB", speechTimeout: "1");

                var text = "https://feedbackbotjp.azurewebsites.net/api/Polly" + "?text=" + System.Web.HttpUtility.UrlEncode(botResponse.ResponseText);
                gather.Play(new Uri(text));

                //gather.Say(botResponse.ResponseText, Say.VoiceEnum.Man, language: Say.LanguageEnum.EnGb);
                voiceResponse.Append(gather);
            }

            return(voiceResponse);
        }
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            BotReponse response = ProcessMessage(context, activity);

            if (!string.IsNullOrEmpty(response.ResponseText))
            {
                await context.PostAsync(response.ResponseText);
            }

            if (response.endCall)
            {
                context.ConversationData.Clear();
                await context.PostAsync("CALL HAS BEEN ENDED");
            }

            context.Wait(MessageReceivedAsync);
        }
Beispiel #3
0
        private static VoiceResponse CreateVoiceResponse(BotReponse botResponse)
        {
            var voiceResponse = new VoiceResponse();

            if (botResponse.endCall)
            {
                voiceResponse.Append(new Say(botResponse.ResponseText, Say.VoiceEnum.Man, language: Say.LanguageEnum.EnGb));
                voiceResponse.Hangup();

                // at this point we could persist our result in a db or put on a queue
            }
            else
            {
                var input = new List <InputEnum> {
                    InputEnum.Speech, InputEnum.Dtmf, InputEnum.Dtmf
                };
                var gather = new Gather(input: input, timeout: 30, numDigits: 1, language: "en-GB", speechTimeout: "1");
                gather.Say(botResponse.ResponseText, Say.VoiceEnum.Man, language: Say.LanguageEnum.EnGb);
                voiceResponse.Append(gather);
            }

            return(voiceResponse);
        }