Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Typing Indicator


(error)

Danger

Programmable Chat has been deprecated and is no longer supported. Instead, we'll be focusing on the next generation of chat: Twilio Conversations. Find out more about the EOL process here(link takes you to an external page).

If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.

The Programmable Chat Typing Indicator feature enables typing signals to be sent for Members from their client endpoints when they are typing within a Channel.

These signals are then sent to all other connected Members of the Channel, allowing for UI features to be implemented, such as showing "User is typing" style messages or indicators for Channel Members. Typing is always within the context of a Channel and a Member.

The Typing Indicator feature follows a producer/consumer model, with the Chat SDKs exposing API methods to set when the User is typing in a Channel. This is signaled via Chat in real time to other Members of the Channel, where events are fired for the typing event.

Table of contents:


Sending Typing Indicator

typing-indicator-send page anchor

The Chat Typing Indicator is always in relation to a Channel - allowing Typing to be correctly indicated within the Channel where the Member is typing.

Note: The Typing Indicator signal is not automatically sent by Chat. The Typing Indicator must be explicitly sent using the relevant SDK API methods.

Note: To optimise network traffic, Chat client endpoints will only send a Typing signal once every 5 seconds by default, even if the Typing API command is called more frequently. The send threshold value can be configured for a Service instance by setting the TypingIndicatorTimeout property of the Services resource. Note that reducing this value will cause more network traffic to be generated by client endpoints calling the Typing API.

To send the Typing Indicator, the following code can be used:

Sending the Typing Indicator

sending-the-typing-indicator page anchor

_10
// intercept the keydown event
_10
inputBox.on('keydown', function(e) {
_10
// if the RETURN/ENTER key is pressed, send the message
_10
if (e.keyCode === 13) {
_10
sendButton.click();
_10
} else {
_10
// else send the Typing Indicator signal
_10
activeChannel.typing();
_10
}
_10
});


Consuming Typing Indicator

typing-indicator-consume page anchor

In order to display the Typing Indicator when other Members are typing within a Channel, the Typing Indicator Events must be consumed and processed on the clients. This is done by listening for the relevant Typing Indicator events/callbacks and processing these appropriately.

Note: The Typing Indicator signal is not automatically sent by Programmable Chat. Typing events will not be received if the Member does not send them explicitly (see the previous section).

Here is an example of listening for the Typing event and then processing this to display a "typing" message for the relevant Member:


_11
//set up the listener for the typing started Channel event
_11
activeChannel.on('typingStarted', function(member) {
_11
//process the member to show typing
_11
updateTypingIndicator(member, true);
_11
});
_11
_11
//set the listener for the typing ended Channel event
_11
activeChannel.on('typingEnded', function(member) {
_11
//process the member to stop showing typing
_11
updateTypingIndicator(member, false);
_11
});

Next: Message Consumption Horizon


Rate this page: