# node-slackr

> A node.js module for send notifications to Slack, support multiple channel and attachments

Latest version **1.0.1** (published 2018-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-slackr
pnpm add node-slackr
yarn add node-slackr
bun add node-slackr
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-06-23 |
| First published | 2014-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 52.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 72 |
| Author | Sarunyhot Suvannachoti |
| Maintainers | chenka |
| Keywords | slack |

## Links

- npm: https://www.npmjs.com/package/node-slackr
- Repository: https://github.com/chenka/node-slackr
- Homepage: https://github.com/chenka/node-slackr#readme
- Issues: https://github.com/chenka/node-slackr/issues
- npm.io page: https://npm.io/package/node-slackr

## Dependencies (3)

- [async](https://npm.io/package/async.md) ^2.6.0
- [lodash](https://npm.io/package/lodash.md) ^4.11.1
- [request](https://npm.io/package/request.md) ^2.72.0

## Recent versions

- 1.0.1 (latest) — 2018-06-23
- 1.0.0 — 2018-06-23
- 0.2.0 — 2018-05-01
- 0.1.4 — 2016-04-24
- 0.1.3 — 2016-04-24
- 0.1.2 — 2015-10-23
- 0.1.1 — 2015-09-24
- 0.1.0 — 2015-03-11
- 0.0.4 — 2014-05-14
- 0.0.3 — 2014-05-13
- 0.0.2 — 2014-05-13
- 0.0.1 — 2014-05-13

## README

![travis-ci](https://travis-ci.org/chenka/node-slackr.svg)

# This module has been deprecated.
please move to [Slack offecial API](https://github.com/slackapi/node-slack-sdk)

Summary
=======
A simple node.js library for send notifications to [Slack](https://slack.com/) via Incoming WebHooks.


Installation
=======
You can also install via npm:
```sh
npm install node-slackr
```

Initialize client:

```js
Slack = require('node-slackr');
slack = new Slack('https://<incoming-hook-url>');
```

Initialize with options:
```js
slack = new Slack('https://<incoming-hook-url>',{
  channel: "#development",
  username: "slack-bot",
  icon_url: "http://domain.com/image.png",
  icon_emoji: ":ghost:"
});
```

### Send message:

If channel is not set default channel is *#general*
```js
slack.notify("Message"); //without callback
slack.notify("Message", function(err, result){
    console.log(err,result);
});

```

### Customized Appearance:

You can customize the name and icon of your Incoming Webhook.

```js
messages = {
    text: "Message",
    channel: "#random",
    username: "new-bot-name",
    icon_url: "https://slack.com/img/icons/app-57.png"
}

slack.notify(messages);
```

Send multiple channels:
```js
messages = {
    text: "Message",
    channel: ["#channel1","#channel2","#channel3"]
}

slack.notify(messages);
```


### Message Attachments:
To display a richly-formatted message attachment in Slack, you can use the same JSON payload as above, but add in an attachments array. Each element of this array is a hash containing the following parameters:

```js
messages = {
  text: "Server Down",
  channel: "#alert",
  attachments: [
    {
      fallback: "Detected server down",
      color: "#36a64f", // Can either be one of 'good', 'warning', 'danger'
      fields: [
        {
          title: "Uptime",
          value: "30 Hours",
          short: false
        },
        {
          title: "Downtime",
          value: "20 Minutes",
          short: false
        }
      ]
    }
  ]
};

slack.notify(messages, function(err, result) {
    console.log(err, result);
});

```

### Documentation

For more information such as send URL link, Message Formatting, @mention and Parsing modes,  please follow the link below

[Formatting](https://api.slack.com/docs/formatting)

[Incomg Webook](https://my.slack.com/services/new/incoming-webhook)

---
_Source: https://npm.io/package/node-slackr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
