【发布时间】:2016-08-28 03:59:43
【问题描述】:
我正在开发一个机器人,您可以在其中预订航班。我正在使用最新版本的机器人框架 (1.1),正如suggested 所建议的那样。
您可以说“为我预订下周一从阿姆斯特丹到波士顿的航班”。
现在,我将 LUIS 配置为响应意图“BookFlight”,并在我的机器人中创建了一个 LuisDialog 和 FormDialog,如下所示:
[LuisIntent("BookFlight")]
public async Task Process(IDialogContext context, LuisResult result)
{
var form = new BookFlightForm();
var entities = new List<EntityRecommendation>(result.Entities);
var formDialog = new FormDialog<BookFlightForm>(form, BuildForm, FormOptions.PromptInStart, entities);
context.Call(formDialog, OnComplete);
}
[Serializable]
public class BookFlightForm
{
[Prompt("From which city do you want to leave from? {||}", AllowDefault = BoolDefault.True)]
[Describe("Location, example: Amsterdam")]
public string LocationFrom { get; set; }
[Prompt("To which city you want to fly to? {||}", AllowDefault = BoolDefault.True)]
[Describe("Location, example: Las Vegas")]
public string LocationTo { get; set; }
[Prompt("When do you want to leave? {||}", AllowDefault = BoolDefault.True)]
[Describe("Departure date, example: tomorrow, next week or any date like 12-06-2016")]
public DateTime DepartureDate { get; set; }
}
我收到 Luis 的以下回复:
{
"intent": "BookFlight",
"score": 0.987034,
"actions": [
{
"triggered": true,
"name": "BookFlight",
"parameters": [
{
"name": "locationFrom",
"required": true,
"value": [
{
"entity": "amsterdam",
"type": "Flight::LocationFrom",
"score": 0.8548711
}
]
},
{
"name": "locationTo",
"required": true,
"value": [
{
"entity": "boston",
"type": "Flight::LocationTo",
"score": 0.962294638
}
]
},
{
"name": "departureDate",
"required": true,
"value": [
{
"entity": "next monday",
"type": "builtin.datetime.date",
"resolution":
{
"date": "2016-05-09"
}
}
]
}
]
}
]
}
问题
表单未填充来自 LUIS 的正确值。所以机器人会要求你填写你的出发地点、日期和你想飞往的地点。但这已向 LUIS 进行了描述。
到目前为止我所做的尝试
- 制作了一个没有子实体但具有正确实体名称的新应用,但表单中没有填写任何值。
- 在运行时将实体中的“类型”从“Flight::LocationTo”重命名为“LocationTo”等。这有效,但不适用于该日期。
- 用正确的值预填充“BookFlightForm”的新实例,但机器人仍会询问日期的值。
所以我有点困惑如何解决这个问题。我是否正确配置了 LUIS?我需要配置 EntityRecognizer 吗? LUIS entity attribute 会很好。
希望你能帮助我!
【问题讨论】:
-
快速提问。您是如何在 LUIS 中获得此离开日期结构的?你有它作为你自己的实体“departureDate”,但它也是一个“builtin.datetime.date”,这意味着你可以解析日期。
标签: c# bots botframework azure-language-understanding