Add another keyword for Quit in FormFlows - Bot Framework

瘦欲@ 提交于 2019-11-29 23:32:54

问题


Is it possible to change the keyword for the Quit commando in FormDialog using Bot Framework?

I want to throw the FormCanceledException when a certain word is typed (Not using english as language).

If I could change the keyword, or add another that does the same as Quit it would be perfect


回答1:


Yes, it's possible. One way to do that, is to add a new term to the FormCommand.Quit command.

Here you will find an example that is doing exactly that (and code below for your reference)

private static IFormBuilder<T> CreateCustomForm<T>()
   where T : class
{
    var form = new FormBuilder<T>();
    var command = form.Configuration.Commands[FormCommand.Quit];
    var terms = command.Terms.ToList();
    terms.Add("cancel");
    command.Terms = terms.ToArray();

    var templateAttribute = form.Configuration.Template(TemplateUsage.NotUnderstood);
    var patterns = templateAttribute.Patterns;
    patterns[0] += " Type *cancel* to quit or *help* if you want more information.";
    templateAttribute.Patterns = patterns;

    return form;
}


来源:https://stackoverflow.com/questions/40749150/add-another-keyword-for-quit-in-formflows-bot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!