0.1.2 ā€¢ Published 2 years ago

slack-friends v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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");
0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago