slack-write
v0.3.1
Published
Write to slack
Downloads
4,834
Readme
write on slack
Usage
- Add a slackbot integration, and get a token (https://your-team-name.slack.com/services/new/slackbot)
- Get a channel id from slack (https://api.slack.com/methods/channels.list/test)
- You can pass anything to username
- You can use slack message formatting (https://api.slack.com/docs/formatting)
Example
var slackWrite = require('slack-write');
var channel = {
token: 'slack-bot-token',
channel: 'CXXXXXXX',
username: 'bot-name'
};
var slack = slackWrite(channel);
// write plain text
slack.write('Some text', function(err, result) {
console.log(err, result);
});
// post a single attachment
slack.attach('ignored text', {
pretext: 'pretext',
title: 'attachment title',
text: 'some texts following title'
}, function(err, result) {
console.lgo(err, result);
});
License
MIT © Dongwon Lim