node.js - 使用 LUIS.ai 的 botframework 中的对话框

标签 node.js botframework azure-language-understanding

我有一段代码可以在本地机器人上完美运行,但与 LUIS 集成时却很奇怪。这是一个重定向到另一个对话框的简单对话:

    // Modelo de datos cargado en luis.ai
    var recognizer = new builder.LuisRecognizer(process.env.LUIS_MODEL_URL);
    bot.recognizer(recognizer);

    //first intent, greeting intent to say hi to the user
    bot.dialog('greetings', [
        function (session) {
            var greetings = ["¡Hola!", "Bonjour amigo!", "zdravstvuyte! (Así se dice hola en ruso)"];
            var pickAGreeting = function () {
                var rnd_greeting = greetings[Math.floor(Math.random() * 4)];
                return rnd_greeting;
                };
            session.send(pickAGreeting(), session.message.text);
            builder.Prompts.text(session, 'What can I do for you about Office?');
        },
        function (session, results) {
            var user_response = results.response;
            session.beginDialog('getProductoOffice', user_response);
        }
    ]).triggerAction({
        matches: 'greetings',
        onInterrupted: function (session) {
            session.send('Can I help you with something?');
        }
    });

    bot.dialog('getProductoOffice', [
        function (session, args) {
            session.send('Welcome to O365 help!', session.message.text);
    ...

And the bot does this:
[me]: Hola
[bot]: ¡Hola!
[bot]: What can I do for you about Office?
[me]: Tell me about Skype
[bot]: Can I help you with something?

奇怪的是,提示我有关 Office 后,它从未进入“功能( session 、结果)”,而是直接进入被中断的对话代码。

这段代码无需集成 LUIS 即可完美运行,并且可以在对话之间正确移动。

最佳答案

每次我输入 LUIS 识别的话语时,由于 triggerAction 行为,对话框都会中断。

要在任务运行时禁用识别器,我必须在识别器中使用方法 onEnabled ,如下所示:

var recognizer = new builder.LuisRecognizer('<model>').onEnabled(function (context, callback) {
     var enabled = context.dialogStack().length == 0;
     callback(null, enabled);
});

这不会中断对话框堆栈,并且识别器仅在没有对话运行时才会工作。

关于node.js - 使用 LUIS.ai 的 botframework 中的对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46362255/

相关文章:

node.js - 用户在 DocPad 中提供的内容

node.js - Node Promise拒绝不进入catch

node.js - 如何在 Azure Bot 服务上同时使用英语和法语 QnaMaker?

botframework - 无法在 Teams 的自适应卡中显示超过 6 个自适应操作

azure - LUIS 可以在多个模型之间共享实体定义吗?

node.js - npm 完全死亡,ERR_TLS_CERT_ALTNAME_INVALID,主机名/IP 与证书的替代名称不匹配 : Host: registry. npmjs.org

node.js - Nodejs - "Sending https request to the same domain multiple times"每次都无法获得 SSL 证书

node.js - 如何在 app.js 中使用 LUIS 来识别不同文件夹中的对话框

Node.js:如何使用 MS Bot Framework 在 Slack 中发送直接消息?

c# - 路由 Microsoft LUIS 请求和机器人框架 - 最好在企业引用应用程序中