If this is a FormDialog, you can add validation steps to each element in the form. In your case, you're probably using a bool "WantsToCreateAccount" or something to the likes of it?
In your FormBuilder code, you'd typically do as I've done here, on a simpler form:
public static IForm<UserData> BuildForm()
{
return new FormBuilder<UserData>()
.Message("Before we start, let me ask you a couple of questions")
.AddRemainingFields()
.Field(new FieldReflector<UserData>(nameof(IsCustomer))
.SetValidate(async (state, value) => await ValidateIsCustomerFieldAsync(state, value)))
.Field(new FieldReflector<UserData>(nameof(HasCustomerId))
.SetValidate(async (state, value) => await ValidateHasCustomerIdFieldAsync(state, value)))
.Build();
}
The SetValidate is the key here, where you can apply whatever logic you'd like after validation of that field, i.e.
private static Task<ValidateResult> ValidateHasCustomerIdFieldAsync(UserData state, object value)
{
if( (SvarAlternativ) value == SvarAlternativ.Nej)
{
state.CustomerId = "Kund, har inte Id";
}
return Task.FromResult(new ValidateResult { IsValid = true, Value = value });
}
Note that a BOOLEAN value is tricky to do validation with because it's a value type that cannot be null, so the validator won't see if it has a "NoValue" or "false" state. Because of this, I just created an enum, where the zero value is the "NoValue" state set by the bot framework:
public enum SvarAlternativ
{
NoValue,
Ja,
Nej
}
Hope this helps you. Once inside the validation method, you can context.close or do whatever you need.