Typing Indicators

All official SDKs support typing events out of the box and are handled on all channels with the typing_events featured enabled. Typing indicators allow you to show to users who is currently typing in the channel. This feature can be switched on/off on a channel-type basis using the CLI or directly from the Dashboard. If you are using one of the official SDK libraries, you will only need to ensure that typing indicators are enabled to get this working.

If you are building your UI on top of one of our Chat Clients instead, you will need to take care of four things:

  1. Send an event typing.start when the user starts typing

  2. Send an event typing.stop after the user stopped typing

  3. Handle the two events and use them to toggle the typing indicator UI

  4. Use parent_id field of the event to indicate that typing is happening in a thread

Sending start and stop typing events

// The Unreal SDK keeps track of the typing state for you.
// Just call `Channel->Keystroke()` when the user types and
// `Channel->StopTyping()` when the user sends the message (or aborts)

// Sends a typing.start event at most once every two seconds,
// and a typing.stop event two seconds after the last keystroke
Channel->KeyStroke();

// Manually sends the typing.stop event, and cancels any pending
// typing.stop event queued by Keystroke()
Channel->StopTyping();

When sending events on user input, you should make sure to follow some best-practices to avoid bugs.

  1. Only send typing.start when the user starts typing

  2. Send typing.stop after a few seconds since the last keystroke

Receiving typing indicator events

// You can manually subscribe to the typing channel events
Channel->On<FTypingStartEvent>(this, &UMyWidget::OnTypingStart);
Channel->On<FTypingStopEvent>(this, &UMyWidget::OnTypingStop);

// Alternatively you can bind to the OnTypingIndicator delegate (also from Blueprints)
Channel->OnTypingIndicator.AddDynamic(this, &UMyWidget::OnTypingIndicator);

Because clients might fail at sending typing.stop event all Chat clients periodically prune the list of typing users.

Control typing events delivery by modifying user privacy settings

Please take into account that typing.start and typing.stop events delivery can be controlled by user privacy settings:

// user object with privacy settings where typing indicators are disabled
{
  // other user fields
  "privacy_settings": {
    "typing_indicators": {
      "enabled": false
    }
  }
}

If privacy_settings.typing_indicators.enabled is set to false, then typing.start and typing.stop events will be ignored for this user by Stream’s server and these events will not be sent to other users. In other words other users will not know that the current user was typing.

© Getstream.io, Inc. All Rights Reserved.