【发布时间】:2016-11-14 16:05:39
【问题描述】:
我正在尝试使用 LUIS 构建一个机器人,但它比我想象的要困难得多。 到目前为止,我已经成功地创建了我的 LUIS 应用程序并创建了一个 Intent 和一个 Entity,并且我创建了一些似乎可以正常工作的 Utterances .
然后我创建了我的机器人并将其连接到 Luis。当我测试我的机器人时,它按预期工作。 现在是有趣的部分。我想处理参数。在 Luis 上,我向我的 Intent 添加了一个动作:
如您所见,我添加了一个提示。 我的机器人中的代码目前如下所示:
/// <summary>
/// Tries to find the category
/// </summary>
/// <param name="result">The Luis result</param>
/// <param name="alarm"></param>
/// <returns></returns>
public string TryFindCategory(LuisResult result)
{
// Variable for the title
EntityRecommendation title;
// If we find our enenty, return it
if (result.TryFindEntity(PiiiCK.Category, out title))
return title.Entity;
// Default fallback
return null;
}
[LuisIntent("Choose category")]
public async Task ChooseCategory(IDialogContext context, LuisResult result)
{
// Get our category
var category = TryFindCategory(result);
var response = "The category you have chosen is not in the system just yet.";
switch (category)
{
case "camera":
response = $"You need help buying a { category }, is this correct?";
this.started = true;
break;
default:
if (!string.IsNullOrEmpty(category)) response = $"Sorry, PiiiCK does not deal with { category.Pluralise() } just yet.";
break;
}
// Post our response back to the user
await context.PostAsync(response);
// Execute the message recieved delegate
context.Wait(MessageReceived);
}
我想你可以猜到我的意思。如果用户输入帮我买个相机,它将进入Choose category Intent,并选择正确的Entity。 但是,如果他们输入 Help me buy,它仍然会转到正确的 Intent,但不会有选定的 Entity。我希望我的机器人看到并使用我在 LUIS 中创建的 Prompt 中的文本,当用户选择他们的 entity 时,我希望它返回到 LUIS参数。
我不知道该怎么做,也找不到任何教程。 任何帮助将不胜感激(甚至链接!)
【问题讨论】:
-
您能否添加您的 LUIS 模型的图像,以便我们了解您的意图/实体? TryFindCategory 在做什么?
-
目前只有 1 个 Intent (Choose category) 和 1 个 Entity (Category)。 TryFindCategory 只是从 github.com/Microsoft/BotBuilder/blob/master/CSharp/Samples/… 第 60 行提取的内容,其中不是布尔值,而是返回实体或 null。
标签: c# botframework azure-language-understanding