Reputation: 11
I am using the sample "SandwichOrder" code. When I use the property "Describe" to change the item value the bot doesn't understand the setted value.
public enum LengthOptions
{
[Describe("Test 1")]
SixInch = 1,
[Describe("Test 2")]
FootLong = 2
};
This is the output:
Upvotes: 1
Views: 75
Reputation: 1248
What @Grace Feng mentioned is one way to do that. Another simpler way would be to add the Terms
decoration to LengthOptions
each item.
So the code would be :
public enum LengthOptions
{
[Terms(new string[] { "Test 1" })]
[Describe("Test 1")]
SixInch = 1,
[Terms(new string[] { "Test 2" })]
[Describe("Test 2")]
FootLong = 2
};
Now your bot will automatically understand the value of "Test 1" as SixInch and "Test 2" as FootLong
Upvotes: 0
Reputation: 16652
It's the problem how FormFlow
handles the feedback after user's selection, the result is actually right the type of LengthOptions
. Since we're not able to modify the source code of BotBuilder SDK
, here is a workaround to solve this problem: we try to override the feedback of this item in FormFlow
, and here is the code when building the FormDialog
:
...
.Field(nameof(Length),
validate: async (state, response) =>
{
var result = new ValidateResult { IsValid = true, Value = response };
var value = (LengthOptions)response;
result.Feedback = "Your selection means " + value;
return result;
})
...
The Length
property in above code can be defined like this:
public enum LengthOptions
{
[Describe("Test 1")]
SixInch = 1,
[Describe("Test 2")]
FootLong = 2
};
public LengthOptions? Length { get; set; }
Here is the test result:
Upvotes: 1