Creating a Slack command with hook.io

Brian Douglas
News on the Bloc
Published in
3 min readSep 11, 2015

I am always looking for ways to do new things with code. Today I work at a startup called Bloc. Being a startup we work in an agile environment, which means there are always a few bugs in the system.

We use a tool called Phabricator to track bugs. It’s very nice

Yesterday during a routine bug announcement in slack, an idea was provided, “i wish there was a /phab command in slack.” The idea was to have this command to easily generate bug task for engineers to eventually squash.

Currently the process takes 4 for extremely long steps:

  1. Open Browser Tab
  2. Log into Phabricator
  3. Click add task button
  4. Fill in info

I wanted to see if there was a way for me cut out some of those steps.

The beauty of slack is it is very customizable and gives it’s users the ability to add Slack Commands. Knowing this I started researching how to do this.

I knew I could use Hubot or Lita to accomplish this but it almost seemed like overkill to have a separate server/bot to do essentially what a webhook could do.

The hook

So I began researching web hooks in Go. I have been learning Go for awhile and have yet to have opportunity to implement it at work or in a side project yet. I found this webhook library, but it was taking me too long to stumble through the syntax and relearn how to work Go, so I bailed on this.

I then though the fastest way would be to use Ruby to create a webhook server locally from scratch, but while starting that I had another thought to check if there were any services out there to create this simple task.

I finally stumbled upon hook.io from this changelog article. It seemed legit so I started wiring it up.

First I had to create the slack command, which only required me to fill out the form at the https://slack.com/services/new/slash-commands.

I then had to created the hook using the basic template for a helloWorld hook; I just replaced some of the code to return a clickable link in slack, that will open the phabricator ticket creator.

I just needed to edit some node code, click “deploy service” and a link is provided for me to add to my slack command’s GET url.

Now that it is all wired up, I just have to type my new slack command with a title for my bug ticket and boom, I have the slack integration faster than a Kanye acceptance speech at the VMA’s.

I still would like to play around with creating my own webhook that will open the page for the user, but for now my current implementation takes the previous 4 steps and makes them 2.

  1. slack /phab [title]
  2. Fill in info

If you have experience in making custom slack commands with a different implementation, please drop me a line here or on twitter. I would love to make this implementation better, maybe next time with Go.

--

--

Brian Douglas
News on the Bloc

All day I dream about GitHub and live in Oakland, CA