1.1.7 • Published 5 years ago

ib-slacknotifier v1.1.7

Weekly downloads
39
License
-
Repository
-
Last release
5 years ago

SlackNotifier

A library that allows you to easily send notifications to a slack channel from a lambda function. The notification also provides a link to the cloudwatch invocation logs of the function. Note that the library is based on Promises.

Installation

npm i ib-slacknotifier

Requirements

To use the library it is necessary to create an Incoming Webhook through the Slack API (https://api.slack.com/incoming-webhooks). This allows you to post notifications to a channel of your choice.

Usage

To create an instance of the SlackNotifier you must provide it with a webhook url for your slack channel and the context of your lambda function. You can also provide the class with an amazon region and a moment timezone for more customization. These defaults to 'eu-central-1' and 'Europe/Copenhagen'.

To send a notification to a channel you use the notify() method. This method takes in the following parameters:

  • message - A string or object containing the message of the notification being posted to slack
  • color - the color of the line to the left of the notification. Options: Red, Yellow, Green, Steel blue. A hex code can also be provided for custom colors.
import SlackNotifier from 'ib-slacknotifier'
import { SlackNotificationColor } from 'ib-slacknotifier/dist/SlackNotificationColor'
import { Context, APIGatewayEvent, ProxyResult } from 'aws-lambda'

const YOUR_SLACK_WEBHOOK = 'https://hooks.slack.com/services/ITLOOKS/LIKETHIS'

export const handler = async (event: APIGatewayEvent, context: Context): Promise<ProxyResult> => {
  let message = 'Look mom, I made this'

  let res = await new SlackNotifier(YOUR_WEBHOOK_URL, context).notify(message, SlackNotificationColor.IB)
}
1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago