Skip to content

James Carr - Rants and Musings of an Agile Developer
Syndicate content
Rants and Musings of an Agile Developer
Updated: 2 hours 7 min ago

Open a Github Issue From Slack!

Thu, 08/21/2014 - 19:20

The other day one of my co-workers opined that it’d be fantastic if we could open a GitHub issue from Slack. Fifteen minutes later the channel got to bask in the awesomeness… of this!

Read on to discover how to use Zapier (shameless plug: yes, I work on this) to whip this up quickly as well!

Opening the Issue

First up, we need to log in to Zapier and set up our first of two Zaps, the one that will create a new issue from Slack.

Now we’ll select our two services and the desired actions:

Next up, connect Slack and GitHub to Zapier.

When we get to step four, we’ll want to setup a custom filter so that we only trigger on Slack messages that contain !gh_issue.

At step five we’ll want to plug the values in to the GitHub issue from Slack. If you scroll back you’ll remember we used a specific format for our issue:

!gh_issue title(Junk Issue) description(Junk Issue!) repo(zapier/zapier-infra)

In Zapier-land, we extract those elements with parenthesis as variables. So when pulling from the trigger we get the raw text and the extracted variables as names like {{text__title}}, {{text__description}}, etc.

At step six we’ll load some samples.

Hrmph. All filtered out. Ah! We haven’t actually tried to create an issue from Slack. Let’s go do that now!

Now we go back to step six and refresh and we should see a new unfiltered sample, of which we can click “See filter sample” to view what will go to GitHub.

Looks good! Let’s go ahead and click “Test” and check that the GitHub issue was created on GitHub.

Great! Let’s go ahead and name this Zap!

But that’s only half the story. It’d also be nice if there was some notification in the channel that it had been created. Not 100% needed, but it would be nice!

The Webhook

So we have multiple ways we could approach this here:

  • Create a Zap that polls GitHub issues and alerts the channel of new issues
  • Setup a webhook through Zapier to push new issues instantly to Slack
  • Use the native Slack/GitHub integration on Slack to send the new issue notification

I’ll admit I didn’t have much luck using the native integration despite wanting it to work as it would have required the least amount of setup. Polling was easy to setup, but it means I can have anywhere from a 1 minute to a 15 minute delay from when I open the issue to when it is published back to Slack. So I opted for the webhook route.

The Webhook Trigger on Zapier is immensely powerful. You can use it to poll a URL, catch incoming webhooks, and even send webhooks back out to other services. It’s pretty raw but it gets the job done, and it gets it done instantly.

Like last time, for step one we will select our services: Webhook to Slack!

In step two, we’ll be given a webhook we can copy and paste to plug it into GitHub. Let’s navigate to GitHub really quick to add it.

In our repository settings page on GitHub, let’s add a new webhook.

By default this will fire on all events. We don’t want that, we want each issue.

This will be grayed out until an event fires, so let’s go back to Zapier and continue working on our Zap.

On step four, we’ll want add a custom filter so that the Zap will only trigger when issue action is equal to “open”. Otherwise this will fire whenever any activity takes place, such as opening and closing issues.

The first time through you may get a modal pop up prompting you to go create a new issue when you try to select a field. This is because webhooks are instant and require a user interaction to take place first. So go create an issue (manually or from Slack, it doesn’t matter) and follow the instructions to get it caught by Zapier. Now we can select the field we need and move on. :-)

At step five it’s time to set up the channel the message will be sent to and what the message will be. I typically prefer to alert the channel of a new issue opened on a repository and then link to it.

There is also a field for Icon URL that can be used to plug in a specific icon for the Slack bot that broadcasts the message. I usually use a character of ours (Zapbot!) that is similar to Hubot, but Octocat fits well here too!

Now we’ll test the Zap and if all goes well, name it and set it live!

Whelp that wraps it up for us… hope you find these Zaps as useful as we have!

Categories: Blogs