Basic Slack Api SDK using User Session Token
npm i --save slack-sdk
const slack = require('slack-sdk')('workspace-name', 'user-session-token', {/* options */});
slack.message.channel('channel-name', 'message');
Cache duration in seconds. Optional, defaults to 60
.
Maximum number of entries in cache at any given time. Optional, defaults to 100
.
- Go to https://YOURWORKSPACE.slack.com/home in Chrome
- Right click → Inspect
- Select the network tab
- Reload the page
- Type in api in the search
- Click rtm.start and then headers
- Scroll down until you find the
token
. It starts withxoxs-
- Copy it!
Send message
to self.
Send message
to channel channel
.
Obtain details for workspace. Should usually be cached as it is easy to run into rate limits.
Send request to slack endpoint endpoint
with parameters params
.
E.g. call("rtm.start", {}, true)
to obtain information about current user. Use cache if information was already obtained before.
Cache operates by matching the exact outgoing request signature.
Cached and non-cached requests operate separately. So making a non cached request does never alter the cache.