コード例 #1
0
        public override AlexaResponse CalculateResponseForAlexa(Request request)
        {
            if (userInput == "repeat" || userInput == "replay")
            {
                AlexaResponse response = new AlexaResponse();
                response.Response.OutputSpeech.Ssml = "<speak>" + currentQuestion.text + "<break time='1s'/>" + currentQuestion.answers + "</speak>";
                response.Response.OutputSpeech.Type = "SSML";
                response.Response.ShouldEndSession  = false;
                DirectivesAttributes directive = CreateDirectiveWithSlot(request, currentQuestion.slotIdentifier);
                response.Response.Directives.Add(directive);

                return(response);
            }
            return(null);
        }
コード例 #2
0
        public override AlexaResponse CalculateResponseForAlexa(Request request)
        {
            if (request.IsNew || request.SlotsList.Count(x => string.IsNullOrEmpty(x.Value)) == 5)
            {
                AlexaResponse response = new AlexaResponse();
                response.Response.OutputSpeech.Ssml = "<speak>" + _currentQuestion.text + "<break time='1s'/>" + _currentQuestion.answers + "</speak>";
                response.Response.OutputSpeech.Type = "SSML";
                response.Response.ShouldEndSession  = false;
                DirectivesAttributes directive = CreateDirectiveWithSlot(request, _currentQuestion.slotIdentifier);
                response.Response.Directives.Add(directive);

                CreateCardContent(_currentQuestion, response);
                return(response);
            }

            return(null);
        }
コード例 #3
0
        public override AlexaResponse CalculateResponseForAlexa(Request request)
        {
            var countOfEmptyslots = request.SlotsList.Count(x => string.IsNullOrEmpty(x.Value));

            if (countOfEmptyslots == 0)
            {
                var response = new AlexaResponse();
                correctAnswer = GetTheCorrectAnswer(previousQuestion, userInput);
                var score = GetScore(listOfAllQuestions, request.SlotsList);
                response.Response.OutputSpeech.Ssml += "<speak>" + correctAnswer + "<break time='1s'/> Your total score is " + score + " out of 5.  < emphasis level =\"moderate\">Geek</emphasis> </speak>";
                response.Response.OutputSpeech.Type  = "SSML";
                response.Response.ShouldEndSession   = true;

                CreateCardContent(previousQuestion, response);
                return(response);
            }
            return(null);
        }
コード例 #4
0
        public override AlexaResponse CalculateResponseForAlexa(Request request)
        {
            var response = new AlexaResponse();

            var headerNextQuestion = " <break time='1s'/>The next question is<break time='1s'/>";

            correctAnswer = GetTheCorrectAnswer(previousQuestion, userInput);
            var text = "<emphasis level=\"moderate\">" + correctAnswer + "</emphasis> ";

            response.Response.OutputSpeech.Ssml = "<speak>" + text + headerNextQuestion + nextQuestion.text + "<break time='1s'/>" + nextQuestion.answers + "</speak>";
            response.Response.OutputSpeech.Type = "SSML";
            response.Response.ShouldEndSession  = false;
            DirectivesAttributes directive = CreateDirectiveWithSlot(request, nextQuestion.slotIdentifier);

            response.Response.Directives.Add(directive);

            CreateCardContent(nextQuestion, response);
            return(response);
        }
コード例 #5
0
        public override AlexaResponse CalculateResponseForAlexa(Request request)
        {
            int number;

            Int32.TryParse(userInput, out number);

            if (number <= 0 || number > 4)
            {
                var response = new AlexaResponse();
                response.Response.OutputSpeech.Ssml = "<speak>Please pick a number from  1 to 4.</speak>";
                response.Response.OutputSpeech.Type = "SSML";
                response.Response.ShouldEndSession  = false;
                //var o = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(request.Slots);
                //o.Property("value").Remove();
                // request.Request.Intent.Slots[slots.Last().Key] = o;
                DirectivesAttributes directive = CreateDirectiveWithSlot(request, previousQuestion.slotIdentifier);
                response.Response.Directives.Add(directive);
                return(response);
            }
            return(null);
        }
コード例 #6
0
 protected void CreateCardContent(Question question, AlexaResponse response)
 {
     response.Response.Card.Content = "Question: " + question.text.Replace("<break time='1s'/>", " ") + "\n Please choose from: \n" +
                                      question.answers.Replace("<break time='1s'/>", " ").Replace(".", "\n") +
                                      "\n Correct answer: " + question.correctAnswer;
 }