I'm have a bot running on heroku within a free tier, and I'm looking for a way to wake the application when a message is received from the user in Slack.
I have a web worker in my Procfile:
web: npm start
I also setup a webserver and botkit:
var app = express();
var port = process.env.PORT || 3000;
app.listen(port, function (err) {
if (err) throw err;
console.log('Bot up!');
});
var controller = Botkit.slackbot({
debug: false
});
var bot = controller.spawn({
token: botConfig.SLACK_BOT_KEY
}).startRTM();
The bot goes up as normal, and goes idle after 30~ minutes of inactivity
2016-09-27T18:55:18.013318+00:00 app[web.1]: info: ** API CALL: https://slack.com/api/rtm.start
2016-09-27T18:55:18.027341+00:00 app[web.1]: Bot up!
2016-09-27T18:55:18.253156+00:00 app[web.1]: notice: ** BOT ID: bot ...attempting to connect to RTM!
2016-09-27T18:55:18.298822+00:00 app[web.1]: notice: RTM websocket opened
2016-09-27T18:55:18.346493+00:00 heroku[web.1]: State changed from starting to up
2016-09-27T19:25:42.535535+00:00 heroku[web.1]: Idling
2016-09-27T19:25:42.536182+00:00 heroku[web.1]: State changed from up to down
2016-09-27T19:25:46.877746+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-09-27T19:25:48.014988+00:00 heroku[web.1]: Process exited with status 143
Now, if I send a message to the bot in slack, it won't respond anymore and the application won't wake up unless I send a request to the webserver.
I don't want to prevent the bot from idling as it would consume my dyno hours, is there a way I can wake up the app when a user sends a message to the bot through slack?