2. Did You Know?
Hubot is a robot
Its pronounced Hew-bot
Hubot is here to help you automate all the menial things
If you know Javascript/CoffeeScript syntax, you can write Hubot logic!
Hubot uses Redis as its “Brain” so you can persist data
Influence Health is using Hubot already!
3. How do I run Hubot
Hubot requires Node.JS. (It's what all the cool kids are doing)
$ brew install nodejs (Or download at https://nodejs.org/en/)
$ npm install -g yo generator-hubot
$ mkdir myhubot
$ cd myhubot
$ yo hubot
4. Hubot can Listen
robot.hear /badger/i, (res) ->
res.send "Badgers? BADGERS? WE DON'T NEED NO STINKIN BADGERS"
Hubot is listening, and then taking an action in response to that event
5. Hubot can Reply
robot.respond /open the pod bay doors/i, (res) ->
res.reply "I'm afraid I can't let you do that."
Hubot can reply to the author of a message. Hubot will only reply when @
mentioned
6. PR Assignment Example
Use case: When we open a PR we want all developers to share in the reviewing
of those pull requests.
1)Establish a pool of reviewers
2)Map Slack/Github usernames
3)Remember who went last, and assign to the next reviewer
Slack has a Github integration that will announce new PRs in a channel. Hubot
can be invited to this channel and listen for messages.
<Show example assign.coffee>
7. Testing Hubot
To run a Hubot REPL:
$ ./bin/hubot
Create a test Slack room (or join #hubot-test)
Invite Hubot from within the Slack channel (/invite @hubot)
Create a web hook at https://api.slack.com/incoming-webhooks
$ curl -X POST -H 'Content-type: application/json' --data '{"text":"foo"}'
https://hooks.slack.com/services/<hook>
9. Gotchas on Listening
Hubot can hear in two ways:
1)Other users (e.g. humans like you and me)
2)Other integrations (e.g. robots like the Github integration)
You must define which listening event you want to listen for:
robot.hear vs robot.listeners.push
10. Gotchas Continued
A message source might be different than the rendering:
This is formatted, and the source looks like this:
Pull request submitted: <hyperlink info…> by jeremydefibaugh
Pay attention when matching, and use console.log
11. Contributing
If you think of a useful Hubot feature, then please hack away. The hubot source
code for IH can be found at https://github.com/BrightWhistle/hubot
Or you have a feature request, or issue, report it on the repo, and someone else
can pick it up!