@byu-oit/post-to-slack
A simple module to post messages to a slack incoming webhook
Last updated 3 years ago by saholman .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @byu-oit/post-to-slack 
SYNC missed versions from official npm registry.

post-to-slack

A simple npm module for posting to Slack Incoming Webhooks (https://byu-oit.slack.com/apps/A0F7XDUAZ-incoming-webhooks)

Usage

Posting simple text

const slack = require('post-to-slack')
const url = '<your slack webhook>';

slack("Testing", url, function(err) {
     if(err) {
         console.log("Send failed: ", err)
     } else {
         console.log("Success")
     }
})

Posting attachments

const slack = require('post-to-slack')
const url = '<your slack webhook>';
const formatter = require('format-json')

var json = {
   "My":{
      "JSON":"object"
   }
}

var formattedJson = formatter.plain(json)

slack({
    text: 'A failed event has been removed from the queue',
    attachments: [{
        fallback: JSON.stringify(json),
        text: formattedJson
    }]
}, url, function(err) {
    if(err) {
        console.log("Send failed: ", err)
    } else {
        console.log("Success")
    }
})

See slack documentation for more information on sending attachments at https://api.slack.com/incoming-webhooks

Current Tags

  • 0.0.1                                ...           latest (3 years ago)

1 Versions

  • 0.0.1                                ...           3 years ago
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |