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 Classic 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.
⚠️ Although the admin page encourages you to upgrade your app’s OAuth scope, please do not do so. The latest permission model does not support the RTM API, which is the underlying API of the Hubot adapter.
Create a configuration of the Hubot Integration: The Hubot Integration is an older way to use the Slack platform. Its main advantage is that you get more permissions out of the box. For those concerned with security, this may be undesirable and should be taken into consideration.
From the link above, click Install, choose a username, and finish by clicking Add Hubot Integration. On the following page, you’ll see an API Token. Copy that value, as 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: