在 FormFlows - Bot Framework 中为 Quit 添加另一个关键字

Add another keyword for Quit in FormFlows - Bot Framework

是否可以使用 Bot Framework 更改 FormDialog 中 Quit commando 的关键字?

我想在输入某个单词时抛出 FormCanceledException(不使用英语作为语言)。

如果我可以更改关键字,或者添加另一个与 Quit 功能相同的关键字,那就完美了

是的,这是可能的。一种方法是在 FormCommand.Quit 命令中添加一个新术语。

Here 你会发现一个例子就是这样做的(下面的代码供你参考)

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;
}