结束对话
我的机器人(使用MS BotFramework)应该是听到对话stream。 如果有人提到“聊天机器人”应该说“我在这里!”,否则保持安静。 这似乎很简单,也许是,但我很难实施它。 这是我有什么:
bot.add('/', function(session) { if (someoneSaidChatbot) { session('Here I am!") } else { // session.reset(), maybe? No! // session.endDialog() then? Uh...nope. // nothing? Hmmm. negative } });
所以,没有任何工作。 如果我离开那里,机器人只是挂起,它停止听stream或回答命令。 有什么想法吗?
当有人键入“chatbot”作为话语的一部分时,此代码结束对话。 这是你想要的?
bot.add('/', function (session) { if (session.message.text.search("chatbot") >= 0) { session.endDialog("Here I am"); } });
我想build议使用endConversationAction()
来注册一个机器人全球行动
bot.endConversationAction( 'enddialog', //dialog Id 'Here I am', //message { matches: /^.*chatbot/i } //match pattern );
因为这是全球性的行为,任何时候当bot听到“Chatbot”时,它会说“我在这里”,如果堆栈中有对话框,你提出的解决scheme可能不起作用。
这也可能取决于您使用的是哪个频道。 某些渠道不能让Bot收听对话中的所有消息。