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

标签 c# bots botframework chatbot

是否可以使用 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;
}

关于c# - 在 FormFlows - Bot Framework 中为 Quit 添加另一个关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40749150/

相关文章:

c# - 如何在 Linux 上为 Windows 交叉编译 C# 项目?

python - FFmpegPCMaudio 在我的服务器上不起作用,但它在我的计算机上工作

c# - Microsoft Bot Framework DirectLine 无法访问对话

indexing - 为什么 Yahoo Indexing Bot 被视为 "evil"?

c# - 如何在表单对话框中接收附件?

c# - Skype 机器人参与者

c# - 如何从本地 SharePoint 2013 和 ADFS 获取 FedAuth Cookie

c# - "Parameter passing to function"还是 "Assigning values to Properties and then using them in function"是更好的选择?

c# - 在 C# 中加密和解密字符串?

ruby - 使用 Mechanize 按标签选择表单字段?