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); }
public static string GetExpectedAnswer(this AlexaAPI.Request.SkillRequest request) { object answer = null; request.Session.Attributes.TryGetValue("answer", out answer); return(answer as string); }
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); } }
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); }
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); }
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); }
public static string GetIntentName(this AlexaAPI.Request.SkillRequest request) { return(request?.Request?.Intent?.Name); }