1.0.0 • Published 6 years ago

slack-msg-helper v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

slack-helper

A Nodejs module facilitating Slack messaging.

installation

npm install --save slack-msg-helper

usage

Add client

const SL = require("slack-helper")

// Will create a default config
SL.addConfig("token","botname");

// Will create a config with name "slack1"
SL.addConfig("slack1","token","botname");

Use client

The client is chainable which means that you can call functions one after the other until you execute the posting. It then returning a promise.

Initialise a post:

// Creating message to group or channel called "my-channel"
SL.message("my-channel");

// Creating message to group or channel called "my-channel" using the config "slack1"
SL.message("my-channel").use("Client1")

Posting

For those example we will use the query variable 'slack':

// initialise query
var slack = SL.message("my-channel");

Simple message

slack.post("my message");

Message with JSON attachement

slack.post("my message", {...});