Typing Indicators

Typing indicators allow you to display whether a user is typing in a particular channel.

Send start and stop typing indicators

// user is typing
chat.sendTypingIndicator({ 
    channelId: "alpha",
    isTyping: true
});

// user submits message and has stopped typing
chat.sendTypingIndicator({
    channelId: "alpha",
    isTyping: false
});

sendTypingIndicator({ channelId: string, isTyping: boolean })

Name

Type

Required

Description

channelId

string

yes

The id of the channel associated with the typing event

isTyping

boolean

yes

true /false

Listen for start and stop typing events

chat.addEventListener((event) => {
    switch (event.type) {
        case "typing.start":
            const { channelId, userId, deviceId } = event.data;
            // Update UI to show a user is typing...
            break;
        case "typing.stop":
            const { channelId, userId, deviceId } = event.data;
            // Update UI to show that user has stopped typing.
            break;
        default:
    }
});

The userId and deviceId used to initialize the Chat class are the values that will be included in the typing.start and typing.stop events.

Last updated

Logo

© Copyright 2024 ALO.ai, Inc. • All Rights Reserved