https://github.com/punwave/punwave-slack-notifier
Code friendly notifier to send messages to Slack channel via webhook
https://github.com/punwave/punwave-slack-notifier
alert message notification notifier slack
Last synced: 2 months ago
JSON representation
Code friendly notifier to send messages to Slack channel via webhook
- Host: GitHub
- URL: https://github.com/punwave/punwave-slack-notifier
- Owner: punwave
- License: mit
- Created: 2017-03-02T04:01:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-05T09:10:15.000Z (over 8 years ago)
- Last Synced: 2025-10-28T00:50:32.407Z (8 months ago)
- Topics: alert, message, notification, notifier, slack
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# punwave-slack-notifier
[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Coverage Status][codecov-image]][codecov-url]
> Code friendly notifier to send messages to Slack channel via webhook
## Install
```
$ npm install --save punwave-slack-notifier
```
## Usage
```js
const SlackNotifier = require('punwave-slack-notifier')
const notifier = new SlackNotifier(WEBHOOK_URL, {
channel: '#general',
username: 'webhookbot',
})
notifier.send({
text: 'This is a line of text.\nAnd this is another one.'
}, (err, response) => {
if (err) console.error(err)
console.log(response)
})
```
## API
### notifier.send(options, callback)
Send message to Slack channel.
---
#### Options
For setting `attachement` of message, please see [Slack API documentation](https://api.slack.com/docs/message-attachments) for reference.
#### options.text
If you want to display some specific information, such as error stack trace, JavaScript object information or JSON (JavaScript Object Notation) formatted string for notifications, you can pass `{ text: [{ title: TITLE, code: CODE }] }` for options to create code blocks.
#### options.attachements
It used for customizing your notifications.
If your pass `{ attachements: [] }` for options, it will override default settings.
---
### notifier.success(options, callback)
Send message that indicates a successful or positive action to Slack channel.
---
### notifier.warning(options, callback)
Send message that indicates a warning that might need attention to Slack channel.
---
### notifier.danger(options, callback)
Send message that indicates a dangerous or potentially negative action to Slack channel.
## License
MIT
[npm-image]: https://img.shields.io/npm/v/punwave-slack-notifier.svg
[npm-url]: https://npmjs.org/package/punwave-slack-notifier
[travis-image]: https://img.shields.io/travis/punwave/punwave-slack-notifier.svg
[travis-url]: https://travis-ci.org/punwave/punwave-slack-notifier
[codecov-image]: https://img.shields.io/codecov/c/github/punwave/punwave-slack-notifier.svg
[codecov-url]: https://codecov.io/gh/punwave/punwave-slack-notifier