Node.js 我的聊天机器人(MS Botframework)如何忽略在空闲通道中未提及的消息?机器人程序
我正在为NodeJS-LUIS.ai开发一个使用MicrosoftSFT bot框架的聊天机器人,并使用对话框将其集成到Slack中。现在,bot可以在DM窗口上正常工作,但是当添加到空闲通道时,bot会回复所有消息,即使没有提到 我知道机器人应该能够监听所有消息,但我如何定义programmaticaly,使其仅在提到时在空闲通道中进行交互 有没有办法确定对话是来自频道还是直接消息 这是对话框的代码示例Node.js 我的聊天机器人(MS Botframework)如何忽略在空闲通道中未提及的消息?机器人程序,node.js,botframework,slack,azure-language-understanding,Node.js,Botframework,Slack,Azure Language Understanding,我正在为NodeJS-LUIS.ai开发一个使用MicrosoftSFT bot框架的聊天机器人,并使用对话框将其集成到Slack中。现在,bot可以在DM窗口上正常工作,但是当添加到空闲通道时,bot会回复所有消息,即使没有提到 我知道机器人应该能够监听所有消息,但我如何定义programmaticaly,使其仅在提到时在空闲通道中进行交互 有没有办法确定对话是来自频道还是直接消息 这是对话框的代码示例 bot.dialog('intentName', [
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
}
}
我标记为重复的消息的可能重复项基本上是相反的,但您将获得查找位置。@EzequielJadib但是您如何识别消息是来自DM还是来自通道,当然在DM中没有提及,因此session.message.entities是empty@JorgeGarcia如果(session.message.address.channelId!=“slack”| | session.message.text.includes('@botid')){@Jorgeggarcia您可以尝试检查session.message.address.conversation.isgroups我标记为重复的一个可能的重复项基本上是相反的,但您会找到查找的位置。@EzequielJadib但是您如何识别消息是来自DM还是来自频道,当然在DM中没有提到session.m实体是empty@JorgeGarcia如果(session.message.address.channelId!=“slack”| | session.message.text.includes(“@botid”){}@jorgeggarcia,您可以尝试检查session.message.address.conversation.isGroup