So you want to get started using Hubot and Slack? We’ve got you covered. Slack Developer Kit for Hubot is an adapter that connects your Hubot scripts to your Slack team, giving you and your fellow teammates a new best friend: your very own scriptable, pluggable bot.
What is Hubot and when should I use it? In short, it makes developing ChatOps-style bots quicker and easier. It’s an application you host on a server that uses the Slack platform and behaves however you script it to.
To get started, you’ll need Node.js installed.
You will first want to create a new Hubot project. The simplest way is to use your computer’s terminal app to install
Yeoman, a handy tool that builds projects from a template. We’ll also install the the template for
npm install -g yo generator-hubot
Now we can create that Hubot project:
mkdir my-awesome-hubot && cd my-awesome-hubot yo hubot --adapter=slack
Yeoman will ask you a few easy questions about your project and fill your directory with a Hubot app, ready to run.
Next, you’ll need a token from Slack to authenticate your Hubot. Use one of the following choices:
Create a Slack App with a Bot User (recommended): Slack apps are a container for many capabilities in the Slack platform, and let you access those capabilities in a single place. This is the recommended choice because it allows room for your Hubot to grow. To begin, you just need a Bot User.
Don’t use this choice if your Hubot needs access to any of the permissions that are only available to Custom Bots in the Bot methods documentation. If you don’t know whether you’ll need those, its easy to start with a Slack app and move to a Custom Bot when you need to by simply swapping a token, no sweat 😅.
Create a configuration of the Hubot Integration: The Hubot Integration is an older way to use the Slack platform. It’s main advantage is you get more permissions out of the box. For some more-security-sensitive people, this might be a disadvantage. From the above link click Install, choose a username, and finish by clicking Add Hubot Integration. On the next page, you’ll see an API Token. Copy that value, it will be your Slack token.
Run the command below, pasting your own Slack token after the
HUBOT_SLACK_TOKEN=xoxb-YOUR-TOKEN-HERE ./bin/hubot --adapter slack
Before you can interact with your Hubot, you invite it into a channel (shortcut:
Windows users: The above command sets an environment variable correctly for Linux and macOS, but Windows is a little different.
Hubot has many pre-written scripts that you can easy add by naming them in
external-scripts.json. Take a look at all
the possibilites with the hubot-scripts keyword in npm.
Feeling inspired? You can jump into writing your own scripts by modifying
scripts/example.coffee. It had tons of
helpful comments to guide you. You might also find the Hubot scripting docs
If you get stuck, we’re here to help. The following are the best ways to get assistance working through your issue: