从Node.js BotBuilder中的conversationUpdate事件启动对话框

从Node.js BotBuilder中的conversationUpdate事件启动对话框,node.js,botframework,Node.js,Botframework,我想在聊天机器人初始化时显示消息并调用对话框。下面的代码显示了该消息。但是,不能调用对话框 bot.on('conversationUpdate', function (activity) { // when user joins conversation, send welcome message if (activity.membersAdded) { activity.membersAdded.forEach(function (identity) { if (id

我想在聊天机器人初始化时显示消息并调用对话框。下面的代码显示了该消息。但是,不能调用对话框

bot.on('conversationUpdate', function (activity) {
// when user joins conversation, send welcome message
if (activity.membersAdded) {
    activity.membersAdded.forEach(function (identity) {
        if (identity.id === activity.address.bot.id) {
            var reply = new builder.Message()
                .address(activity.address)
                .text("Hi, Welcome ");
            bot.send(reply);
            // bot.beginDialog("initialize", '/');
            // session.beginDialog("initialize");
        }
    });
}});bot.dialog('/', intents);
下面是对话框的代码。当聊天机器人开始时,我需要调用下面的对话框

bot.dialog('initialize', [
function (session, args, next) {
  builder.Prompts.choice(session, "Do you have account?", "Yes|No", { listStyle: builder.ListStyle.button });
}, function (session, args, next) {
    if (args.response.entity.toLowerCase() === 'yes') {
        //session.beginDialog("lousyspeed");
        session.send("No pressed");
    } else if (args.response.entity.toLowerCase() === 'no') {
        session.send("Yes pressed");
        session.endConversation();
    }
}]).endConversationAction("stop",
"",
{
    matches: /^cancel$|^goodbye$|^exit|^stop|^close/i
    // confirmPrompt: "This will cancel your order. Are you sure?"
});
我尝试了以下方法。但它不起作用

        1. bot.beginDialog("initialize", '/');
        2. session.beginDialog("initialize");

您遇到此错误是因为,尽管它们具有相同的方法名称,但方法签名在
session.beginDialog()
bot.beginDialog()
之间有所不同

这可能有点令人困惑,因为
session.beginDialog()
的第一个参数是
对话框ID
,但使用
bot.beginDialog()
时,第一个参数是
地址,第二个参数是
对话框ID

要解决此问题,请使用SDK参考文档中描述的正确输入参数调用
bot.beginDialog()
,例如
bot.beginDialog(activity.address,dialogId)

您还可以在此处看到完整的方法签名:


我用单行代码解决了我的问题

bot.beginDialog(activity.address, 'initialize');
你是如何定义“活动”的?当我使用你的代码时,它说活动没有定义。。。
bot.beginDialog(activity.address, 'initialize');