moleculer-slack

1.2.2 • 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

/moleculer-slack/

    Package Sidebar

    Install

    npm i moleculer-slack

    Weekly Downloads

    39

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    14.2 kB

    Total Files

    9

    Last publish

    Collaborators

    • icebob