Slack Developer Kit for Node.js
Kind: global class
functionObjectbooleanbooleanstringstring[SlackDataStore](#SlackDataStore)?Creates a new instance of RTM client.
| Param | Type | Default | Description |
|---|---|---|---|
| token | string |
The token to use for connecting | |
| [opts] | Object |
||
| [opts.socketFn] | RTMClient~socketFn |
A function to call, passing in a websocket URL, that should return a websocket instance connected to that URL | |
| [opts.dataStore] | [SlackDataStore](#SlackDataStore) | null | false |
A store to cache Slack info. Recommended value is false. Default value is an instance of SlackMemoryDataStore. |
|
| [opts.autoReconnect] | boolean |
true |
Whether or not to automatically reconnect when the connection closes |
| [opts.useRtmConnect] | boolean |
false |
Whether to use rtm.connect rather than rtm.start. Recommended value is true. |
| [opts.retryConfig] | Object |
The retry policy to use, defaults to forever with exponential backoff, see node-retry for more details. | |
| [opts.maxReconnectionAttempts] | number |
DEPRECATED: Use retryConfig instead | |
| [opts.reconnectionBackoff] | number |
DEPRECATED: Use retryConfig instead | |
| [opts.wsPingInterval] | number |
5000 |
The time (in ms) to wait between pings with the server |
| [opts.maxPongInterval] | number |
The max time (in ms) to wait for a pong before reconnecting | |
| [opts.logLevel] | string |
"info" |
The log level for the logger |
| [opts.logger] | RTMClient~logFn |
Function to use for log calls, takes (logLevel, logString) parameters |
functionKind: instance property of [RTMClient](#RTMClient)
ObjectThe active websocket.
Kind: instance property of [RTMClient](#RTMClient)
booleanKind: instance property of [RTMClient](#RTMClient)
booleanKind: instance property of [RTMClient](#RTMClient)
stringThe id of the user that’s currently connected via this client.
Kind: instance property of [RTMClient](#RTMClient)
stringThe id of the team that’s currently connected via this client.
Kind: instance property of [RTMClient](#RTMClient)
[SlackDataStore](#SlackDataStore)Kind: instance property of [RTMClient](#RTMClient)
?The timer repeatedly pinging the server to let it know the client is still alive.
Kind: instance property of [RTMClient](#RTMClient)
Kind: instance method of [RTMClient](#RTMClient)
Begin an RTM session.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type |
|---|---|
| opts | object |
Deprecated
Kind: instance method of [RTMClient](#RTMClient)
Generates the next message id to use.
NOTE: This id must be unique per RTM connection.
Kind: instance method of [RTMClient](#RTMClient)
Connects to the RTM API.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type | Description |
|---|---|---|
| socketUrl | String |
The URL of the websocket to connect to. |
Disconnects from the RTM API.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type |
|---|---|
| optReason | Error |
| optCode | Number |
Attempts to reconnect to the websocket by retrying the start method.
Kind: instance method of [RTMClient](#RTMClient)
Handler to deal with the WebSocket open event. NOTE: this.connected doesn’t get set to true until the helloHandler is called.
Kind: instance method of [RTMClient](#RTMClient)
Handler to deal with the WebSocket message event.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type |
|---|---|
| wsMsg | object |
Handler for the remote server’s response to a message being sent on the websocket.
Kind: instance method of [RTMClient](#RTMClient)
| Param |
|---|
| replyTo |
| message |
Emits the websocket error.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type |
|---|---|
| err | Object |
Occurs when the websocket closes.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type | Description |
|---|---|---|
| code | String |
The error code |
| reason | String |
The reason for closing |
Handles the RTM API’s pong message, updating the lastPong time on the client.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type |
|---|---|
| message | Object |
If we haven’t received a pong in too long, treat any incoming message as a pong to prevent unnecessary disconnects.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type |
|---|---|
| message | Object |
Occurs when the socket connection is opened. Begin ping-pong with the server. hello
Kind: instance method of [RTMClient](#RTMClient)
Helper for sending a simple message to a channel|group|DM etc via the RTM API.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type | Description | ||
|---|---|---|---|---|
| text | string |
The text of the messsage to send. | ||
| channelId | string |
The id of the channel | group | DM to send this message to. |
| [optCb] | function |
Helper for updating a sent message via the ‘chat.update’ API call
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type | Description |
|---|---|---|
| message | object |
message The message object to be updated, see /lib/clients/web/facets/chat.js for more details |
| [optCb] | function |
Optional callback |
Sends a typing indicator to indicate that the user with activeUserId is typing.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type | Description | ||
|---|---|---|---|---|
| channelId | string |
The id of the channel | group | DM to send this message to. |
Subscribes this socket to presence changes for only the given userIds.
This requires presence_sub to have been passed as an argument to start.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type | Description |
|---|---|---|
| userIds | Array |
The user IDs to subscribe to |
Sends a message over the websocket to the server.
Kind: instance method of [RTMClient](#RTMClient)
| Param | Type | Description |
|---|---|---|
| message | \* |
The message to send back to the server. |
| [optCb] | function |