问题
I'm having trouble getting my Luis Entities to bind to my FormFlow fields so I can skip steps in the FormFlow. A simplified version of my FormFlow dialog is as follows
[Serializable]
public class DoSearch
{
public string SearchTerm;
public static IForm<DoSearch> BuildForm()
{
var builder = new FormBuilder<DoSearch>();
return builder
.Message("Search Function")
.Field(nameof(DoSearch.SearchTerm))
.AddRemainingFields()
.Confirm("Are you sure you wish to search for {SearchTerm} ?")
.Build();
}
}
And I am calling this with the following code
public async Task StartSearch(IDialogContext context, LuisResult result)
{
var searchForm = new BuildForm<DoSearch>(() => DoSearch.BuildForm());
var searchForm1 = new FormDialog<DoSearch>(new DoSearch(), searchForm , FormOptions.PromptInStart, result.Entities);
context.Call<searchForm>(searchForm1, SearchComplete);
// ...
}
The result.Entities does contain the appropriate entity (Type = SearchTerm) but the FormFlow always asks for this when it runs.
The example Pizza bot sample code seems to work, but I can't seem to get it to bind the entity to the field.
Anyone have any ideas what I'm doing wrong?
Thanks in advance
回答1:
It appears that this is a bug. Entities seem to bind to properties that are Enums, but that are strings.
https://github.com/Microsoft/BotBuilder/issues/151
Hopefully this will be sorted at some point
回答2:
If you get the last version of the SDK it should work.
This has been fixed in this commit : https://github.com/Microsoft/BotBuilder/commit/e81b9dd23b3c69024caf8b53dcddc0bf158f61e2
来源:https://stackoverflow.com/questions/36712912/mapping-luis-entities-to-dialog-fields