We've been using Slack to communicate with each other for the first few weeks of the class. Now it is time to build our very own Slackbot to add a fun, interactive component to the chat room. A Slackbot is an integration into Slack that can either respond to specific phrases that are mentioned in Slack or they can post things from outside of slack into a channel or private conversation. There are now entire startups built on top of Slackbots. For example, people have built Slackbots that let you hail an Uber from them or schedule meetings with different members of your team (where it searches your Google Calendar). One of the most popular Slackbot's lets people post random gifs based on phrases into a channel from Giphy.
Hubot is a robot that was created by GitHub, that enhances their company chat. Hubot can deploy their site, act as a source of fun comments, and also automate their daily tasks. It is powerful and can be extended in a way that developers can build whatever they want on top of it.
Hubot scripts are generally written in CoffeeScript, a language that compiles into JavaScript. Thankfully, these scripts can also be written in vanilla JavaScript. Your bot can respond to whatever you like, but it must perform at least three different actions.
The respond
command will respond to specific text it sees in the Slack channel.
You can then use the send
command to post a message to the channel.
send
lets you send a message to the Slack channel. We usually use this
hand-in-hand with respond
. For example, when someone says something (i.e. 'Hi')
on the channel, we respond by sending "Howdy". Of course, it will only send or respond based
on the commands and words you teach it (by adding it to your code).
reply
lets you reply to a certain user or to the person who sent the original
message. This includes the @
in front of the user's name so they get alerted.
Hubot also has a random
command which will return a random result based on what
you give it. Check out the starter code for some examples.
Bonus:
README.md
file with explanations of what your bot does, what commands it responds to,
the approach taken, installation instructions, unsolved problems, etc.Key Resources
Examples
Additional Reading