slack-friends
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

slack-friends

Make it easy to send to Slack from your application

Installation

💡 npm install slack-friends

How to get bot token

  1. https://api.slack.com/
  2. Your apps
  3. Create New App
  4. OAuth & Permissions - Bot User OAuth Token
Bot Token scopes 
  * channels:join
  * channels:read
  * chat:write

Usage

import { SlackFriends } from "slack-friends";

const slack = new SlackFriends({
  token: "Your Bot Token",
  channel: "Channel Name",
});
  • token : Please refer to 'How to get bot token' to issue the token
  • channel : write channel name eg) #channelName -> remove # and only use channelName

Common Message

slack.send("hello world");

Custom Message

Please refer to the detail to build Custom Message https://app.slack.com/block-kit-builder/

const customMessage = {
  "blocks": [
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "This is a section block with a button."
      },
      "accessory": {
        "type": "button",
        "text": {
          "type": "plain_text",
          "text": "Click Me",
          "emoji": true
        },
        "value": "click_me_123",
        "action_id": "button-action"
      }
    }
  ]
}

slack.send(customMessage);

Cron Message

slack.cron("* * * * *", "hello World");
 # ┌────────────── second (optional)
 # │ ┌──────────── minute
 # │ │ ┌────────── hour
 # │ │ │ ┌──────── day of month
 # │ │ │ │ ┌────── month
 # │ │ │ │ │ ┌──── day of week
 # │ │ │ │ │ │
 # │ │ │ │ │ │
 # * * * * * *

This is a quick reference to cron syntax and also shows the options supported by node-cron.

Schedule Message

slack.time(new Date("2022-06-18T05:17:00Z"), "hello World");

Package Sidebar

Install

npm i slack-friends

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

16.3 kB

Total Files

5

Last publish

Collaborators

  • ehdaydkv112