There are multiple ways to run Puppeteer apps in production. You can run it on your own set of servers or in a serverless environment like Google Cloud Function or AWS Lambda. Another option is Heroku. Let’s walk through how I setup a Puppeteer-powered Slackbot to run on Heroku’s cloud.

Disclaimer: This may or may not work. I’m not totally certain that the Slack RTM API is still usable (ie. not deprecated).

Your Room Awaits

Hatjitbot is a Slackbot that gets new Hatjitsu rooms for you. Getting into the weeds a bit, Hatjitsu is a website that allows scrum teams to setup a shared space where they can do story sizing, as part of the Agile development process. It’s a light manual process that only requires one-click to setup. You then need to share the link with your team so everyone can join.

I wanted to automate this. I figured I could write a quick Slackbot that listened for requests and used Puppeteer to create a new Hatjitsu room for you. It would then share a link with a Slack channel or group.

Hatjitbot in action

I needed some place to deploy this bot to, that wasn’t my MacBook. This is where I became interested in Heroku.

Getting Setup

First, setup a Heroku account if you don’t already have one setup. Then download and setup the Heroku CLI. I use MacOS, so I used Homebrew to install the tools.

brew tap heroku/brew && brew install heroku

Connect the tools to your Heroku account

heroku login

Next, get the code.

git clone git@github.com:evanhalley/hatjitbot.git

Once you have the code, go ahead and install the dependencies.

cd hatjitbot
npm install

Slack Setup

Now we need a Slack bot token. Head over to Slack API website to setup a new bot and get a Slackbot token. This part may be particularly difficult because I believe Slack deprecated the Slack bot API over RTM in the past month or two. Once you have a Slack bot token, create file called .env and its contents should be:

BOT_TOKEN=xo-your-bot-token-123

Deploying to Heroku

We’ll need to add two buildpacks to our Heroku installation. A Heroku buildpack is responsible for prepping your code to run on Heroku. It installs additional dependencies in the Heroku environment as well as configure the app to run in Heroku. The two build packs we need are to tell Heroku we have a Nodejs app and that our app contains Puppeteer.

Run the following comands:

heroku buildpacks:add heroku/nodejs
heroku buildpacks:add jontewks/puppeteer

Finally, push your changes to Heroku with:

git push heroku master

This will push the code to Heroku and trigger a build that may last a few minutes. While the build is happening, head over to the Heroku Dashboard for your newly create Hatjitbot project and add a config variable BOT_TOKEN.

configuring variables in Heroku

Once your build is complete and your bot installed to your Slack workspace, you should be able to DM or mention the bot in a channel to request a room. Be sure to include one of the hot words to trigger the process.

size, groom, grooming
🧇