The team ID for the workspace the client is connected to.
The user ID for the connected client.
An agent used to manage TCP connections for requests. Most commonly used to implement proxy support. See
npm packages tunnel
and https-proxy-agent
for information on how to construct a proxy agent.
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.
Whether this client will automatically reconnect when (not manually) disconnected
A list of cancelable Promises that each represent a caller waiting on the server to acknowledge an outgoing message with a response (an incoming message containing a "reply_to" property with the outgoing message's ID). This list is emptied by canceling all the promises when the client no longer expects to receive any replies from the server (when its disconnected or when its reconnected and doesn't expect replies for past outgoing messages). The list is a sparse array, where the indexes are message IDs for the sent messages.
Whether or not the client is currently connected to the RTM API
The instance of KeepAlive used to monitor this client's connection.
This object's logger instance
The last message ID used for an outgoing message
Atomically increments and returns a message ID for the next message.
onmessage
handler for the client's websocket. This will parse the payload and dispatch the relevant events for
each incoming message.
A queue of tasks used to serialize outgoing messages and to allow the client to buffer outgoing messages when its not in the 'ready' state. This queue is paused and resumed as the state machine transitions.
The number of milliseconds to wait upon connection for reply messages from the previous connection. The default value is 2 seconds.
Set up method for the client's websocket instance. This method will attach event listeners.
A cache of the options used to start the connection, so that it can be reused during reconnections.
State machine that backs the transition and action behavior
Configuration for the state machine
Tear down method for the client's websocket instance. This method undoes the work in setupWebsocket(url).
Configuration for custom TLS handling
Use the rtm.connect
method to connect when true, or the rtm.start
method when false
Internal use web client
The client's websocket
The name used to prefix all logging generated from this object
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 receiving 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.
whether to wait for an acknowledgement response from the platform before resolving the returned Promise.
the message type
the message body
End an RTM session. After this method is called no messages will be sent or received unless you call start() again later.
Calls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Add a listener for a given event.
Add a one-time listener for a given event.
Remove all listeners, or those of the specified event.
Remove the listeners of a given event.
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).
the message type
the message body
Send a simple message to a public channel, private channel, DM, or MPDM.
The message text.
A conversation ID for the destination of this message.
Sends a typing indicator to indicate that the user with activeUserId
is typing.
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.
Subscribes this client to presence changes for only the given userIds
.
An array of user IDs whose presence you are interested in. This list will replace the list from any previous calls to this method.
Generated using TypeDoc
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.