Slack Developer Kit for Node.js
An RTMClient allows programs to communicate with the Slack Platform’s RTM API. This object uses the EventEmitter pattern to dispatch incoming events and has several methods for sending outgoing messages.
Kind: static class of @slack/client
Extends: EventEmitter
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [connected] | boolean |
false |
Whether or not the client is currently connected to the RTM API |
| [authenticated] | boolean |
false |
Whether or not the client has authenticated to the RTM API. This occurs when the connect method completes, and a WebSocket URL is available for the client’s connection. |
| [activeUserId] | string |
The user ID for the connected client. | |
| [activeTeamId] | string |
The team ID for the workspace the client is connected to. |
EventEmitter
Promise.<(void\|module:@slack/client.RTMCallResult)>Promise.<RTMCallResult>Promise.<void>Promise.<number>Promise.<RTMCallResult>Promise.<void>Promise.<void>Promise.<(void\|module:@slack/client.RTMCallResult)>Kind: instance method of RTMClient
| Param | Type |
|---|---|
| awaitReply | boolean |
| type | string |
| body | Object.<string, any> |
Promise.<RTMCallResult>Generic method for sending an outgoing message of an arbitrary type. This method guards the higher-level methods from concern of which state the client is in, because it places all messages into a queue. The tasks on the queue will buffer until the client is in a state where they can be sent.
If the awaitReply parameter is set to true, then the returned Promise is resolved with the platform’s acknowledgement response. Not all message types will result in an acknowledgement response, so use this carefully. This promise may be rejected with an error containing code=RTMNoReplyReceivedError if the client disconnects or reconnects before recieving the acknowledgement response.
If the awaitReply parameter is set to false, then the returned Promise is resolved as soon as the message is sent from the websocket.
Kind: instance method of RTMClient
| Param | Type | Description |
|---|---|---|
| awaitReply | "undefined" |
whether to wait for an acknowledgement response from the platform before resolving the returned Promise. |
| type | string |
the message type |
| body | Object.<string, any> |
the message body |
Promise.<void>Kind: instance method of RTMClient
| Param | Type |
|---|---|
| awaitReply | "undefined" |
| type | string |
| body | Object.<string, any> |
End an RTM session. After this method is called no messages will be sent or received unless you call start() again later.
Kind: instance method of RTMClient
Promise.<number>Generic method for sending an outgoing message of an arbitrary type. The main difference between this method and
addOutgoingEvent() is that this method does not use a queue so it can only be used while the client is ready
to send messages (in the ‘ready’ substate of the ‘connected’ state). It returns a Promise for the message ID of the
sent message. This is an internal ID and generally shouldn’t be used as an identifier for messages (for that,
there is ts on messages once the server acknowledges it).
Kind: instance method of RTMClient
| Param | Type | Description |
|---|---|---|
| type | string |
the message type |
| body | the message body |
Promise.<RTMCallResult>Send a simple message to a public channel, private channel, DM, or MPDM.
Kind: instance method of RTMClient
| Param | Type | Description |
|---|---|---|
| text | string |
The message text. |
| conversationId | string |
A conversation ID for the destination of this message. |
Kind: instance method of RTMClient
| Param | Type |
|---|---|
| text | string |
| conversationId | string |
| callback | RTMCallResultCallback |
Kind: instance method of RTMClient
| Param | Type |
|---|---|
| text | string |
| conversationId | string |
| callback | RTMCallResultCallback |
Promise.<void>Sends a typing indicator to indicate that the user with activeUserId is typing.
Kind: instance method of RTMClient
| Param | Type | Description |
|---|---|---|
| conversationId | string |
The destination for where the typing indicator should be shown. |
Begin an RTM session using the provided options. This method must be called before any messages can be sent or received.
Kind: instance method of RTMClient
| Param | Type |
|---|---|
| options | module:@slack/client/dist/methods.TokenOverridable | module:@slack/client/dist/methods.LocaleAware | module:@slack/client/dist/methods.__type | module:@slack/client/dist/methods.TokenOverridable | module:@slack/client/dist/methods.__type |
Promise.<void>Subscribes this client to presence changes for only the given userIds.
Kind: instance method of RTMClient
| Param | Type | Description |
|---|---|---|
| userIds | Array.<string> |
An array of user IDs whose presence you are interested in. This list will replace the list from any previous calls to this method. |