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
- Merge pull request #17 from Naktibalda/patch-3 Use websockets by default — committed to send-help-pl0x/botkit by deleted user 7 years ago
@devaroop’s solution worked for me, just remove the
.jswhen starting the bot (e.g.node slack_botinstead ofnode 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.jsproduces the error for me on Mac, buttoken=my_token node demo_botdoes not. Small silly error.