我的chatbot(MS Botframework)如何忽略Slack频道中未提及的消息? BOT

我正在使用NodeJS的Micrososft Botframework – LUIS.ai开发一个聊天机器人,并使用对话框在Slack中进行整合。 现在机器人在DM窗口上工作正常,但是当被添加到一个闲置的通道时,即使没有提到,机器人也会回复所有的消息。

我知道机器人应该能够听到所有的消息,但是我怎么能把programmaticaly定义为只在提到的时候才在一个松弛的通道中进行交互呢?

有没有方法可以确定对话是来自频道还是来自直接的讯息?

这是对话框的代码片段样例

bot.dialog('intentName', [ function (session, args, next) { var intent = args.intent; session.dialogData.item = {}; var item= builder.EntityRecognizer.findEntity(intent.entities, 'myEntity'); session.dialogData.itemNumber = item.entity; // Prompt for title if (!session.dialogData.item) { builder.Prompts.text(session, 'What are you looking for?'); } else { next(); } }, function (session, results, next) { if (results.response) { session.dialogData.itemNumber = results.response; } //restify call //session.send(response) session.endDialog(); }); } ]).triggerAction({ matches: 'intentName' }); 

***********更新***********

我能够使用这段代码识别频道对话和DM之间的关系

 if(session.message.address.channelId=="slack"){ //Channel conversation if(session.message.address.conversation.isGroup){ if(session.message.text.includes("@botname")){ //your code } session.endDialog(); //bot not mentioned, hence do nothing } else{ //your bot reply to a DM } }