Chat

Chat is is designed to support in-session text communication. Zoom truncates messages exceeding a binary size of 10,000 bytes. As a best practice, we recommend a limit of 1000 characters per message.

While in a session, users can send chat messages to other users who are also in the session.

The following two main components within the SDK will help you implement in-session message features:

  • The chatNewMessageNotify event is triggered when a new message is sent or received. This callback confirms the delivery of the message.
  • An instance of ZoomVideoSDKChatHelper provides methods that can be used to send and receive messages in a session running on your app.

Send messages

There are two different forms of chat in a session: public and private. A private message is sent to a specific user in the session and a public message is sent to all users present in the session.

Before sending a private message to a specific user, you must verify that private chat is enabled in your session and obtain the user you would like to send the message to.

  1. Obtain an instance of the ZoomVideoSDKChatHelper object.

    const chatHelper = zoom.chatHelper;
    
  2. Check if chat is disabled prior to setting up chat-related components.

    chatHelper.isChatDisabled;
    
  3. Send a Private Chat Message

    if (chatHelper.isPrivateChatDisabled) {
        // You cannot send user-specific messages
    } else {
        chatHelper.sendChatToUser(user, "This is a private message");
    }
    
  4. Send a Public Chat Message

    chatHelper.sendChatToAll("This is a public message");
    

Receive messages

Whenever a chat message is received, the most important pieces of data to make note of are the sender and the content of the message.

You can use this information to display the sender information such as the user name and content of the message to the message recipient(s) in your UI.

Get notified when a chat message is received

chatNewMessageNotify(messageItem: any) => {
  const content = messageItem.content;
  const sender = messageItem.senderUser;
  const senderName = sender.userName;
}

For more information on how to use the ZoomVideoSDKUserInfo object, see the manager user information documentation in the reference.

Message item definitions

Here are some message item definitions to make note of while using the ZoomVideoSDKChatMessage:

  • messageItem.isChatToAll; returns false for private messages.
  • messageItem.isSelfSend; returns true if current user sent the message.
  • messageItem.timestamp; is the time at which the message was sent.
  • messageItem.receiverUser; is the recipient for a private message.