User started chat session
This function is triggered when a user starts a new chat session. You can think of starting a chat session like entering a chat room. Inside this function, you can add custom logic for any actions that occur when a user has joined a chat channel.
async function handleEvent(event: UserStartedChatSessionEvent, context: Context) {
}
The above function takes two parameters:
-
The event object which in this case is the
UserStartedChatSessionEventobject. This object has four properties:user: The user who started the chat session.channel: The channel in which the session was started.channelUnread: This property has the type and tells us if the user has any unread messages in the channel in which a new chat session was started. It is true if the user has any unread messages in the channel and false if there are no unread messages.channelMessagesCount: The number of messages sent in this channel.
-
A
Contextobject.
note
This is a non-blocking chat function.