问题
I am working on a bot where you can book a flight. I'm working with the latest version of the bot framework (1.1), as suggested suggested here.
You can say things like "Book me a flight from Amsterdam to Boston next monday".
Now, I configured LUIS to respond with the intent "BookFlight" and in my bot I've made a LuisDialog and FormDialog like so:
[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; }
}
I get the following response from 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"
}
}
]
}
]
}
]
}
The problem
The form is not filled with the right values from LUIS. So the bot will ask you to fill in your departure location, date and the location you want to fly to. But this is already described to LUIS.
What I've tried so far
- Made a new app with no entity children but with the right entity names, no values were filled in the form.
- Renamed at runtime the 'types' from the entity from 'Flight::LocationTo' to 'LocationTo', etc. This worked, but it didn't work for the date.
- Prefilled the new instance of 'BookFlightForm' with the right values, but the bot will still ask for the values of the date.
So I am a bit puzzled how to fix this. Did I configure LUIS correctly? Do I need to configure the EntityRecognizer? A LUIS entity attribute would be nice.
Hope you can help me!
回答1:
Your Luis entity type should match the field name in your form. If you change "type": "Flight::LocationFrom"
to "type": "LocationFrom"
for your Luis entity, form flow should match the entity with the LocationFrom
field in your form and populate it correctly.
来源:https://stackoverflow.com/questions/36998505/connecting-luis-dialog-to-form-dialog-and-mapping-the-right-fields