Skip to content

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

License

Notifications You must be signed in to change notification settings

david-benes/node-slackhook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%