Coder Social home page Coder Social logo

node-trello-slack's Introduction

node-trello-slack

wercker status
Dependency Status

The built-in integration for Trello provided by Slack/SlackHQ isn't enough. It's limited to one board!

This tool will check the trello api once a minute for updates and push them into your desired channels. You can configure any number of boards.

Install

npm install --save node-trello-slack

Usage

Create an executable script with the following code:

#!/usr/bin/env node

var Bot = require('node-trello-slack')
	,bot = new Bot({
		pollFrequency: 1000*60*3 //every 3 minutes
		,start: true
		,trello: {
			boards: ['Nz5nyqZg','...']
			,key: 'trello-key-here'
			,token: 'trello-token-here'
			,events: ['createCard','commentCard','addAttachmentToCard','updateCard','updateCheckItemStateOnCard']
		}
		,slack: {
			domain: 'slack-domain-here'
			,token: 'slack-webhook-token-here'
			,channel: '#general'
		}
	});

You may completely omit trello.events, which indicates that you want all (recognized) events announced. All recognized events are listed in the example above. Alternately, include some subset of the list shown above. (Case sensitive)

Trello-board-specific channels

If you want to send alerts from each board to a different Slack channel, pass object hashes instead of string board id's in the trello.boards array, as you see here:

,trello: {
	boards: [
		{
			id: 'Nz5nyqZg'
			,channel: '#general'
		}
		,{
			id: '...'
			,channel: '#devops'
		}
	]
	,key: 'trello-key-here'
	,token: 'trello-token-here'
}

Getting your Trello and Slack credentials

You'll need a Trello key and token. Get your key here: it's the one in the box near the top labeled "key." Once you have that key, substitute it into the following url for and open it up in a browser tab:

https://trello.com/1/connect?name=node-trello-slack&response_type=token&expiration=never&key=<KEY-HERE>

You'll also need your webhook token and domain for Slack. The domain is just the part of the url before .slack.com. To get your token, go to the following url (substituting your domain for <YOUR-DOMAIN>) and add the webhook integration (if it's not already enabled). The token will be listed in the left sidebar.

https://<YOUR-DOMAIN>.slack.com/services/new/incoming-webhook

Fill all four of these values into your bot config, and tweak the other options

Running...

Once you've configured access to your Trello and Slack accounts, the last thing to know is how this tool knows what events it's already seen. There are two options: File system, and Redis.

...locally (or where the file system is writeable)

The simplest is using the file system. Just create a file named last.id in the root folder of the project and put the number 0 into it. As long as the filesystem is writeable the file will be updated when new board actions have been seen.

...on Heroku (or where the file system is not writeable)

I run this tool on Heroku (a single free dyno works great!) but they dont allow you to write to the filesystem. Instead, I use Redis. Add the free Redis To Go addon and everything should just work out of the box.

heroku create
heroku addons:add redistogo
git push heroku master
heroku ps:scale worker=1 && heroku logs -t

This will push whatever you've got committed in your local git repo up to a new heroku app connected to a free RedisToGo instance, running on a free Heroku worker dyno, and tail the Heroku log file -- just in case there are errors. If no errors appear after a minute or two, just hit ctrl+c to exit the log tail and go about your business.

Enjoy!

The MIT License (MIT)

Copyright (c) 2014 Adam Tuttle

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-trello-slack's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.