Azure 机器人框架:显示欢迎消息

Azure bot framework: Show welcome message

我正在尝试创建一个机器人,它会在我使用 NodeJS 刷新或启动机器人时给我一条欢迎消息(注意:最初不输入任何内容)。

我使用了以下代码

var bot = new builder.UniversalBot(connector, [
    function (session) {
        builder.Prompts.text(session, 'Hi! What is your name?');
    }
]);

但这对我没有帮助,它只在我输入内容时给我一条消息

看来您需要使用 conversationUpdate 回调。尝试以下源自 skype example

的片段
bot.on('conversationUpdate', function(message) {
    // Send a hello message when bot is added
    if (message.membersAdded) {
        message.membersAdded.forEach(function(identity) {
            if (identity.id === message.address.bot.id) {
                var reply = new builder.Message().address(message.address).text("Hi! What is your name?");
                bot.send(reply);
            }
        });
    }
});