Top of pageSkip to main content

Chat


Chats can be sent during a session to and from all participants or select participants.

On this page

Init chat

After joining a session, call client.getChatClient() to get the chat client.

const chat = client.getChatClient()

Send chats

To send a chat to a specific participant, call the chat.send() function.

 chat.send('Hey participant', userId)

To send a chat to all participants, call the chat.sendToAll() function.

chat.sendToAll('Hey everyone')

Receive chats

To receive chats sent from other participants, use the chat-on-message event listener.

client.on('chat-on-message', (payload) => {
  console.log(payload)
  console.log(`Message: ${payload.message}, from ${payload.sender.senderName} to ${payload.receiver.receiverName}`)
})

Get chat history

To get the chat history for chats sent to everyone in the session, call the chat.getHistory() function. This returns chats that were sent and received while the user was in the session.

chat.getHistory()

For the full set of chat features, see the Video SDK Reference.

Next Steps

Need help?

If you're looking for help, try Developer Support or our Developer Forum. Priority support is also available with Premier Developer Support plans.