Menu

Expand
Rate this page:

Typing Indicator

The Conversations Typing Indicator feature enables typing signals to be sent for Participants from their client endpoints when they are typing within a Conversation.

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

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

Sending Typing Indicator

The Conversations Typing Indicator is always in relation to a Conversation - allowing Typing to be correctly indicated within the Conversation where the Participant is typing.

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

To optimise network traffic, Conversations 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 from a web-based front end, the following Javascript code can be used:

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

Consuming Typing Indicator

In order to display the Typing Indicator when other Participants are typing within a Conversation, 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.

The Typing Indicator signal is not automatically sent by Conversations. Typing events will not be received if the Participant does not send them explicitly (see the section above on Receiving typing indicators.

Here is an example of listening for the Typing event and then processing this to display a "typing" message for the relevant Participant. You would implement your own updateTypingIndicator method:

//set up the listener for the typing started Conversation event
activeConversation.on('typingStarted', function(participant) {
    //process the participant to show typing
    updateTypingIndicator(participant, true);
});

//set  the listener for the typing ended Conversation event
activeConversation.on('typingEnded', function(participant) {
    //process the participant to stop showing typing
    updateTypingIndicator(participant, false);
});

What's Next?

Continue learning with the following guides:

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Loading Code Sample...
        
        
        

        Thank you for your feedback!

        Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        thanks-feedback-gif