Botkit: How to deploy on Heroku?

Created on 29 Dec 2015  Â·  7Comments  Â·  Source: howdyai/botkit

First of all, thanks for this amazing tool! I find it really helpful.

I've deployed my bot on Heroku. However, every now and then logs show messages like this Stopping all processes with SIGTERM and my bot goes offline.

Is there any particular way to deploy this on Heroku?

Thank you!

Most helpful comment

Couple things.

  1. You have to have a Procfile in the root of your git repository targeting worker: node slack_bot.js or whatever the path / name is to your start file is (the default is slack_bot.js). Commit to your repository.
  2. Go to your Heroku dashboard and under settings click "revel config vars" and add in a new key:value with the key being "token" and the value being the slack key your were given by slack.
  3. Go to the resources tab, you should now see your "worker dyno". click the pencil, and slide it to the "on" state. You should see your bot wake up in slack, (if you navigate to a different tab, and then back to the resources tab you will see status "awake").
  4. if you are using the "uptime" example command from the example in botkit, you can type "uptime" and you should see something like :bot_face: I am a bot named whatever. I have been running for 2.2119333333333335 minutes on a bunch of letters and numbers. This means your bot is awake and running

All 7 comments

Hi, I'm having similar problems, when I run a simple botkit app on Heroku, I get after 60 seconds "Stopping all processes with SIGTERM" and the app shuts down. Now I know that a node.js server needs a port, and heroku spins them up dynamically, but do you know what I should change to do this?
My script is tiny:

"use strict";

const SLACK_BOT_TOKEN = process.env.SLACK_BOT_TOKEN;

let Botkit = require('botkit'),
    formatter = require('./modules/slack-formatter'),
    salesforce = require('./modules/salesforce'), 

    controller = Botkit.slackbot(),

    bot = controller.spawn({
        token: SLACK_BOT_TOKEN
    });

bot.startRTM(err => {
    if (err) {
        throw new Error('Could not connect to Slack');
    }
});

controller.hears(['help'], 'direct_message,direct_mention,mention', (bot, message) => {
    bot.reply(message, {
        text: `You can ask me things like:
    "Search account Acme" or "Search Acme in acccounts"
    "Search contact Lisa Smith" or "Search Lisa Smith in contacts"
    "Search opportunity Big Deal"
    "Create contact"
    "Create case"`
    });
});

Couple things.

  1. You have to have a Procfile in the root of your git repository targeting worker: node slack_bot.js or whatever the path / name is to your start file is (the default is slack_bot.js). Commit to your repository.
  2. Go to your Heroku dashboard and under settings click "revel config vars" and add in a new key:value with the key being "token" and the value being the slack key your were given by slack.
  3. Go to the resources tab, you should now see your "worker dyno". click the pencil, and slide it to the "on" state. You should see your bot wake up in slack, (if you navigate to a different tab, and then back to the resources tab you will see status "awake").
  4. if you are using the "uptime" example command from the example in botkit, you can type "uptime" and you should see something like :bot_face: I am a bot named whatever. I have been running for 2.2119333333333335 minutes on a bunch of letters and numbers. This means your bot is awake and running

Thanks! It worked really well, though the reddis bit needed some tweaking.
There was a good blog on it with sample code. It's up and running nicely!

On 12 May 2016 at 20:48, Corey Snyder [email protected] wrote:

Couple things.

1.

You have to have a Procfile in the root of your git repository
targeting worker: node slack_bot.js or whatever the path / name is to
your start file is (the default is slack_bot.js). Commit to your repository.
2.

Go to your Heroku dashboard and under settings click "revel config
vars" and add in a new key:value with the key being "token" and the value
being the slack key your were given by slack.
3.

Go to the resources tab, you should now see your "worker dyno". click
the pencil, and slide it to the "on" state. You should see your bot wake up
in slack, (if you navigate to a different tab, and then back to the
resources tab you will see status "awake").
4.

if you are using the "uptime" example command from the example in
botkit, you can type "uptime" and you should see something like :bot_face:
I am a bot named whatever. I have been running for 2.2119333333333335
minutes on a bunch of letters and numbers. This means your bot is
awake and running

—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/howdyai/botkit/issues/53#issuecomment-218850324

Great! A tip, I turn off the bot in Heroku by sliding the worker dyno to "off" if you need the bot to go offline to work locally via the terminal or whatever. Also, Heroku will "restart" if you push to production some new code. Finally, the bot will have to "sleep" if you are using the free Heroku account for a few hours in each 24 hour cycle. So upgrade to the hobby account if you need your bot "awake" 24-7.

see https://github.com/Daij-Djan/chatbot_templates for a checklist to deploy to heroku ;)

This works! I forgot to add a Procfile which Heroku needs to start up the dyno (free plan) after periods of inactivity. There is just one line of code worker: node bot.js in that Procfile, but it makes all the difference.

I got the error Stopping all processes with SIGTERM how to fix??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iworkforthem picture iworkforthem  Â·  3Comments

abinashmohanty picture abinashmohanty  Â·  4Comments

znat picture znat  Â·  4Comments

matueranet picture matueranet  Â·  4Comments

benbrown picture benbrown  Â·  3Comments