Published at 22.03.2016
If your team uses Slack or any other chat for communication, you probably heard about Hubot by now. If you haven’t, well, Hubot is an amazing bot developed by Github to be a butler that sits in your chat and listens to the commands.
Github is famous for their idea of ChatOps, where a lot of things happen through their company Campfire chat, so they wrote Hubot to suit their needs. Need something translated? Ask Hubot. Need an app deployed, but you really suck at command line?
Get your developers to configure
In this post, I will show you how to deploy your own hubot (with Slack adapter, as we use Slack for our team) to anynines.
Table of Contents
First thing you need to do is install and set up Hubot locally. Assuming you have Node.js environment already installed (if you don’t, Node.js has a bunch of tutorials on that – like: https://nodejs.org/en/download/package-manager/), all you need to do is run:
$ npm install -g yo generator-hubot
This will install Yeoman, the scaffolding tool, as well as Yeoman generator for setting up Hubots. If that went smoothly (on some io.js & new Node.js versions, you might run into warnings about
yo version, but as long as it’s not an error, you can safely ignore them), set up your new Hubot using
$ mkdir my-hubot $ cd my-hubot $ yo hubot
This will run a setup environment for Hubot. Make sure you are more creative while naming your bot than I was and you don’t name it
hubot or you’ll run into dependency issue with Node telling you you’re mad if you want to install Hubot as a Hubot dependency. Which kinda makes sense, I guess.
After the setup process succeeded, install your Slack adapter:
$ npm install hubot-slack —save
To check if your Hubot works correctly, run it locally:
Works? Great! Now it’s time to set up Slack!
To make Hubot run on Slack, you need to give it a token. To get your personal token, go to Slack apps page, search for Hubot and add a new Hubot to your Slack team. Inside the configuration pane, you should find something like this:
This is your Hubot Slack token that you need to set up in your anynines manifest to make sure your Hubot can talk to your Slack.
To deploy your Hubot to an anynines instance, you need to do a bunch of simple steps. First of all, make sure you’re in the right organization and space, by typing in:
$ cf target
Once you made sure, it’s time to create your
file. Here’s an example file that you can use:
As you can see, Hubot uses Redis for its “brain”, where it keeps all the important information. To set up your Redis on anynines, check out
cf marketplace for the list of available services. Once you did that, set up an instance using:
$ cf create-service redis redis-my_hubot
After you’re done, make sure to put your
HUBOT_SLACK_TOKEN in your manifest file and you should be good to go. Push your Hubot to anynines using
$ cf push
Voila! If everything worked, you should see Hubot connect to your Slack team when the deploy is done.
Have fun and happy hacking!
Products & Services
© anynines GmbH 2023