private void GeneratePrompt(IDialogContext context, CustomQnAMakerResults qnaResult) { var helper = GetDialogHelper(context, qnaResult); var qnaList = qnaResult.Answers; var questions = qnaList.Select(x => x.Questions[0]) .Concat(new[] { ResourcesDE.NoneOfTheAboveOption }).ToArray(); PromptOptions <string> promptOptions = new PromptOptions <string>( prompt: ResourcesDE.AnswerSelectionPrompt, tooManyAttempts: ResourcesDE.TooManyAttempts, options: questions, attempts: 0); PromptDialog.Choice(context: context, resume: helper.ResumeAndPostAnswer, promptOptions: promptOptions); }
private QnAMakerDialogHelper GetDialogHelper(IDialogContext context, CustomQnAMakerResults qnaResult) { var message = context.Activity.AsMessageActivity(); FeedbackRecord feedback = null; if (message != null) { feedback = new FeedbackRecord { UserId = message.From.Id, UserQuestion = message.Text }; } return(new QnAMakerDialogHelper(qnaResult, feedback, _qnAService)); }
private async Task <Boolean> IsDefaultOrErrorAnswerReturned(String question, IDialogContext context, CustomQnAMakerResults qnaResult, IEnumerable <EntityRecommendation> entities) { if (!qnaResult.Answers.Any() || !_answersScoringService.IsAppropriateAnswer(qnaResult.Answers)) { //save unanswered question var credentials = await _databasesConnectionService.GetUserCredentials(context); _questionsProcessingService.ProcessNotAnsweredQuestion(question, credentials?.UserName); //return default answer await ReturnAnswer(context, null); return(true); } return(false); }