There is a bot created from the template http://aka.ms/bf-bc-vstemplate
In the created project I was update Bot Builder Package.
I try to understand examples of FormFlow from the documentatio: https://docs.microsoft.com/uk-ua/bot-framework/dotnet/bot-builder-dotnet-formflow-advanced
I'm trying to run this example:
public static IForm<SandwichOrder> BuildForm()
{
return new FormBuilder<SandwichOrder>()
.Message("Welcome to the sandwich order bot!")
.Field(nameof(Sandwich))
.Field(nameof(Length))
.Field(nameof(Bread))
.Field(nameof(Cheese))
.Field(nameof(Toppings),
validate: async (state, value) =>
{
var values = ((List<object>)value).OfType<ToppingOptions>();
var result = new ValidateResult { IsValid = true, Value = values };
if (values != null && values.Contains(ToppingOptions.Everything))
{
result.Value = (from ToppingOptions topping in Enum.GetValues(typeof(ToppingOptions))
where topping != ToppingOptions.Everything && !values.Contains(topping)
select topping).ToList();
}
return result;
})
.Message("For sandwich toppings you have selected {Toppings}.")
.Build();
}
I go to the step with a choice of Toppings and was writing "Everything". In response comes:
Exception: The given key was not present in the dictionary.
[File of type 'text/plain']
If I write Olives, there is no error and the answer is the expected: "For sandwich toppings you have selected Olives."
What am I doing wrong?
I'm really not sure what you are doing wrong, I just tested the annotated sandwich bot and was able to select "Everything" by typing in "Everything". Have you modified the code at all? I was not able to reproduce.

@JasonSowers, could you see my solution, please?
Please try replacing you ToppingsOptions enum with this:
public enum ToppingOptions
{
[Terms("except", "but", "not", "no", "all", "everything")]
Everything=1,
Avocado, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes
};
Thank you so much! It worked!
Could you explain why work code:
public enum ToppingOptions
{
Everything=1,
Avocado, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes
};
and do not work
public enum ToppingOptions
{
Avocado, BananaPeppers, Cucumbers, GreenBellPeppers, Jalapenos,
Lettuce, Olives, Pickles, RedOnion, Spinach, Tomatoes,
Everything
};
?
To e perfectly honest I'm not exactly sure, it is just the way it is coded in the example . Formflow is kind of black box to me, Sorry I do not have a concrete answer for you. Maybe someone else can jump in and explain
This page https://docs.microsoft.com/uk-ua/bot-framework/dotnet/bot-builder-dotnet-formflow-advanced
states:
public enum ToppingOptions
{
// This starts at 1 because 0 is the "no value" value
[Terms("except", "but", "not", "no", "all", "everything")]
Everything = 1,
...
}
Note the comment:
// This starts at 1 because 0 is the "no value" value
@JasonSowers, you still helped me a lot!
@EricDahlvang, thank you!
Most helpful comment
This page https://docs.microsoft.com/uk-ua/bot-framework/dotnet/bot-builder-dotnet-formflow-advanced
states:
Note the comment:
// This starts at 1 because 0 is the "no value" value