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.channel.message('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.
Share files
to self.
Get meta information about channel channel
Send message
to channel channel
.
Set topic
of channel channel
Set purpose
of channel channel
Share files
to a channel channel
.
Obtain details for workspace. Should usually be cached as it is easy to run into rate limits.
Upload file. Title and filename default to basename of filepath. Returns file id.
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.