botkit: Not connecting to slack RTM

When I run the bot It gets stuck on this message:

token=my-real-slack-token node bot.js
** No persistent storage method specified! Data may be lost when process shuts down.
** Setting up custom handlers for processing Slack messages
** API CALL: https://slack.com/api/rtm.start
** BOT ID:  catbot  ...attempting to connect to RTM!

Here’s the code:

var Botkit = require('botkit')

if (!process.env.token) {
  console.log('Error: Specify token in environment')
  process.exit(1)
}

var controller = Botkit.slackbot({
 debug: false,
})

controller.spawn({
  token: process.env.token
}).startRTM(function(err) {
  if (err) {
    throw new Error(err)
  }
})

function rand(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}

var listeners = 'direct_message, direct_mention, mention'
controller.hears(['rand'], listeners, function(bot, message) {
    bot.reply(message, rand(1,100))
})

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@devaroop’s solution worked for me, just remove the .js when starting the bot (e.g. node slack_bot instead of node slack_bot.js)

@mayurthole I suppose you do not provide a database connection/method to persist data, e.g. for Mongo or Postgres. You should provide upon creation of an instance of your bot/slack controller, otherwise you will not be able to store teams or user when the register to your application/integration.

I also hit this problem, and was puzzled since I wasn’t using a proxy.

token=my_token node demo_bot.js produces the error for me on Mac, but token=my_token node demo_bot does not. Small silly error.