Deploying the Howdy.ai Botkit to Heroku

PUBLISHED ON JAN 31, 2016 — IMPORTED FROM TUMBLR, TEXT

It wasn’t difficult, but like they say, blog about what would have helped your previous self.

Presumbaly, you’re here because you have a rad bot you built using Botkit, and you’re looking for a bit of guidance on getting it out of your local environment and into the real world using Heroku.

bots-gif

If you’re not already familiar with Heroku, or just need a refresher, check out their tutorial on deploying Node.js apps.

Quick tip: from the command line, using Homebrew on OSX, run brew install heroku-toolbelt and then heroku login to get started.

After deploying my working-locally bot using the Heroku tutorial, I kept getting a port error, which DarrenN mentioned in an issue filed on Github. Following benbrown’s suggestions, I first tried running my bot as a background process [as specified in my Procfile], but that didn’t work, likely because I did something wrong. Trying out the second suggestion, I set up a web server using some of Botkit’s built-in functionality. Works as advertised!

The next time I deploy a bot using Botkit and Heroku [which will likely be sooner than later], this is the process I’ll use:

  • Set my token environmental variable on my Heroku app using Heroku’s toolbelt: heroku config:set token=all-sorts-of-alphanumeric-biz-from-slack

  • At the top of my snark-bot.js file, set up the web server:

  • Put together my minimal Procfile, as explained in the Heroku tutorial:

web: node snark-bot.js

  • In order to save myself some time, I’ll test Heroku locally using a .env file containing my sandbox-Slack token and the heroku local command [more info here]. That .env file will look something like this:

token=different-sorts-of-alphanumeric-biz-from-my-sandbox-slack

  • When everything is working as expected using heroku local, I’ll then git push heroku feature-branch:master and check the logs using heroku logs –tail while testing the newly-hosted-on-Heroku bot to confirm that everything still looks good.

  • My last step will be merging feature-branch into master, and redeploying to Heroku using git push heroku master.

Easy peasy, chicken breezy.