public async Task GenericIntent(IDialogContext context, LuisResult result) { //resposta do Qna QnAAnswer qnAAnswer = null; //variavel de controle do intent string intent = String.Empty; //verifica se o LUIS rtornou algumointent if (result.Intents.Count > 0) { intent = result.Intents.First().Intent; } //verifica se existe esse content nas onfiguracoes do servico if (QnaServices.ContainsKey(intent)) { //rcupera o servico do QnA var qnaService = QnaServices[intent]; //recupera a respost do servico de QnA qnAAnswer = await qnaService.GetAnswer(result.Query); //seta a resposta padrao string qnaMakerAnswer = "Nenhum resultado foi encontrado."; //verifica se existe resposta do Qna if (qnAAnswer.answers.Count > 0) { qnaMakerAnswer = qnAAnswer.answers[0].answer; //Retorna a resposta await context.PostAsync($"{qnaMakerAnswer}"); //Exibe o feedback se o score for inferior ao threshold if (qnAAnswer.answers[0].score < Threshlod) { context.Call(new FeedbackDialog(LuisAppId, qnAAnswer), ResumeAfterFeedback); } } else { //Retorna a resposta await context.PostAsync($"{qnaMakerAnswer}"); //Espera ate que a mensagem chegue por completo context.Wait(MessageReceived); } } else //se nao existe intent { //seta a rsposta do Luis await this.ShowLuisResult(context, result); } //registra o Log await Logger.Instance.LogarLuisQna ( LuisAppId, context, result, qnAAnswer ); }
public FeedbackDialog(string luisAppId, QnAAnswer qnAAnswer) { // keep track of data associated with feedback _luisAppId = luisAppId; _qnAAnswer = qnAAnswer; }