意向匹配后,在对话框中读取用户的话语

时间:2018-07-06 10:39:08

标签: node.js botframework

嗨,我正在寻找可以在对话框中读取用户话语并找到执行业务逻辑的实体的代码。我正在使用RegEx识别器而不是LUIS。我能够通过用户输入来调用适当的意图。下面是代码

bot.recognizer(new builder.RegExpRecognizer( 'searchProductsIntent', /^search products in \w+$|^please get products of \w+$/i));
bot.dialog("searchProductsKk", function (session) {
    session.send("I am intent");
    session.endConversation("Ok, I'm intent.");

    //Logic:I want to read the user utterance here for eg., search products in **kodak**. I want to read the search term "kodak" from utterance to search kodak products. 

}).triggerAction({ matches: 'searchProductsIntent' });

我在任何地方都找不到相关的示例代码。

1 个答案:

答案 0 :(得分:1)

您可以通过IDialogWaterfallStep函数的第二个参数接收输入消息。请考虑以下代码段:

bot.dialog("searchProductsKk", function (session,args,next) {
   // args.intent.matched[0] is the user utterance.
   console.log(args.intent.matched[0])

}).triggerAction({
    matches: 'searchProductsIntent'
});