Node.js Slackbot api可以';我不能接收消息
我正在用NodeJS建立一个SlackBot 我当前正在使用此库,但问题是初始化后,bot不会出现在“应用程序”类别中,但它位于SlackBot中,每次我键入消息时,它都会返回一条错误消息:Node.js Slackbot api可以';我不能接收消息,node.js,bots,slack-api,Node.js,Bots,Slack Api,我正在用NodeJS建立一个SlackBot 我当前正在使用此库,但问题是初始化后,bot不会出现在“应用程序”类别中,但它位于SlackBot中,每次我键入消息时,它都会返回一条错误消息: I'm sorry, I don't understand! Sometimes I have an easier time with a few simple keywords. Or you can head to our wonderful Help Center for more assistanc
I'm sorry, I don't understand! Sometimes I have an easier time with a few simple keywords. Or you can head to our wonderful Help Center for more assistance!
另一方面,当我向用户发送消息时,我可以看到我设置的bot:
如何使机器人Hugo与SlackBot内部Slack分开
我就是这样设置的:
var SlackBot = require('slackbots');
var bot = new SlackBot({
token: process.env.SLACK_TOKEN,
name: 'Hugo'
});
function get() {
return bot;
}
exports.get = function() {
return bot;
}
exports.send_message = function(user_ref, message) {
bot.postMessage(user_ref, message).then((data) => {
return data;
});
}
exports.get_users = function() {
var user_list = get().getUsers();
return user_list;
}
这就是我发送测试消息的方式:
var bot = require('./modules/bot.js');
bot.get().on('message', function(data) {
console.log("#######################################"); // -> debug only
console.log(data);
console.log("#######################################");
bot.send_message('USER_ID', 'test response');
});