*UPDATE* I’ve added UserVoice to Trello Integration too, via an additional endpoint. Check it out on Github: github.com/scottefein/slack-to-trello
One of my favorite features of Trello has been the Slack Integration. Every change, addition card-it’s really way too much to digest via email. But having it show up in Slack keeps me on top of it, without it feeling intrusive. However I still had to log into Trello to add new cards to the icebox. This is kind of annoying because I’ll be on a call, we’ll come up with a great idea, and I take a note in my Google Doc that I should add this idea to the IceBox. Or we’ll be conversing over Slack, mention that we should do something, and then forget to add it to Trello. This is a nuisance!
So I decided today that I’d like to be able to do”/trello As a lovely person, I should be able to adopt a kitten” and have a new card added to Trello. I wasn’t so concerned with organization, assignments, or details-just getting it into the IceBox is a good first step.
Slack luckily makes third-party integrations pretty simple. You fill out a form with the slack command you want and what endpoint they should post to, and boom, integrated. Now, I’d prefer they post JSON, but it’s still pretty simple to work with.
The harder part was setting up the API endpoint for Trello Integration. I decided to use Go + Google App Engine because I wanted to host it for free and Go is good at things like this.
Step 1: Getting Your App Key
Head on over here: https://trello.com/app-key and grab that key.
Step 2: Authorize Yourself to Your App
You might be use to Twitter, who just gives you your own token from the user interface, so you can easily just start making request against your own user. Trello doesn’t do that, so you need to get your token for your own user. You’re going to need read/write access.
It’s going to give you a screen, grab your token off that screen and save it somewhere. This is the token you’re going to use to make all requests to Trello for the Slack Integration.
Step 3: Figuring Out Where to Put the Cards
Trello makes creating an integration for your own use rather difficult… We need a list to post these cards to, in this case “IceBox”, but to make a request to add a card to the IceBox list, we need the ID of that list. That’s where the hard part starts… You can’t get it off the interface, so you need to make a series of API calls to actually find the ID.
First you’ll need to get the ID of your Board
Find the board from the JSON (recommend using a JSON prettifier in Chrome) and grab the ID of the board.
Now to get all the Lists on that board… We can’t just tack more stuff onto the URL, we actually end up in a new Resource Scope.
From here, you can grab the ID of the list you want to make requests on. Save that for later.
Step 4: Create a Config File
You should never store tokens or app secrets in your git repository, so the seamingly preferred method of doing this on AppEngine (as opposed to environmental variables) is GCFG (code.google.com/p/gcfg).
Make a file called app.gcfg and put the following inside:
[trello] token = [token] key = [key] idList = [id-of-list]
And then inside your GoApp, we’ll access it like this:
Step 5: Your app.yaml
For any AppEngine app, you need a yaml file that describes the app. Looks something like this:
Step 6: The Code
This is pretty basic. All you’re doing is going in and posting to the Trello /1/cards endpoint with the text from /trello on slack.
And that’s it! You’ll need the Google App Engine SDK to do a goapp deploy. Your URL endpoint is now [project-name].appspot.com/send_to_trello
Step 7: Configure Slack
Head over to Slack, go to https://papercall.slack.com/services/new/slash-commands. Type in /trello or whatever command you want and click “Add Slash Command Integration”. All you need to do is paste the URL endpoint where it says URL, configure the autocomplete if you want, and click Save.
And you’re done! Happy Slacking with Trello Folks.