The only module you'll need for custom hooks that integrate with Slack
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
Gruntfile.js
LICENSE
README.md
package.json
slack.js

README.md

Slackhook

The only module you'll need for custom hooks that integrate with Slack.

Build Status

Installation

npm install slackhook

Requirements

You'll need a domain and token from Slack.

The domain will be the organisation part of <organisation>.slack.com

The token is given to you when you create your incoming webhook integration.

Usage

var Slackhook = require('slackhook');
var slack = new Slackhook({
    domain: 'yourdomain',
    token: 'yourtoken'
});

Sending

You can set up incoming webhooks here

slack.send({
    content: 'Hi everybody',
    channel: '#general',
    username: 'Dr. Nick',
    icon_url: 'drnick.png' 
});

You can pass the send method a callback if you like.

slack.send({
    text: 'Hi Dr. Nick!',
    channel: '#general',
    username: 'Everybody',
    icon_emoji: 'smile'
}, function(err, response){
    // Do your thing
});

Responding

You can also respond to webhooks coming from Slack. You could use this to make a chat bot etc.

You can set up outgoing webhooks here

This example assumes you're running inside an Express.js route.

app.post('/outgoing', function(req, res){
	var hook = slack.respond(req.body);
	res.json({text: 'Hi ' + hook.user_name, username: 'Dr. Nick'});
});

Example apps

Teamcity integration

License

MIT