Exemple #1
0
        public static string GetActualAnswer(this AlexaAPI.Request.SkillRequest request)
        {
            AlexaAPI.Request.Slot slot = null;
            request.Request.Intent.Slots.TryGetValue("answerValue", out slot);

            return(slot?.Value);
        }
Exemple #2
0
        public static string GetExpectedAnswer(this AlexaAPI.Request.SkillRequest request)
        {
            object answer = null;

            request.Session.Attributes.TryGetValue("answer", out answer);
            return(answer as string);
        }
Exemple #3
0
 public static int GetNumberOfQuestionsAsked(this AlexaAPI.Request.SkillRequest request)
 {
     if (request.Session?.Attributes?.ContainsKey("numberOfQuestionsAsked") == true)
     {
         var number = request.Session?.Attributes?["numberOfQuestionsAsked"];
         return(Int32.Parse(number.ToString()));
     }
     else
     {
         return(0);
     }
 }
Exemple #4
0
        public static QuestionType GetQuestionType(this AlexaAPI.Request.SkillRequest request)
        {
            object sessionValue = null;

            request.Session.Attributes.TryGetValue("questionType", out sessionValue);

            var          questionType = sessionValue as string;
            QuestionType value;

            Enum.TryParse <QuestionType>(questionType, out value);

            return(value);
        }
Exemple #5
0
        public static MyFirstAlexaSkill.Application.AlexaServiceResponse WithSpeechResponse(this AlexaAPI.Request.SkillRequest request, string speech)
        {
            var intentName = request.GetIntentName();
            var response   = MyFirstAlexaSkill.Application.AlexaServiceResponse.CreateSpeechResponse(intentName, speech, true);

            return(response);
        }
Exemple #6
0
        public static MyFirstAlexaSkill.Application.AlexaServiceResponse WithQuestionResponse(this AlexaAPI.Request.SkillRequest request,
                                                                                              Question question,
                                                                                              string speech)
        {
            var intentName   = request.GetIntentName();
            var outputSpeech = speech + question.Problem;

            var response = MyFirstAlexaSkill.Application.AlexaServiceResponse.CreateQuestionResponse(intentName, outputSpeech, false);

            response.SetExpectedAnswer(question.Answer);
            response.SetQuestionType(question.Type);

            var numberOfQuestionsAsked = request.GetNumberOfQuestionsAsked();

            numberOfQuestionsAsked += 1;
            response.SetNumberOfQuestionsAsked(numberOfQuestionsAsked);

            return(response);
        }
Exemple #7
0
 public static string GetIntentName(this AlexaAPI.Request.SkillRequest request)
 {
     return(request?.Request?.Intent?.Name);
 }