This is the first out of three posts where I will explain how we hooked up Hubot to Github’s API. The goal of this is to get notified in Slack when your pull request becomes unmergeable.
A Springest Hackday idea
At Springest we hold regular hackdays. The purpose of these days is to learn, have fun together and work on something that is related to Springest, but isn’t part of our daily work-routine. It can be anything from hanging a swing in the office to building the company’s internal Facebook app called Sputr.
Starting the day, we all share our ideas during stand-up and we get to work. Either solo or in a team.
‘Get slack notifications when a pull request becomes unmergeable’ was one of the ideas on our hackday-list that I thought was interesting to work on.
In this post, I’ll explain how to run Hubot locally in Slack, so you can test-drive your code.
So what is Hubot, anyway?
Hubot is a chat bot by Github. It is open source and written in CoffeeScript and Node.js. You can automate processes with Hubot through scripts, or just add some flavor to your team’s culture. At Springest, our bot is called ‘Ingrid’. She notifies us about all sorts of things that happen on the Springest website and we can tell her to do stuff for us, like deploying, share support ticket info or give someone karma. All by messaging in Slack.
Slack is a messaging app for teams. Messaging is categorized in channels that everyone is free to follow or not. It enables us to easily communicate with each other.
To install Hubot, you need to follow these instructions:
Node.js and npm
Open your console and check if you have installed node.js and npm:
If nothing exists, install node.js by downloading it here. This will also install npm.
Make sure you have the latest version of npm installed, by running:
If you have never installed hubot before, you need to install its generator. Otherwise you can skip this step.
Let’s run it!
Now that you have the generator, add a directory for your bot and create it. I asked my six-year-old son what name he would give a robot, if he would have one. He said ‘Stone’ because robots are hard like stone. So I called it Stone for this example, no questions asked.
Create your bot (just hit ‘enter’ for all questions) :
Check if it is alive and kicking by running:
If all went well, you should now be able to chat with your bot in the console. Type ‘your-bot-name the rules’ and see if you get a reply.
Move from console to Slack
Create an account on Slack if you do not have one yet. I’ve created my own personal channel, to test this bot before implementing the code in Ingrid, our company bot. Once you have your own channel set up, go to
https:// yourslackchannel .slack.com/apps/A0F7XDU93-hubot and click on the green button, ‘Add Configuration’.
Add your bot’s username and hit ‘Add Hubot Configuration’.
Keep this page open, because you need to copy the environment variable in order to run your bot in Slack.
Now that you’ve configured your bot in Slack, and got your token, you have to install the Slack adapter and your bot is setup to run locally:
Open Slack on your computer and restart your bot with Slack’s environment variable, followed by a call to hubot’s scripts, plus the adapter flag:
Invite your bot to your #random Slack channel (
/invite @botname) and test it out by typing
@botname pug me
Congratulations! You are now ready to hook up Github’s pull request events. A new post about this will be published shortly.
Want to work at the biggest learning source in the world?