Esempio n. 1
0
        public DirectivesAttributes CreateDirectiveWithSlot(Request request, string slotNumber)
        {
            var directive = new DirectivesAttributes();

            directive.SlotToElicit = slotNumber;
            directive.Type         = "Dialog.ElicitSlot";
            directive.UpdatedIntentAttributes.Name  = request.Intent;
            directive.UpdatedIntentAttributes.Slots = request.Slots;
            return(directive);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }