【问题标题】:Why I get TypeError: dialog.addDialogTrigger is not a function?为什么我得到 TypeError: dialog.addDialogTrigger is not a function?
【发布时间】:2018-02-21 12:13:06
【问题描述】:

我的机器人不再工作:如果我向“/”对话框或其他对话框(例如“/menu”)发送任何消息。 我总是收到同样的错误“TypeError: dialog.addDialogTrigger is not a function”

机器人信息:

  1. SDK 平台:Node.js
  2. SDK 版本:botbuilder 3.14.0

部署环境:

  1. Azure 机器人服务
  2. 使用模拟器进行本地开发

代码示例

bot.dialog('menu', require("./dialogs/menu"))
    .triggerAction({
        matches: /^#menuderungly$/i
    });

知道如何应对吗? 非常感谢您的帮助!

【问题讨论】:

  • bot.dialog的第二个参数应该是对话框还是IDialogWaterfallStep,你的dialogs/menu是什么?我在这里没有看到任何dialog.addDialogTrigger
  • ./dialogs/menu 的导出格式是什么?另外,您能否在UniversalBot 的实例化以及与您的bot 和对话框注册相关的其他代码上显示其他代码?
  • 为了调试,放一个console.log(bot.dialog('menu', require('./dialogs/menu'))),看看结果如何。那真的有triggerAction功能吗

标签: node.js botframework


【解决方案1】:

您似乎正在尝试调用另一个文件上的对话框。在这种情况下,您必须像任何其他 NodeJs 函数一样在该文件中声明对话框:

parentDialog.js

var childrenDialogs = require('./childrenDialogs'); 
...
...
// this is where the base dialog handles the conversation over to another dialog
bot.dialog('/', childrenDialogs.childDialog1); 

childrenDialogs.js:

exports.childDialog1 = (session) => {
    // something in this dialog
}

我希望这会有所帮助。干杯! :)

【讨论】:

    猜你喜欢
    • 2020-01-20
    • 2019-05-08
    • 1970-01-01
    • 2020-11-16
    • 2020-09-13
    • 2022-06-22
    • 1970-01-01
    • 2021-11-20
    • 1970-01-01
    相关资源
    最近更新 更多