Skip to content

Ajnasz/slack-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to subscribe to a hook and respond to it

var createSlackHook = require('slack-hook');

var slackHook = createSlackHook(secretSlackToken);

slackHook.use(function (serv) {
	return new Promise(function (resolve, reject) {
		// do some great stuff
		var result = doSomeGreatStuff(serv.body);

		if (result) {
			serv.respond('Thank you, I did some great stuff');
			resolve(serv);
		} else {
			// sending back error
			serv.error = {
				statusCode: 400,
				message: 'Could not do any great stuff'
			}

			reject(serv);
		}
	});
});

var port = 8899;

slackHook.server.listen(port, function () {
	'use strict';

	console.log('listening on %d', port);
});

About

Lightweight framework to handle incoming slack webhooks

Resources

Stars

Watchers

Forks

Packages

No packages published