我想用LUIS建立一個機器人,但它比我想象的要困難得多。 到目前爲止,我已經成功地創建我LUIS應用程序並創建一個意圖和實體,我設計了幾個話語,似乎很好地工作。微軟Bot框架,LUIS和動作參數
然後我創建了我的機器人,並將它連接到路易斯。當我測試我的機器人時,它按預期工作。 現在,有趣的部分。我想處理參數。在路易斯我添加了一個動作我意圖:
正如你可以看到我已經添加了一個提示。 我在我的機器人代碼目前看起來是這樣的:
/// <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);
}
我想你能猜出我與這是怎麼回事。如果用戶輸入幫我購買相機,它會得到選擇類別意圖和將有正確的實體選中。 但是,如果他們鍵入幫我買,它仍然會去正確的意圖,但它不會有一個選定的實體。我希望我的機器人能夠看到並使用我在LUIS中創建的提示中的文本,並且當用戶選擇他們的實體我希望它返回LUIS並使用該參數。
我不知道如何做到這一點,我找不到任何教程。 任何幫助將不勝感激(甚至鏈接!)
您可以添加您的LUIS模型的圖像,以便我們瞭解您擁有的意圖/實體嗎?TryFindCategory在做什麼? –
目前只有1個意圖(選擇類別)和1個實體(類別)。 TryFindCategory只是一個摘錄從https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Samples/AlarmBot/Dialogs/AlarmLuisDialog.cs第60行,而不是布爾我只是返回實體或null。 – r3plica