具有RegEx和意图的triggerAction
我正在使用bot框架来帮助系统中的基本任务。 其中一项任务是列出不同的数据组,例如组和用户。
处理这个对话框如下所示:
lib.dialog('/', function(session) { <code> }).triggerAction({matches: stuff});
代码部分可以处理抛出的每一种列表,所以我想让triggerAction捕获所有不同的列表。 它们在我自己的自定义识别器中得到识别,并且将总是GetTopicList的格式,其中“主题”是“用户”或“组”等,因此意图将是“GetUserList”或“GetGroupList”。
我似乎无法得到RegEx的工作,因为它会开始听取消息,而不是我的识别器(/^Get.*List$/解决问题,但它不会听识别器)。
一旦你在一个triggerAction中使用RegEx,触发器开始监听发送给机器人的消息而不是意图,这种行为不是我正在寻找的,而是让触发器仍然听取意图。 这可能吗?
作为MatchType的botbuilder nodejs源代码的描述 :
/** * Supported rules for matching a users utterance. * * _{RegExp}_ - A regular expression will be used to match the users utterance. * * _{string}_ - A named intent returned from a recognizer will be used to match the users utterance. * * _{(RegExp|string)[]}_ - An array of either regular expressions or named intents can be passed to match the users utterance in a number of possible ways. The rule generating the highest score (best match) will be used for scoring purposes. */
所以根据我的理解和代码testing的结果,意图只能通过sting而正则expression式匹配。
恐怕你需要使用string数组作为matches
属性:
triggerAction({ matches: ['GetTopicList','GetUserList',...], })