Change Confirm options in botframework Formflow

2019-06-25 23:48发布

I have created a formflow in botframework. I want to change the confirmation options, by default it takes 'Yes' and 'No'. but i want it to proceed instead 'Yes', even if user inputs 'OK', 'Ya', 'Yeah' etc. how i can add options for confirmation

1条回答
Anthone
2楼-- · 2019-06-26 00:17

You need to add the new terms to the Yes array of the FormBuilder configuration. Something like:

public static IFormBuilder<T> CreateCustomForm<T>()
    where T : class
{
    var form = new FormBuilder<T>();
    var yesTerms = form.Configuration.Yes.ToList();
    yesTerms.Add("Ya");
    form.Configuration.Yes = yesTerms.ToArray();

    return form;
}

That then you can use like:

 return CreateCustomForm<MyForm>()

The reason of this would be something like the following:

The Confirmation field, set it's type to bool. At some point, a recognizer is defined for the field, based on it's type. In this, case, the Confirmation field will use the RecognizeBool recognizer.

The recognizer uses the Yes/No arrays defined in the form's configuration (which initially they are retrieved from the resource file) for doing the parsing.

When the Confirmation field is added to the Form, a ConfirmStep step is also added. The ConfirmStep is the one that later in the game ends up calling the recognizer to do the matching and parsing of the terms.

查看更多
登录 后发表回答