Automating tasks for your team using Hubot
At OnCare we’ve been using Hubot, a chatbot made by the folks at Github as a companion to help our team get the answers they need. I wanted to share our experience as it differs slightly from it’s roots of Hubot being a developer focused bot.
Bit of a back story first; our sales team was looking for information about customers in order to do their job. We didn’t have admin pages to let them self-serve so all enquiries were being manually handled by me. Before I built out another admin page, I thought it’d actually be more convenient for the team to get this information through the medium they were already using; Slack.
What if anyone in our team could simply ask “hubot user firstname.lastname@example.org?” (whilst adhering to GDPR).
Downloading, configuring, deploying and integrating into Slack was a doddle when following their instructions. I deployed to Heroku for convenience but it has the fortunate side-effect of working well within their free tier as it’s almost exclusively required inside office hours.
I’m not much a fan of CoffeeScript so when I embarked on writing our first custom script, I was pleased to see I could write in JS.
Hubot could theoretically speak directly to our database but it’s a good idea to have a separation of concerns and instead let it authenticate and query your backend API instead.
Our backend service is written in Django so I added a Django REST Framework endpoint that’d provide information about a user by email (
With this in place I have a Hubot script that looks like this:
Now what we can do is ask:
me: hubot help
hubot: hubot user email@example.com — Get information about an OnCare user
me: hubot user firstname.lastname@example.org
hubot: Finding user, 1 sec
hubot: That user belongs to Foo Agency. They are a “care worker”
That was fairly easy.
I “announced” the feature to the team by just putting this dialogue in the Slack general channel and noticed people asking similar questions without training. The power of simplicity.
Everyone likes a bit of customisation so our “hubot” quickly became “onbot” and a custom avatar was introduced.
Once we had our first skill setup, I thought it’d be great to get a synopsis of our company stats so I created a JSON endpoint that exposed existing high level KPIs that were previously being shown on an admin dashboard. We can now fetch this with
It was all well and good being able to more easily find our stats but I thought onbot should be a bit more proactive. I setup a script that would send a stats update every morning to #general. As Hubot is just running a Node server I created a dead simple script that triggered on a cron interval like so:
There are some links and information we refer to frequently. With a simple shortcuts script we can ask thinks like:
onbot handbook— link to company culture handbook
onbot phone— not an action, reminds us of our phone number
There is a package called factoids but I found the commands a bit verbose and didn’t want to worry about the persistence of the data (yet). My shortcuts script is stupidly simple and it only takes a minute to deploy if we make an amend;
As helpful as our subservient bot is, it isn’t very chatty and I want to rectify that. I started writing my own REPL for Hubot but shortly after discovered the Hubot Conversation library.
I’ll be using this to enable conversations like:
me: hubot agency WrongName
hubot: Sorry, I couldn’t find “WrongName”. I did find:
Which one are you interested in?
me: Correct Name
hubot: Ok here you are:
I’d like to play around with Slack’s message attachments so we can better present information, especially our stats.
It’s been a great talking point for our team who have daily stats in the morning and great to see people using (and abusing) Hubot to help get answers they need with minimal friction.
I’d love to hear how other teams are using Hubot to improve their team’s productivity so please leave a response :)
OnCare is continuing to build customer centric software for care agencies and we are looking for another engineer to join our growing team to support this effort. If you’re a London based full-stack engineer, fancy working on tech for good and desire a large degree of control of the work you do, get in touch (james at weareoncare.com).