Wrapper for Slack Web API #️⃣
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
api
test
tools
.gitignore
.npmignore
.travis.yml
History.md
LICENSE
README.md
index.js util.inherits Dec 8, 2015
package.json

README.md

Slack Web API Wrapper

Client interface for accessing Slack Web API.

NPM version Build Status Coverage Status

Installation

Install via npm

npm install slack-wrapi --save

Usage

Create a slack client with API token to connect to Slack Web API.

var slackWrapi = require('slack-wrapi');

var slack = new slackWrapi(SLACK_API_TOKEN);

// Now you are ready to make API calls to Slack.

Function names match with Slack API endpoints (methods) as per the documentation.

Just provide parameters and a callback.

API calls follow this syntax:

slack.apigroup.action(queryString, callback);

  • queryString - (as required) API method parameters as key-value pairs.

Examples

Lists custom emoji for a team.

slack.emoji.list(function(err, data) {
  if (!err) {
    console.log(data);
  }
});

Lists all channels in a Slack team.

slack.channels.list({exclude_archived:1}, function(err, data) {
  if (!err) {
    console.log(data);
  }
});

Gets information about a private group.

slack.groups.info({channel:"G1234567890"}, function(err, data) {
  if (!err) {
    console.log(data);
  }
});

Adds a reaction to an item.

slack.reactions.add({
    name: "thumbsup",
    file: "F1234567890",
    file_comment: "Fc1234567890",
    channel:"G1234567890",
    timestamp: "1234567890.123456"
  },
  function(err, data) {
    if (!err) {
      console.log(data);
    }
  }
);

Gets information about a user.

slack.users.info({user: "U1234567890"}, function(err, data) {
  if (!err) {
    console.log(data);
  }
});

Post chat messages to Slack.

slack.chat.postMessage({
    "channel": "#general",
    "text": "Hello <@u12345678|world>!",
    "username": "Wrapi Bot",
    "as_user": false,
    "parse": "full",
    "link_names": 1,
    "attachments": [{"pretext": "pre-hello", "text": "text-world"}],
    "unfurl_links": true,
    "unfurl_media": false
  },
  function(err, data) {
    if (!err) {
      console.log(data);
    }
  }
)

Check user's current Do Not Disturb settings.

slack.dnd.info({
    "user": "U1234"
  },
  function(err, data) {
    if (!err) {
      console.log(data);
    }
  }
)

API Methods

api

apps.permissions

apps.permissions.resources

apps.permissions.scopes

auth

bots

channels

chat

conversations

dialog

dnd

emoji

files.comments

files

groups

im

migration

mpim

oauth

pins

reactions

reminders

rtm

search

stars

team

team.profile

usergroups

usergroups.users

users

users.profile

License

MIT