# Use in-meeting chat > The code on this page works with either the **default UI** or the **custom UI**. The Meeting SDK lets you use [in-meeting chat](https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0064400) to communicate with other participants in the same meeting. Handle chat functionality through the `InMeetingChatController` interface. ```kotlin ZoomSDK.getInstance().inMeetingService.inMeetingChatController ``` ```java InMeetingChatController chatController = ZoomSDK.getInstance().getInMeetingService().getInMeetingChatController(); ``` ## Control chat settings Before you use in-meeting chat, check if the current meeting or webinar supports chat, and then look at which participants or attendees can use chat. ### Chat settings in a meeting In a meeting, use `meetingAttendeeChatPrivilege`. ```kotlin if (!chatController.isChatDisabled) { val chatPrivilege = chatController.meetingAttendeeChatPrivilege } ``` ```java if (!chatController.isChatDisabled()) { InMeetingChatController.MobileRTCMeetingChatPriviledge chatPriviledge = chatController.getMeetingAttendeeChatPrivilege(); } ``` The `meetingAttendeeChatPrivilege` uses one of these values. - `No_One` - No participants may use chat. - `Host_Only` - Only the host of the meeting may use chat. - `Everyone_Publicly` - All participants may use chat, but private messages are not allowed. - `Everyone_Publicly_And_Privately` - All participants may use chat to send both private and public messages. - `Invalid` - Meeting chat privilege is not applicable to the current meeting. If the current user is the meeting's host, they can control chat settings by specifying a `MobileRTCMeetingChatPriviledge`. ```kotlin chatController.changeAttendeeChatPriviledge(InMeetingChatController.MobileRTCMeetingChatPriviledge.Everyone_Publicly_And_Privately) chatController.changeAttendeeChatPriviledge(InMeetingChatController.MobileRTCMeetingChatPriviledge.No_One) ``` ```java chatController.changeAttendeeChatPriviledge(InMeetingChatController.MobileRTCMeetingChatPriviledge.Everyone_Publicly_And_Privately); chatController.changeAttendeeChatPriviledge(InMeetingChatController.MobileRTCMeetingChatPriviledge.No_One); ``` ### Chat settings in a webinar In a webinar, use `webinarAttendeeChatPrivilege`. ```kotlin val chatPrivilege = chatController.webinarAttendeeChatPrivilege ``` ```java InMeetingChatController.MobileRTCWebinarChatPriviledge chatPriviledge = chatController.getWebinarAttendeeChatPrivilege(); ``` The `webinarAttendeeChatPrivilege` uses one of these values. - `No_One` - No attendees may use chat. - `All_Panelists` - Only panelists may use chat. - `All_Panelists_And_Attendees` - All panelists and attendees may use chat. - `Invalid` - Webinar chat privilege is not applicable to the current webinar. Update a webinar's chat settings by setting a `MobileRTCWebinarPanelistChatPrivilege`. ```kotlin chatController.panelistChatPrivilege = InMeetingChatController.MobileRTCWebinarPanelistChatPrivilege.ChatPrivilege_All chatController.panelistChatPrivilege = InMeetingChatController.MobileRTCWebinarPanelistChatPrivilege.ChatPrivilege_AllPanelist ``` ```java chatController.setPanelistChatPrivilege(InMeetingChatController.MobileRTCWebinarPanelistChatPrivilege.ChatPrivilege_All); chatController.setPanelistChatPrivilege(InMeetingChatController.MobileRTCWebinarPanelistChatPrivilege.ChatPrivilege_AllPanelist); ``` ## Send messages To send a public message in either a meeting or a webinar, instantiate a `ChatMessageBuilder` and set the content and message type. ```kotlin val chatMessage = ChatMessageBuilder() .setContent("This is a sample message.") .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_All) .build() chatController.sendChatMsgTo(chatMessage) ``` ```java InMeetingChatMessage chatMessage = new ChatMessageBuilder() .setContent("This is a sample message") .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_All) .build(); chatController.sendChatMsgTo(chatMessage); ``` For private messages, change the message type to `ZoomSDKChatMessageType_To_Individual` and include a receiver ID to specify the message recipient. ```kotlin val privateMessage = ChatMessageBuilder() .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_Individual) .setContent("This is a sample private message") .setReceiver(userId) .build() chatController.sendChatMsgTo(privateMessage) ``` ```java InMeetingChatMessage privateMessage = new ChatMessageBuilder() .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_Individual) .setContent("This is a sample private message") .setReceiver(userId) .build(); chatController.sendChatMsgTo(privateMessage); ``` To reply to an existing message in a thread, first get a `threadId` for the message being responded to. For more information on how to get the `threadId`, see [Receive messages](#receive-messages). Once you've retrieved the thread ID, pass it in and set the type based on whether the parent message is public or private. ```kotlin val threadId = msg?.threadId val threadReplyMessage = ChatMessageBuilder() .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_All) .setThreadId(threadId) .setContent("This is a sample message reply to a thread.") .build() chatController.sendChatMsgTo(threadReplyMessage) ``` ```java InMeetingChatMessage threadReplyMessage = new ChatMessageBuilder() .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_All) .setThreadId(threadId) .setContent("This is a sample message reply to a thread.") .build(); chatController.sendChatMsgTo(threadReplyMessage); ``` Messages sent from the SDK can also include quoted text. The quote position specifies the start and end characters in the quoted text string. ```kotlin val quotedMessage = ChatMessageBuilder() .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_All) .setQuotePosition(0, 42) .setContent("This is a sample message stylized as a quote") .build() chatController.sendChatMsgTo(quotedMessage) ``` ```java InMeetingChatMessage quotedMessage = new ChatMessageBuilder() .setMessageType(ZoomSDKChatMessageType.ZoomSDKChatMessageType_To_All) .setQuotePosition(0, 42) .setContent("This is a sample message stylized as a quote") .build(); chatController.sendChatMsgTo(quotedMessage); ``` ## Receive messages To display content from chat messages, the SDK provides a callback to get notified of when a new message is sent to the meeting. You can also use this callback to confirm that a message sent by the current user has successfully been posted to the meeting chat. Use the `msg` parameter within `InMeetingChatListener#onChatMesageReceived` to get information about the chat message. Some data, like `receiverUserId`, will only be available for specific types of messages. ```kotlin val messageListener = object : InMeetingListener() { ... override fun onChatMessageReceived(msg: InMeetingChatMessage?) { msg?.content // The content of the message that is visible to users in the meeting. msg?.chatMessageType // The message type (See "Send Messages"). msg?.isChatToAll // Whether the chat message is public. msg?.msgId // A unique identifier assigned to this message. msg?.isChatToWaitingroom // Whether the message was sent to the waiting room. msg?.isChatToAllPanelist // Whether the chat message was sent to the webinar panelists. msg?.isComment // Whether the chat message is a comment responding to a thread. msg?.isThread // Whether the chat message is a thread with comments. msg?.receiverDisplayName // The display name of the user on the receiving end of a private message. msg?.receiverUserId // The Zoom user ID of the user on the receiving end of a private message. msg?.senderDisplayName // The display name of the user who sent the message. msg?.senderUserId // The Zoom user ID of the user who sent the message. msg?.threadId // The unique identifier associated with a thread msg?.time // The time at which the message was sent. } } ZoomSDK.getInstance().inMeetingService.addListener(messageListener) ``` ```java @Override public void onChatMessageReceived(@Nullable InMeetingChatMessage msg) { if (msg != null) { msg.getContent(); msg.getChatMessageType(); msg.isChatToAll(); msg.getMsgId(); msg.isChatToWaitingroom(); msg.isChatToAllPanelist(); msg.isComment(); msg.isThread(); msg.getReceiverDisplayName(); msg.getReceiverUserId(); msg.getSenderDisplayName(); msg.getSenderUserId(); msg.getThreadId(); msg.getTime(); } } ``` ## Delete messages To delete a message sent by the current user, use the `msgId`. ```kotlin chatController.deleteChatMessage(messageId) ``` ```java chatController.deleteChatMessage(messageId); ``` ## Parse text format The SDK supports receiving various styles of chat messages. The styles are included as a list of `IRichTextStyleItem` objects. These items contain two components: a `RichTextStyle` enum indicating the type of style, and a list of `IRichTextStyleOffset`s describing ranges including each style. ```kotlin val styles = msg?.textStyleItemList styles?.forEach { val styleType = it.textStyle it.textStyleOffsetList.forEach {offset -> offset.positionStart offset.positionEnd } } ``` ```java List styles = msg.getTextStyleItemList(); for (IRichTextStyleItem style : styles) { for (IRichTextStyleOffset offset : style.getTextStyleOffsetList()) { offset.getPositionStart(); offset.getPositionEnd(); } } ``` ---