Nodejslack
Start using Slack's Web API in an easy way through this Node.js library.
Also, this library is built using the Promises pattern, powered by Bluebird .
Installation
npm install nodejslack
Methods
Bots
getBotInfo(id)
(return: promise) - Gets information about a Bot
Channels
archiveChannel(id)
(return: promise) - Archives a channel,createChannel(name)
(return: promise) - Creates a channel,getChannelHistory(data)
(return: promise) - Gets the history of a channel,getChannelInfo(id)
(return: promise) - Gets info of a channel,inviteUserToChannel(channelId, userId)
(return: promise) - Invites a user to a channel,joinChannel(channelName)
(return: promise) - Join(user) to a channel,kickUserFromChannel(channelId, userId)
(return: promise) - Kicks a user from a channel,leaveChannelfunction(channelId)
(return: promise) - Leaves a channel,getChannels()
(return: promise) - Get all channels,markChannel(channelId, ts)
(return: promise) - Moves the read cursor in a channel,renameChannel(channelId, name)
(return: promise) - Renames a channel,setPurposeChannel(channelId, purpose)
(return: promise) - Sets a purpose of a channel,setTopicChannel(channelId, topic)
(return: promise) - Sets a topic of a channel,unarchiveChannel(channelId)
(return: promise) - Unarchives a channel
Chats
meMessage(channelId, text)
(return: promise) - Sends a me message to a channel from the calling user,deleteMessage(ts, channelId, asUser)
(return: promise) - Deletes a message,postMessage(data)
(return: promise) - Posts a message,updateMessage(data)
(return: promise) - Updates a message
dnd(Do not Disturb)
endDnd()
(return: promise) - Ends dnd(Do not disturb) mode,endSnooze()
(return: promise) - Ends Snooze mode,dndInfo(user)
(return: promise) - Provides information about a user's current Do Not Disturb settings,setSnooze(minutes)
(return: promise) - Sets Snooze mode,dndTeamInfo(users)
(return: promise) - Provides information about a Team's Do Not Disturb settings
Emoji
getEmojiList()
(return: promise) - Gets Emoji List
Files
fileUpload(params)
(return: promise) - uploads a file,getFilesList(params)
(return: promise) - returns a list of uploaded files,getFileInfo(id, count, page)
(return: promise) - returns informations about the specified filedeleteFile(id)
(return: promise) - Delete specified filefileRevokePublicURL(id)
(return: promise) - Disables public URL the specified filefileEnablePublicURL(id)
(return: promise) - Enables public URL the specified file
Files.comment
fileAddComment(id, comment)
(return: promise) - Add a comment to a file,fileEditComment(id, fileId, comment)
(return: promise) - Edit an existing comment about a filefileDeleteComment(id, fileId)
(return: promise) - Delete a comment about a file
Users
deleteUserPhoto()
(return: promise) - Deletes a photo from the user's profile,getUserPresence(id)
(return: promise) - Gets user's presence,getUserIdentity()
(return: promise) - Gets user's identity,getUserInfo(id)
(return: promise) - Gets user's info,getUsersList()
(return: promise) - Gets all users,setUserActive()
(return: promise) - Sets user's as active,setUserPhoto(data)
(return: promise) - Sets a photo to the user's profile,setUserPresence(presence)
(return: promise) - Sets user's presence(Either "auto" or "away")
Usage
slack.fileUpload(params)
var Slack = ;var fs = ;var SLACK_TOKEN = processenvSLACK_TOKEN || 'YOUR_GENERATED_SLACK_TOKEN'; var slack = SLACK_TOKEN; var form = file: fs // Optional, via multipart/form-data. If omitting this parameter, you MUST submit content // content: 'Your text here', // Optional, File contents. If omitting this parameter, you must provide a `file` filename: 'test.csv' // Required fileType: 'post' // Optional, See more file types in https://api.slack.com/types/file#file_types title: 'Title of your file!' // Optional initial_comment: 'First comment about this file.' // Optional channels: 'general' //Optional, If you want to put more than one channel, separate using comma, example: 'general,random'; slack;
slack.getFilesList(params)
var Slack = ;var fs = ;var SLACK_TOKEN = processenvSLACK_TOKEN || 'YOUR_GENERATED_SLACK_TOKEN'; var slack = SLACK_TOKEN; var form = user: 'USER_ID' // Optional, User ID channel: 'CHANNEL_ID' // Optional, Channel ID ts_from: 342353452342 // Optional, Filter(Unix Timestamp) files created after this timestamp (inclusive). ts_to: 342353452342 // Optional, Filter(Unix Timestamp) files created before this timestamp (inclusive). types: 'zips,pdfs' // Optional, Filter files by type: all, spaces, snippets, images, gdocs, zips, pdfs. count: 20 // Optional, default: 100 page: 2 // Optional, default: 1; slack;
slack.getFileInfo(id, count, page)
var Slack = ;var fs = ;var SLACK_TOKEN = processenvSLACK_TOKEN || 'YOUR_GENERATED_SLACK_TOKEN'; var slack = SLACK_TOKEN; var fileId = 'UH45344543'; // File IDvar count = 20; // Optional, Number of items to return per page.var page = 2; // Optional, Page number of results to return. slack;
slack.deleteFile(id)
var Slack = ;var fs = ;var SLACK_TOKEN = processenvSLACK_TOKEN || 'YOUR_GENERATED_SLACK_TOKEN'; var slack = SLACK_TOKEN; var fileId = 'UH45344543'; // File ID slack;
slack.fileRevokePublicURL(id)
var Slack = ;var fs = ;var SLACK_TOKEN = processenvSLACK_TOKEN || 'YOUR_GENERATED_SLACK_TOKEN'; var slack = SLACK_TOKEN; var fileId = 'UH45344543'; // File ID slack;
slack.fileEnablePublicURL(id)
var Slack = ;var fs = ;var SLACK_TOKEN = processenvSLACK_TOKEN || 'YOUR_GENERATED_SLACK_TOKEN'; var slack = SLACK_TOKEN; var fileId = 'UH45344543'; // File ID slack;
fileAddComment(id, comment)
(return: promise) - Add a comment to a file,fileEditComment(id, fileId, comment)
(return: promise) - Edit an existing comment about a filefileDeleteComment(id, fileId)
(return: promise) - Delete a comment about a file
slack.fileAddComment(id, comment) + slack.fileEditComment(id, fileId, comment) + slack.fileDeleteComment(id, fileId)
var Slack = ;var fs = ;var SLACK_TOKEN = processenvSLACK_TOKEN || 'YOUR_GENERATED_SLACK_TOKEN'; var slack = SLACK_TOKEN; var fileId = 'UH45344543'; // File ID slack ;