moleculer-slack
v1.2.2
Published
Send Messages to slack
Downloads
139
Readme
moleculer-slack
Send Messages to Slack API.
Install
$ npm install moleculer-slack --save
Usage
Before use please set the
SLACK_TOKEN
andSLACK_CHANNEL
environment variables.
let { ServiceBroker } = require("moleculer");
let SlackService = require("../../index");
// Create broker
let broker = new ServiceBroker({ logger: console });
// Load my service
broker.createService({
name: "slack",
mixins: [SlackService]
});
// Start server
broker.start().then(() => {
broker
.call("slack.send", { message: "Hello Slack!" })
.then(res => console.log("Slack message sent. Sid:", res.ts))
.catch(console.error);
});
Settings
| Property | Type | Default | Description |
| -------- | ---- | ------- | ----------- |
| slackToken
| String
| required | Slack API Token. Visit your Slack App dashboard's main page. Click "Create App, Generate Token", then copy and paste your "API TOKEN" here. |
| slackChannel
| String
| null
| Slack API Token. Visit your Slack App dashboard's main page. Add incoming webhook and create/select a channel, then copy and paste here. |
Actions
send
Send a Slack Message
Parameters
| Property | Type | Default | Description |
| -------- | ---- | ------- | ----------- |
| message
| String
| required | Message text |
| channel
| String
| null
| Channel name |
Results
Type: String
Methods
sendMessage
Send a slack message
Parameters
| Property | Type | Default | Description |
| -------- | ---- | ------- | ----------- |
| message
| String
| - | Body of the message |
| channel
| String
| - | Channel name |
Results
Type: String
Test
$ npm test
In development with watching
$ npm run ci
License
The project is available under the MIT license.
Contact
Copyright (c) 2016-2018 Ice Services