conversationUpdate()
一旦网页加载了我的聊天机器人,我就会让我的机器人自动向用户打招呼。然后它启动带有选项菜单的根对话框。请参阅下面的代码片段。
问题在于,一旦用户加入对话,/
对话框就会自动再次调用,并且用户会看到重复的菜单选项对话框。
用户加入对话后,如何停止根对话的启动?如果我不能,我该如何解决这个问题?
我的想法是强制将用户与机器人同时添加到对话中。不确定这是否有意义。
第一个机器人在这里,所以不知道如何做到这一点。
bot.on('conversationUpdate', function(activity) {
if (activity.membersAdded) {
const hello = new builder.Message()
.address(activity.address)
.text("Welcome....");
activity.membersAdded.forEach(function(identity) { // say hello only when bot joins and not when user joins
if (identity.id === activity.address.bot.id) {
bot.send(hello);
bot.beginDialog(activity.address, '*:/');
}
});
}
});