我正在嘗試按照Microsoft Docs 中的這篇文章將我們的版本 3 代碼遷移到版本 4。但是,我不確定如何重寫 Luis 對話框。必須做什么?我在 onturnasync 中添加了以下代碼,現在不確定如何重寫 AfterFAQ resume 方法。請幫助我重寫這些現有的 Luis 方法: //The LUIS dialog service call the back the method if the conversation is part of Greeting intent [LuisIntent("Greetings")] public async Task Greetings(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result) { needMoreInformation = false; qnaInvalidMessageCount = 0; var messageToForward = await activity; string[] supportList = { "HELP", "FEEDBACK", "SUPPORT", "ESCALATE", "AGENT" }; string qnaAnswer; if (messageToForward.Text == null || supportList.Any(x => x == messageToForward.Text.ToUpper())) { await context.PostAsync("Please reach out to ..."); context.Wait(MessageReceived); } else if (GreetingColl.TryGetValue(messageToForward.Text.Trim().ToLower(), out qnaAnswer)) { await context.PostAsync(qnaAnswer); context.Wait(MessageReceived); } else { await context.Forward(new QnAGreetingsDialog(), AfterFAQDialog, messageToForward, CancellationToken.None); } }修改代碼: public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) { if (turnContext.Activity.Type == ActivityTypes.Message) { ... var luisResults = await botServices.LuisServices[LuisKey].RecognizeAsync(turnContext, cancellationToken); var topScoringIntent = luisResults?.GetTopScoringIntent(); var topIntent = topScoringIntent.Value.intent;
1 回答

泛舟湖上清波郎朗
TA貢獻1818條經驗 獲得超3個贊
如果您的問題是關于 Bot Framework core v4,PFB 獲取意圖的步驟:
首先,您需要在 bot 框架中使用密鑰將 LUIS 服務注入到服務中。
使用以下代碼獲取識別器結果對象
var luisResults = await services.LuisServices[LuisKey].RecognizeAsync(turnContext, default(CancellationToken));
LUIS 密鑰是注入 LUIS 服務時使用的密鑰。
這是使用 RecognizerResult 對象獲取意圖的方法。
luisResults.GetTopIntent(luisThresholdScore).intent;
- 1 回答
- 0 關注
- 92 瀏覽
添加回答
舉報
0/150
提交
取消