Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

moleculer-slack

1.1.0 • Public • Published

Moleculer logo

moleculer-slack NPM version

Send Messages to Slack API.

Install

$ npm install moleculer-slack --save

Usage

Before use please set the SLACK_TOKEN and SLACK_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

@ice-services @MoleculerJS

install

npm i moleculer-slack

Downloadsweekly downloads

0

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability