Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

How to deploy on Heroku? #53

Closed
mdesanti opened this issue Dec 29, 2015 · 7 comments
Closed

How to deploy on Heroku? #53

mdesanti opened this issue Dec 29, 2015 · 7 comments

Comments

@mdesanti
Copy link

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!

@c4tch
Copy link

c4tch commented Apr 20, 2016

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"`
    });
});

@coreysyms
Copy link

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

@c4tch
Copy link

c4tch commented May 18, 2016

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 notifications@github.com wrote:

Couple things.

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
#53 (comment)

@coreysyms
Copy link

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.

@Daij-Djan
Copy link

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

@cssidy
Copy link

cssidy commented May 25, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@Daij-Djan @mdesanti @c4tch @coreysyms @cssidy and others