Technology

Automating project setup using Slack and NodeJS

Rob Waggott
Rob Waggott
13 Oct 2015
blog post featured image

Neil Osmond

One of the most tedious parts of a developer's or project manager's life is setting up a new project, you have to:

  • Create your git repository (we use bitbucket here at Technology Studio towers)
  • Create azurewebsites to deploy your dev and live sites to
  • Create a teamcity project, integrate git and add your builds
  • Create a Slack room (more about that below)

We love using Slack for our internal messaging (OK, OK, for sending memes to each other) so we wondered how we could integrate project setup with Slack. The advantage of this approach is that anybody could do it (it doesn't rely on a developer or someone with knowledge of the above services), all of our tooling and integration is in one place and it's self documented.

Slash Commands

We had a number of integration options when considering how to do this through Slack:

  • Webhooks
  • A custom plugin
  • Slash commands

We decided to use Slash commands as we can setup multiple commands under the same configured integration, we're all accustomed to using such commands for things like Hangouts and Giphy, and it's quick and easy to get an integration setup. A slash command has two elements:

  • The command - a command is made up of two parts - the command name and further text
  • A URL - a URL that is requested when somebody runs the slash command.

Our project setup slash command looks a bit like this:

/project-setup [ProjectName] [Services (azure,bitbucket,slack,teamcity)]

It takes in two commands:

  • ProjectName - The name of the new project, this is used for the Azure website names, the Bitbucket repo name, the Slack channel name and the Teamcity project.
  • Services - A comma delimited list of the services to setup:

Where the wild things live

They live in a Node script hosted on azure in case you're wondering.

The real magic happens in the URL that the above slash command is requesting. We decided to implement our script in Node because we love Javascript here at The Technology Studio and it's easy and quick to develop and deploy without the need for compilation. The following URL receives the following parameters from Slack:

  • token=gIkuvaNzQIHg97ATvDxqgjtO
  • team_id=T0001
  • team_domain=example
  • channel_id=C2147483705
  • channel_name=test
  • user_id=U2147483697
  • user_name=Steve
  • command=/weather
  • text=94070

We're just interested in the token so we can make sure the request is from Slack and the text so we can pull out the two arguments specified above.

The script takes the two arguments from the Slash command and uses different npm packages and webservices to do the wild things. Below are a list of the tools/webservices we used for each service:

  • We set up the azure websites using the azure-asm-website npm package.
  • Bitbucket have an awesome REST APIthat we consumed using the request npm package.
  • Slack have an equally nice API that we bearly scratched the service of
  • Teamcity have an API with a mind blogging amount of documentation

We'll be blogging in further detail about these tasks in the near future.

What's missing?

We would have loved to have setup our JIRA project and Confluence space but their API doesn't currently allow for this.

What else are we missing? Get in touch and let us know.

Can't wait to find out more? Then get in touch to join in with the funor get in touch if you want us to get your project setup .

Header image via imgflip.com/memegenerator.

Close chatbot
Open chatbot
Open chatbot