我正在开发一个可以预订航班的机器人。我正在使用最新版本的bot框架(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; }
}
我从路易斯得到以下回复:
{
"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描述了。
到目前为止我尝试了什么
所以我有点困惑如何解决这个问题。我是否正确配置了LUIS?我是否需要配置EntityRecognizer? LUIS entity attribute会很好。
希望你能帮助我!
答案 0 :(得分:2)
您的Luis实体类型应与表单中的字段名称匹配。如果您为Luis实体更改"type": "Flight::LocationFrom"
至"type": "LocationFrom"
,则表单流应与表单中LocationFrom
字段的实体匹配,并正确填充。