Skip to content

nifetency/slackbot-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Slack Notification POC

A simple Proof of Concept (POC) for sending notifications to Slack using the slack-notify library in a Node.js environment.

Features

  • Send simple text messages to Slack.
  • Support for custom channels, icons, and usernames.
  • Pre-configured methods for common notification types: bug, success, and alert.
  • Advanced formatting using Slack attachments and fields.
  • Promise-based API.

Prerequisites

  • Node.js (v14 or higher recommended)
  • A Slack Incoming Webhook URL. You can create one by setting up an "Incoming Webhooks" integration in your Slack workspace.

Installation

  1. Clone the repository or download the source code.
  2. Install the dependencies:
npm install

Configuration

Open slack-notify.js and replace the placeholder webhook URL with your actual Slack webhook URL:

const MY_SLACK_WEBHOOK_URL = 'https://hooks.slack.com/services/YOUR/WEBHOOK/URL';

Usage

Run the script using Node.js:

node slack-notify.js

Examples

The slack-notify.js file includes several examples:

Basic Text Message

slack.send('Hello!')
  .then(() => console.log('Done!'))
  .catch(err => console.error(err));

Custom Configuration

slack.send({
  channel: '#custom-channel',
  icon_url: 'http://example.com/icon.png',
  text: 'Custom notification message',
  username: 'CustomBot'
});

Pre-configured Methods

slack.bug('Something broke!'); // Posts to #bugs by default
slack.success('Operation successful!'); // Posts to #alerts by default
slack.alert('Important notice!'); // Posts to #alerts by default

Rich Formatting with Fields

slack.alert({
  text: 'Server Stats',
  fields: {
    'CPU usage': '7.51%',
    'Memory usage': '254mb'
  }
});

About

POC for sending notifications to slack

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors