我建议您尝试使用 BestMatchDialog 替换尽可能多的场景(至少 15 个)。
您仍将使用 LuisDialog 作为您的根对话框。
这是一个例子:
[Serializable]
public class GreetingsDialog: BestMatchDialog<bool>
{
[BestMatch(new string[] { "Hi", "Hi There", "Hello there", "Hey", "Hello",
"Hey there", "Greetings", "Good morning", "Good afternoon", "Good evening", "Good day" },
threshold: 0.5, ignoreCase: true, ignoreNonAlphaNumericCharacters: true)]
public async Task WelcomeGreeting(IDialogContext context, string messageText)
{
await context.PostAsync("Hello there. How can I help you?");
context.Done(true);
}
[BestMatch(new string[] { "bye", "bye bye", "got to go",
"see you later", "laters", "adios" })]
public async Task FarewellGreeting(IDialogContext context, string messageText)
{
await context.PostAsync("Bye. Have a good day.");
context.Done(true);
}
public override async Task NoMatchHandler(IDialogContext context, string messageText)
{
context.Done(false);
}
}
从你的 LuisDialog 你可以这样称呼它
[LuisIntent("None")]
[LuisIntent("")]
public async Task None(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)
{
var cts = new CancellationTokenSource();
await context.Forward(new GreetingsDialog(), GreetingDialogDone, await message, cts.Token);
}
上面的代码是从Ankitbko's MeBot repo借来的。