systemic-slack
Simple systemic component to send messages or files in Slack to any room.
- SLACK_TOKEN - Slack API token Slack Token Page
const System = require('systemic')
const slack = require('systemic-slack')
new System()
.configure({
slack: {
token: process.env.SLACK_TOKEN
}
})
.add('logger', console)
.add('slack', slack()).dependsOn('config')
.start((err, components) => {
/// do anything with components.slack
})
Use the client method chat.postMessage
, documentation is available here
await components.slack.chat.postMessage({
channel: 'CXXXXXX', // channel ID
text, // Text to send
});
Use the client method files.upload
, documentation is available here
const {createReadStream} = require('fs');
slackClient.files.upload({
filepath,
title,
channels: [ 'CXXXXXXX' ],
file: createReadStream(filepath),
});
Message content can be formated using MarkDown syntax Markdown cheatseet