private async Task <DialogStepResult> ProcessResponseOnYouAreLate(string text) { var luisResult = await _luisService.GetIntent(text); switch (luisResult.Intent) { case "BeSoon": if (luisResult.Entities.ContainsKey("builtin.datetime.time")) { return(new DialogStepResult(String.Format("{0}, no more!", luisResult.Entities["builtin.datetime.time"]), new DialogStep(ProcessResponseOnHurryUp, DidntCatchResponse))); } else { return(new DialogStepResult("Ok... No more!", new DialogStep(ProcessResponseOnHurryUp, DidntCatchResponse))); } case "AskForgiveness": return(new DialogStepResult("No more sorries! Hurry up!", new DialogStep(ProcessResponseOnYouAreLate, DidntCatchResponse))); case "AlreadyHere": return(new DialogStepResult("Really? And where were you all that time? I'm on the second floor", new DialogStep(FinalResponse, FinalResponse))); default: return(await DidntCatchResponse(null)); } }
private async Task <DialogStepResult> ProcessGuessResponse(string text) { string guessString = null; var result = await _luisService.GetIntent(text); result?.Entities.TryGetValue("builtin.number", out guessString); int?guess = ConvertToNumber(guessString); if (guess == null) { return(await DidntCatchResponse(null)); } if (_retriesLeft <= 0) { return(new DialogStepResult("This one was the last. Who you are? Who? You are the looooser!", new DialogStep(FinalResponse, FinalResponse))); } if (guess == _unknownNumber) { return(new DialogStepResult("You got it. My congratulation!!!", new DialogStep(FinalResponse, FinalResponse))); } else if (_mentionedNumbers.Contains(guess.Value)) { return(new DialogStepResult("Oh, you have already called this one. Try again", new DialogStep(ProcessGuessResponse, FinalResponse))); } else { var response = _noResponses[(new Random()).Next(_noResponses.Length)]; _mentionedNumbers.Add(guess.Value); _retriesLeft--; return(new DialogStepResult(response, new DialogStep(ProcessGuessResponse, DidntCatchResponse))); } }
public async Task <TextAndAudioWrapper> InputQuestionAndReturnAnswer(TextInput textInput) { var luisService = new LuisService(); var wrapper = new TextAndAudioWrapper(); var question = textInput.Text; var generalKB = new QnAMakerService(_qnaHostName, "d282ad63-9701-4548-afac-a421f0ec43ed", _endPointKey); var groupKB = new QnAMakerService(_qnaHostName, "b51f7e68-706b-42e4-8b31-0dd34d392a54", _endPointKey); var postKB = new QnAMakerService(_qnaHostName, "92e0fe0c-8826-4e60-8c47-9a4d36cb629e", _endPointKey); var intent = await luisService.GetIntent(question); string answer; switch (intent) { case "Group": answer = await groupKB.GetAnswer(question); break; case "Post": answer = await postKB.GetAnswer(question); break; case "None": answer = await generalKB.GetAnswer(question); break; default: answer = "Sorry, I don't know that."; break; } if (answer == "") { answer = "Sorry, I don't know that."; } var textToSpeechService = new TextToSpeechService(); var audioAnswer = await textToSpeechService.GenerateAudioSpeech(answer); wrapper.Text = answer; wrapper.Audio = audioAnswer; return(wrapper); }