private async Task <TransferObjectQnA> DefaultMatchHandlerWithReturn(IDialogContext context, string queryString, QnAMakerResult qnAMakerResultObject) { TransferObjectQnA transfer = new TransferObjectQnA { Answer = qnAMakerResultObject.Answers.First().Answer, Question = queryString, Score = qnAMakerResultObject.Answers.First().Score }; return(transfer); }
private async Task <TransferObjectQnA> NoMatchHandlerWithReturn(IDialogContext context, string queryString) { TransferObjectQnA transfer = new TransferObjectQnA { Answer = Ressources.QnAMakerRessources.NoMatchFoundHandlerMessage, Question = queryString, Score = 0 }; return(transfer); }
private async Task <TransferObjectQnA> MakeQnAMakerCallforConversion(IDialogContext context, string QueryString) { string KnowledgeBaseId = KeysAndRessourceStrings.KnowledgeBaseIdConvert; string SubscriptionKey = KeysAndRessourceStrings.SubscriptionKeyQnAMaker; IQnAMakerRequests QnAMakerObject = new QnAMakerRequests(); IQnAMakerMatchHandler qnAMakerMatchHandler = new QnAMakerMatchHandler(); // Name to number magic QnAMakerResult QnAMakerResultObject = await QnAMakerObject.GetQnAMakerResponse(QueryString, KnowledgeBaseId, SubscriptionKey); TransferObjectQnA querystring = await qnAMakerMatchHandler.QnAMakerResultProcessingWithReturn(context, QueryString, QnAMakerResultObject); return(querystring); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; TransferObjectQnA QnAMakerResult = await MakeQnAMakerCallforConversion(context, activity.Text); if (QnAMakerResult.Score < 0.2) { await context.PostAsync(QnAMakerResult.Answer.ToString()); await context.PostAsync($"I could not find \"{QnAMakerResult.Question}\" in my Database."); context.Wait(MessageReceivedAsync); } else { JObject StarwarsAnswer = await CallStarWarsApi(context, QnAMakerResult.Answer); await context.PostAsync(StarwarsAnswer.ToString()); context.Wait(MessageReceivedAsync); } }