This is a Slack client library for Node.js. It's intended to expose all of the functionality of Slack's Real Time Messaging API while providing some common abstractions and generally making your life easier, if you want it to.
This code has been built to support our hubot-slack adapter. Most other functionality isn't yet supported, and documentation is minimal, at best.
npm install slack-client --save
Slack = require 'slack-client'
slackToken = 'xoxb-YOUR-TOKEN-HERE' # Add a bot at https://my.slack.com/services/new/bot and copy the token here.
autoReconnect = true # Automatically reconnect after an error response from Slack.
autoMark = true # Automatically mark each message as read after it is processed.
slack = new Slack(slackToken, autoReconnect, autoMark)
slack.on 'open', ->
console.log "Connected to #{slack.team.name} as @#{slack.self.name}"
slack.on 'message', (message) ->
console.log message
slack.on 'error', (err) ->
console.error "Error", err
slack.login()
A full example of how to use this module from Node.js can be found in the /examples directory.
Here's the most direct way to get your work merged into the project.
- Fork the project
- Clone down your fork
- Create a feature branch
- Hack away and add tests, not necessarily in that order
- Make sure everything still passes by running tests
- If necessary, rebase your commits into logical chunks without errors
- Add yourself to package.json as a contributor
- Push the branch up to your fork
- Send a pull request for your branch
Copyright © Slack Technologies, Inc. MIT License; see LICENSE for further details.
- Better/any timeouts on initial websocket connection
- Better/any timeouts on API calls
- Document the connection options, etc
- Emit more events around unreads and mentions