https://github.com/guidesmiths/systemic-slack
Simple systemic component to send messages or files in Slack to any room
https://github.com/guidesmiths/systemic-slack
Last synced: 5 months ago
JSON representation
Simple systemic component to send messages or files in Slack to any room
- Host: GitHub
- URL: https://github.com/guidesmiths/systemic-slack
- Owner: onebeyond
- License: mit
- Created: 2020-05-21T13:54:03.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-20T11:48:44.000Z (almost 2 years ago)
- Last Synced: 2024-12-20T16:09:54.509Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/systemic-slack
- Size: 173 KB
- Stars: 2
- Watchers: 13
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://codeclimate.com/github/onebeyond/systemic-slack/maintainability)
[](https://codeclimate.com/github/onebeyond/systemic-slack/test_coverage)# systemic-slack
systemic-slackSimple systemic component to send messages or files in Slack to any room.
## Environment variables
* SLACK_TOKEN - Slack API token [Slack Token Page](https://api.slack.com/tokens)## Usage
```js
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
})
```## How to send a message
Use the client method `chat.postMessage`, documentation is available [here](https://api.slack.com/methods/chat.postMessage)
```js
await components.slack.chat.postMessage({
channel: 'CXXXXXX', // channel ID
text, // Text to send
});
```## How to send a file
Use the client method `files.upload`, documentation is available [here](https://api.slack.com/methods/files.upload)
```js
const {createReadStream} = require('fs');
slackClient.files.upload({
filepath,
title,
channels: [ 'CXXXXXXX' ],
file: createReadStream(filepath),
});
```## Message format
Message content can be formated using MarkDown syntax [Markdown cheatseet](https://www.markdownguide.org/cheat-sheet/)