Microsoft Bot framework: Sending Message on connect

前端 未结 1 1237
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 10:44

I\'m new with Microsoft Bot framework. Right now I\'m testing my code on Emulator. I want to send Hello message as soon as your connect. Following is my code.



        
相关标签:
1条回答
  • 2020-11-30 11:24

    Hook into the conversationUpdate event and check when the bot is added. After that, you can just post a message or begin a new dialog (as in the code below I extracted from the ContosoFlowers Node.js sample, though there are many others doing the same).

    // Send welcome when conversation with bot is started, by initiating the root dialog
    bot.on('conversationUpdate', function (message) {
        if (message.membersAdded) {
            message.membersAdded.forEach(function (identity) {
                if (identity.id === message.address.bot.id) {
                    bot.beginDialog(message.address, '/');
                }
            });
        }
    });
    
    0 讨论(0)
提交回复
热议问题