@bondsports/slack
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Slack

The Slack package provides functionality for sending messages to Slack channels using the Slack API.

Installation

To install the Slack package, you can use npm or yarn:

npm install @bondsports/slack

or

yarn add @bondsports/slack

Usage

You can use the Slack Client by importing it into your TypeScript code:

import { SlackClient } from '@bondsports/slack';

// Initialize SlackClient with your Slack API token, environment, and default channel
const slackClient = new SlackClient('your-api-token', 'production', '#general');

// Send a message to Slack
slackClient.sendMessage('Hello, Slack!').then((success) => {
    if (success) {
        console.log('Message sent successfully');
    } else {
        console.error('Failed to send message');
    }
});

Constructor

The SlackClient constructor takes three parameters:

  • token: A string representing your Slack API token.
  • environment: A string representing the environment in which the client operates.
  • defaultChannel: A string representing the default channel to which messages will be sent.

Example:

const slackClient = new SlackClient('your-api-token', 'production', '#general');

Methods

sendMessage

The sendMessage method sends a message to a Slack channel.

async sendMessage(message: string, options?: ISendMessageOptions): Promise<boolean>
  • message: The message to send to the Slack channel.
  • options: Optional parameters for sending the message.

Example:

slackClient.sendMessage('Hello, Slack!').then((success) => {
    if (success) {
        console.log('Message sent successfully');
    } else {
        console.error('Failed to send message');
    }
});

Readme

Keywords

none

Package Sidebar

Install

npm i @bondsports/slack

Weekly Downloads

351

Version

1.0.1

License

none

Unpacked Size

19.5 kB

Total Files

22

Last publish

Collaborators

  • dan.spinosa--bondsports.co
  • evadshin
  • eyal.borovsky
  • gittyp
  • ido.naveh.bondsports
  • noam.benzeev
  • taroninak
  • barak_matityahu
  • jbknickerbocker