Slackbot api无法接收消息

时间:2017-10-17 09:05:38

标签: node.js bots slack-api

我正在使用NodeJS构建SlackBot。

我目前正在使用这个库slackbots,但问题是在初始化之后,僵尸程序没有出现在Apps类别中,但是它在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 assistance!

enter image description here

另一方面,当我向用户发送消息时,我可以看到我设置的机器人: enter image description here

如何让机器人Hugo与Slack内部的SlackBot分开?

我是如何设置的:

 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');
  });

0 个答案:

没有答案
相关问题