diff --git a/docs.json b/docs.json
index 3ae3cdbf0..0edf9dff2 100644
--- a/docs.json
+++ b/docs.json
@@ -2528,7 +2528,12 @@
},
{
"group": "Setup",
- "pages": ["sdk/javascript/setup-sdk"]
+ "pages": [
+ "sdk/javascript/setup-sdk",
+ "sdk/javascript/installation",
+ "sdk/javascript/initialization",
+ "sdk/javascript/ssr-compatibility"
+ ]
},
{
"group": "Authentication",
@@ -2607,6 +2612,7 @@
},
"sdk/javascript/ai-moderation",
"sdk/javascript/ai-agents",
+ "sdk/javascript/ai-integration-quick-reference",
{
"group": "Resources",
"pages": [
@@ -2623,6 +2629,14 @@
"sdk/javascript/managing-web-sockets-connections-manually"
]
},
+ {
+ "group": "Reference",
+ "pages": [
+ "sdk/reference/messages",
+ "sdk/reference/entities",
+ "sdk/reference/auxiliary"
+ ]
+ },
{
"group": "UI Kits",
"pages": [
@@ -2631,6 +2645,9 @@
"sdk/javascript/angular-overview"
]
},
+
+ "sdk/javascript/best-practices",
+ "sdk/javascript/troubleshooting",
"sdk/javascript/extensions-overview",
"sdk/javascript/ai-user-copilot-overview",
"sdk/javascript/ai-chatbots-overview",
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
deleted file mode 100644
index b9f3c6ed9..000000000
--- a/node_modules/.package-lock.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "docs",
- "lockfileVersion": 3,
- "requires": true,
- "packages": {
- "node_modules/22": {
- "version": "0.0.0",
- "resolved": "https://registry.npmjs.org/22/-/22-0.0.0.tgz",
- "integrity": "sha512-MdBPNDaCFY4fZVpp14n3Mt4isZ2yS1DrIiOig/iMLljr4zDa0g/583xf/lFXNPwhxCfGKYvyWJSrYyS8jNk2mQ==",
- "license": "MIT"
- }
- }
-}
diff --git a/node_modules/22/README.md b/node_modules/22/README.md
deleted file mode 100644
index 311c8dd06..000000000
--- a/node_modules/22/README.md
+++ /dev/null
@@ -1 +0,0 @@
-PLACEHOLDER
\ No newline at end of file
diff --git a/node_modules/22/package.json b/node_modules/22/package.json
deleted file mode 100644
index f3cf8f650..000000000
--- a/node_modules/22/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "22",
- "version": "0.0.0",
- "description": "PLACEHOLDER",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "Houfeng",
- "license": "MIT"
-}
diff --git a/package-lock.json b/package-lock.json
deleted file mode 100644
index e374029e1..000000000
--- a/package-lock.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "docs",
- "lockfileVersion": 3,
- "requires": true,
- "packages": {
- "": {
- "dependencies": {
- "22": "^0.0.0"
- }
- },
- "node_modules/22": {
- "version": "0.0.0",
- "resolved": "https://registry.npmjs.org/22/-/22-0.0.0.tgz",
- "integrity": "sha512-MdBPNDaCFY4fZVpp14n3Mt4isZ2yS1DrIiOig/iMLljr4zDa0g/583xf/lFXNPwhxCfGKYvyWJSrYyS8jNk2mQ==",
- "license": "MIT"
- }
- }
-}
diff --git a/package.json b/package.json
deleted file mode 100644
index 08836e674..000000000
--- a/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "dependencies": {
- "22": "^0.0.0"
- }
-}
diff --git a/sdk/javascript/additional-message-filtering.mdx b/sdk/javascript/additional-message-filtering.mdx
index 6648ba35e..7f89e548a 100644
--- a/sdk/javascript/additional-message-filtering.mdx
+++ b/sdk/javascript/additional-message-filtering.mdx
@@ -1,35 +1,61 @@
---
title: "Additional Message Filtering"
+sidebarTitle: "Additional Filtering"
+description: "Advanced filtering options for fetching messages using MessagesRequestBuilder in the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Filter by category and type
+let messagesRequest = new CometChat.MessagesRequestBuilder()
+ .setUID("UID")
+ .setCategories(["message"])
+ .setTypes(["image", "video", "audio", "file"])
+ .setLimit(50)
+ .build();
-The `MessagesRequest` class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the `MessagesRequest` class.
-
-The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class.
+// Unread messages only
+let messagesRequest = new CometChat.MessagesRequestBuilder()
+ .setUID("UID")
+ .setUnread(true)
+ .setLimit(50)
+ .build();
-The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched.
+// Threaded messages
+let messagesRequest = new CometChat.MessagesRequestBuilder()
+ .setUID("UID")
+ .setParentMessageId(parentId)
+ .setLimit(50)
+ .build();
-Steps to generate an object of the MessagesRequest class:
+// Fetch with pagination
+messagesRequest.fetchPrevious().then(messages => { });
+messagesRequest.fetchNext().then(messages => { });
+```
-1. Create an object of the `MessagesRequestBuilder` class.
-2. Set all the parameters you wish to set.
-3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class.
+**Key methods:** `setUID()`, `setGUID()`, `setLimit()`, `setCategories()`, `setTypes()`, `setTags()`, `setUnread()`, `setParentMessageId()`, `setMessageId()`, `setTimestamp()`, `hideReplies()`, `hideDeletedMessages()`
+
-Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object.
+The `MessagesRequest` class fetches messages based on various parameters. It uses the Builder design pattern via `MessagesRequestBuilder`.
-1. fetchNext() - Calling this method will return the messages after the specified parameters.
-2. fetchPrevious() - Calling this method will give you messages before the specified parameters.
+To fetch messages:
+1. Create a `MessagesRequestBuilder` object
+2. Set your desired parameters
+3. Call `build()` to get a `MessagesRequest` object
+4. Call `fetchNext()` or `fetchPrevious()` to retrieve messages
-Since messages are obtained in a paginated manner, a `maximum of 100` messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages.
+| Method | Description |
+| --- | --- |
+| `fetchNext()` | Returns messages after the specified parameters |
+| `fetchPrevious()` | Returns messages before the specified parameters |
-Now that you are clear how to use the `MessagesRequest` class, below are the various options available:
+Messages are paginated with a maximum of 100 per request. Call `fetchPrevious()`/`fetchNext()` repeatedly on the same object to get subsequent pages.
## Number of messages fetched
-*In other words, how do I set the number of messages fetched in a single iteration*
-
-To achieve this, you can use the `setLimit()` method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is `100`.
+Set the number of messages to fetch per request using `setLimit()`. Maximum is 100.
@@ -53,9 +79,7 @@ let messagesRequest: CometChat.MessagesRequest =
## Messages for a user conversation
-*In other words, how do I fetch messages between me and any user*
-
-This can be achieved using the `setUID()` method. This method takes the UID of the user with whom the conversation is to be fetched. When a valid UID is passed, the SDK will return all the messages that are a part of the conversation between the logged-in user and the UID that has been specified.
+Use `setUID()` to fetch messages between the logged-in user and a specific user.
@@ -80,11 +104,15 @@ let messagesRequest: CometChat.MessagesRequest =
-## Messages for a group conversation
+When messages are fetched successfully, the response includes an array of message objects.
+
+
+The examples on this page use a small `setLimit()` value for brevity. In production, use a higher limit (up to 100) for efficient pagination.
+
-*In other words, how do I fetch messages for any group conversation*
+## Messages for a group conversation
-You can achieve this using the `setGUID()` method. This method takes the GUID of a group for which the conversations are to be fetched. Passing a valid GUID to this method will return all the messages that are a part of the group conversation. Please note that the logged-in user must be a member of the group to fetch the messages for that group.
+Use `setGUID()` to fetch messages from a group. The logged-in user must be a member of the group.
@@ -109,17 +137,15 @@ let messagesRequest: CometChat.MessagesRequest =
-
-
-If none of the above two methods `setUID()` and `setGUID()` is used, all the messages for the logged-in user will be fetched. This means that messages from all the one-on-one and group conversations which the logged-in user is a part of will be returned.> All the parameters discussed below can be used along with the setUID() or setGUID() or without any of the two to fetch all the messages that the logged-in user is a part of.
+When messages are fetched successfully, the response includes an array of message objects.
+
+If neither `setUID()` nor `setGUID()` is used, all messages for the logged-in user across all conversations will be fetched. All parameters below can be combined with `setUID()` or `setGUID()`.
## Messages before/after a message
-*In other words, how do I fetch messages before or after a particular message*
-
-This can be achieved using the `setMessageId()` method. This method takes the message-id as input and provides messages only after/before the message-id based on if the fetchNext() or fetchPrevious() method is triggered.
+Use `setMessageId()` to fetch messages before or after a specific message ID. Use `fetchNext()` to get messages after, or `fetchPrevious()` to get messages before.
@@ -182,13 +208,11 @@ let GUID: string = "GUID",
-This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific message-id for a particular user/group conversation.
+This method can be combined with `setUID()` or `setGUID()` to fetch messages around a specific message in a conversation.
## Messages before/after a given time
-*In other words, how do I fetch messages before or after a particular date or time*
-
-You can easily achieve this using the `setTimestamp()` method. This method takes the Unix timestamp as input and provides messages only after/before the timestamp based on if fetchNext() or fetchPrevious() method is triggered.
+Use `setTimestamp()` with a Unix timestamp to fetch messages before or after a specific time.
@@ -251,13 +275,11 @@ let GUID: string = "GUID",
-This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific date or time for a particular user/group conversation.
+This method can be combined with `setUID()` or `setGUID()` to fetch messages around a specific time in a conversation.
## Unread messages
-*In other words, how do I fetch unread messages*
-
-This can easily be achieved using setting the unread flag to true. For this, you need to use the `setUnread()` method. This method takes a boolean value as input. If the value is set to true, the SDK will return just the unread messages.
+Use `setUnread(true)` to fetch only unread messages.
@@ -316,13 +338,11 @@ let GUID: string = "GUID",
-This method along with `setGUID()` or `setUID()` can be used to fetch unread messages for a particular group or user conversation respectively.
+Combine with `setGUID()` or `setUID()` to fetch unread messages for a specific conversation.
## Exclude messages from blocked users
-*In other words, how do I fetch messages excluding the messages from the users I have blocked*
-
-This can be easily achieved using the `hideMessagesFromBlockedUsers()` method. This method accepts a boolean value which determines if the messages from users blocked by the logged-in user need to be a part if the fetched messages. If the value is set to true, the messages will be hidden and won't be a part of the messages fetched. The default value is false i.e if this method is not used, the messages from blocked users will be included in the fetched messages.
+Use `hideMessagesFromBlockedUsers(true)` to exclude messages from users you've blocked. Default is `false`.
@@ -381,13 +401,11 @@ let GUID: string = "GUID",
-This method can be used to hide the messages by users blocked by logged in user in groups that both the members are a part of.
+This also works in group conversations where both users are members.
## Updated and received messages
-*In other words, how do I fetch messages that have been received or updated after a particular date or time*
-
-This method accepts a Unix timestamp value and will return all the messages that have been updated and the ones that have been sent/received after the specified time. The messages updated could mean the messages that have been marked as read/delivered or if the messages are edited or deleted.
+Use `setUpdatedAfter()` with a Unix timestamp to fetch messages that were sent or updated after a specific time. Updated messages include those marked as read/delivered, edited, or deleted.
@@ -450,13 +468,11 @@ let GUID: string = "GUID",
-This can be useful in finding the messages that have been received or updated after a certain time. Can prove very useful if you are saving the messages locally and would like to know the messages that have been updated or received after the last message available in your local databases.
+Useful for syncing messages with a local database — fetch only what's changed since your last sync.
## Updated messages only
-*In other words, how do I fetch messages that have been updated after a particular date or time*
-
-This can be achieved easily by setting the updatesOnly parameter to true. To do so, you can use the updatesOnly() method. This method takes a boolean input and can be used with the `setUpdatedAfter()` method to get jus the updated messages and not the messages sent/received after the specified time. This method cannot be used independently and always needs to be used with the `setUpdatedAfter()` method.
+Use `updatesOnly(true)` with `setUpdatedAfter()` to fetch only updated messages (not newly received ones). This method must be used together with `setUpdatedAfter()`.
@@ -523,13 +539,11 @@ let GUID: string = "GUID",
-## Messages for multiple categories
+When messages are fetched successfully, the response includes only messages that have been updated (edited, deleted, read/delivered status changed) after the specified timestamp.
-*In other words, how do I fetch messages belonging to multiple categories*
-
-We recommend before trying this, you refer to the [Message structure and hierarchy guide](/sdk/javascript/message-structure-and-hierarchy) to get familiar with the various categories of messages.
+## Messages for multiple categories
-For this, you will have to use the `setCategories()` method. This method accepts a list of categories. This tells the SDK to fetch messages only belonging to these categories.
+Use `setCategories()` with an array of category names to filter by message category. See [Message structure and hierarchy](/sdk/javascript/message-structure-and-hierarchy) for available categories.
@@ -592,15 +606,11 @@ let GUID: string = "GUID",
-The above snippet will help you get only the messages belonging to the `message` and `custom` category. This can also be used to disable certain categories of messages like `call` and `action`.
+The above snippet fetches only messages in the `message` and `custom` categories. Use this to exclude categories like `call` and `action`.
## Messages for multiple types
-*In other words, how do I fetch messages belonging to multiple types*
-
-We recommend before trying this, you refer to the [Message structure and hierarchy guide](/sdk/javascript/message-structure-and-hierarchy) to get familiar with the various types of messages.
-
-This can be easily achieved using the `setTypes()` method. This method accepts a list of types. This tells the SDK to fetch messages only belonging to these types.
+Use `setTypes()` with an array of type names to filter by message type. See [Message structure and hierarchy](/sdk/javascript/message-structure-and-hierarchy) for available types.
@@ -671,13 +681,11 @@ let GUID: string = "GUID",
-Using the above code snippet, you can fetch all the media messages.
+The above snippet fetches all media messages (image, video, audio, file).
## Messages for a specific thread
-*In other words, how do I fetch messages that are a part of a thread and not directly a user/group conversations*
-
-This can be done using the `setParentMessageId()` method. This method needs to be used when you have implemented threaded conversations in your app. This method will return the messages only belonging to the thread with the specified parent Id.
+Use `setParentMessageId()` to fetch messages belonging to a specific thread.
@@ -740,13 +748,11 @@ let GUID: string = "GUID",
-The above code snippet returns the messages that belong to the thread with parent id 100.
+The above code returns messages belonging to the thread with the specified parent message ID.
## Hide threaded messages in user/group conversations
-*In other words, how do I exclude threaded messages from the normal user/group conversations*
-
-In order to do this, you can use the `hideReplies()` method. This method is also related to threaded conversations. This method takes boolean as input. This boolean when set to true will make sure that the messages that belong to threads are not fetched. If set to false, which is also the default value, the messages belong to the threads will also be fetched along with other messages.
+Use `hideReplies(true)` to exclude threaded messages from the main conversation. Default is `false`.
@@ -804,12 +810,9 @@ let GUID: string = "GUID",
-
## Hide deleted messages in user/group conversations
-*In other words, how do I exclude deleted messages a user/group conversations*
-
-In order to do this, you can use the `hideDeletedMessages()` method. This method takes boolean as input. This boolean when set to true will make sure that the deleted messages are not fetched. If set to false, which is also the default value, the deleted messages will also be fetched along with other messages.
+Use `hideDeletedMessages(true)` to exclude deleted messages. Default is `false`.
@@ -867,12 +870,9 @@ let GUID: string = "GUID",
-
## Hide quoted messages in user/group conversations
-*In other words, how do I exclude quoted messages in a user/group conversations*
-
-In order to do this, you can use the `hideQuotedMessages()` method. This method takes boolean as input. This boolean when set to true will make sure that the quoted messages are not fetched. If set to false, which is also the default value, the quoted messages will also be fetched along with other messages.
+Use `hideQuotedMessages(true)` to exclude quoted messages. Default is `false`.
@@ -930,12 +930,9 @@ let GUID: string = "GUID",
-
## Messages by tags
-*In other words, how do I fetch messages by tags*
-
-In order to do this, you can use the `setTags()` method. This method accepts a list of tags. This tells the SDK to fetch messages only belonging to these tags.
+Use `setTags()` with an array of tag names to fetch only messages with those tags.
@@ -997,12 +994,9 @@ let GUID: string = "GUID",
-
## Messages with tags
-*In other words, how do I fetch messages with the tags information*
-
-In order to do this, you can use the `withTags()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages along with the tags. When set to `false` , the SDK will not fetch tags associated with messages. The default value for this parameter is `false` .
+Use `withTags(true)` to include tag information in the response. Default is `false`.
@@ -1060,12 +1054,15 @@ let GUID: string = "GUID",
+When `withTags(true)` is set, each message's `tags` field will be populated. Access tags using `getTags()`.
-## Messages with links
+| Additional Field | Getter | Return Type | Description |
+| --- | --- | --- | --- |
+| tags | `getTags()` | `string[]` | Tags associated with the message |
-In other words, as a logged-in user, how do I fetch messages that contains links?
+## Messages with links
-In order to do this, you can use the `hasLinks()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have links in the text. The default value for this parameter is `false`.
+Use `hasLinks(true)` to fetch only messages containing links. Default is `false`.
@@ -1129,12 +1126,9 @@ let GUID: string = "GUID",
-
## Messages with attachments
-In other words, as a logged-in user, how do I fetch messages that contains attachments?
-
-In order to do this, you can use the `hasAttachments()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have attachments (image, audio, video or file). The default value for this parameter is `false`.
+Use `hasAttachments(true)` to fetch only messages with attachments (image, audio, video, or file). Default is `false`.
@@ -1199,11 +1193,11 @@ let GUID: string = "GUID",
-## Messages with reactions
+The response contains media message objects with attachment details including file metadata and thumbnail URLs.
-In other words, as a logged-in user, how do I fetch messages that contains reactions?
+## Messages with reactions
-In order to do this, you can use the `hasReactions()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have reactions. The default value for this parameter is `false`.
+Use `hasReactions(true)` to fetch only messages that have reactions. Default is `false`.
@@ -1268,11 +1262,11 @@ let GUID: string = "GUID",
-## Messages with mentions
+The response contains message objects with reactions. Each message's `data` object includes a `reactions` array.
-In other words, as a logged-in user, how do I fetch messages that contains mentions?
+## Messages with mentions
-In order to do this, you can use the `hasMentions()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have mentions. The default value for this parameter is `false`.
+Use `hasMentions(true)` to fetch only messages that contain mentions. Default is `false`.
@@ -1337,11 +1331,11 @@ let GUID: string = "GUID",
-## Messages with particular user mentions
+The response contains text message objects with mentions. Each message has a `mentionedUsers` array, a `mentionedMe` boolean, and a `data.mentions` object.
-In other words, as a logged-in user, how do I fetch messages that mentions specific users?
+## Messages with particular user mentions
-In order to do this, you can use the `setMentionedUIDs()` method. This method accepts an array of UIDs as input. When set, the SDK will fetch messages which have the mentions of the UIDs passed.
+Use `setMentionedUIDs()` with an array of UIDs to fetch messages that mention specific users.
@@ -1406,11 +1400,11 @@ let GUID: string = "GUID",
-## Messages with specific attachment types
+The response contains text message objects that mention the specified users.
-In other words, as a logged-in user, how do I fetch messages that contain specific types of attachments?
+## Messages with specific attachment types
-In order to do this, you can use the `setAttachmentTypes()` method. This method accepts an array of `CometChat.AttachmentType` ENUM values as input. When provided, the SDK will fetch only those messages that include attachments of the specified types (such as image, audio, video, or file).
+Use `setAttachmentTypes()` with an array of `CometChat.AttachmentType` values to fetch messages with specific attachment types.
@@ -1474,3 +1468,23 @@ let GUID: string = "GUID",
+
+The response contains media message objects filtered to the specified attachment types.
+---
+
+## Next Steps
+
+
+
+ Send text, media, and custom messages
+
+
+ Listen for incoming messages in real-time
+
+
+ Understand message categories, types, and hierarchy
+
+
+ Work with threaded conversations
+
+
diff --git a/sdk/javascript/advanced-overview.mdx b/sdk/javascript/advanced-overview.mdx
index 7a8e791f6..964125fac 100644
--- a/sdk/javascript/advanced-overview.mdx
+++ b/sdk/javascript/advanced-overview.mdx
@@ -1,8 +1,47 @@
---
title: "Advanced"
sidebarTitle: "Overview"
+description: "Advanced SDK features including connection management, real-time listeners, login listeners, and WebSocket configuration."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Check connection status
+CometChat.getConnectionStatus(); // "connected" | "connecting" | "disconnected"
+
+// Listen for connection changes
+CometChat.addConnectionListener("LISTENER_ID", new CometChat.ConnectionListener({
+ onConnected: () => console.log("Connected"),
+ onDisconnected: () => console.log("Disconnected")
+}));
+
+// Listen for login events
+CometChat.addLoginListener("LISTENER_ID", new CometChat.LoginListener({
+ onLoginSuccess: (user) => console.log("Logged in:", user),
+ onLogoutSuccess: () => console.log("Logged out")
+}));
+```
+
This section helps you to know about the Connection Listeners.
+
+---
+
+## Next Steps
+
+
+
+ Monitor and respond to connection state changes
+
+
+ Manually manage WebSocket connections
+
+
+ Listen for login and logout events
+
+
+ Complete reference for all SDK listeners
+
+
diff --git a/sdk/javascript/ai-agents.mdx b/sdk/javascript/ai-agents.mdx
index f4b88d96a..d3d998e32 100644
--- a/sdk/javascript/ai-agents.mdx
+++ b/sdk/javascript/ai-agents.mdx
@@ -1,40 +1,66 @@
---
title: "AI Agents"
+sidebarTitle: "AI Agents"
+description: "Integrate AI Agents into your app to enable intelligent, automated conversations with real-time streaming events and tool invocations."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// Listen for real-time AI Agent events (streaming)
+CometChat.addAIAssistantListener("LISTENER_ID", {
+ onAIAssistantEventReceived: (event) => console.log("Event:", event)
+});
+
+// Listen for persisted agentic messages
+CometChat.addMessageListener("LISTENER_ID", {
+ onAIAssistantMessageReceived: (msg) => console.log("Assistant reply:", msg),
+ onAIToolResultReceived: (msg) => console.log("Tool result:", msg),
+ onAIToolArgumentsReceived: (msg) => console.log("Tool args:", msg)
+});
+
+// Cleanup
+CometChat.removeAIAssistantListener("LISTENER_ID");
+CometChat.removeMessageListener("LISTENER_ID");
+```
+
+**Event flow:** Run Start → Tool Call(s) → Text Message Stream → Run Finished
+
+
# AI Agents Overview
-AI Agents enable intelligent, automated interactions within your application. They can process user messages, trigger tools, and respond with contextually relevant information. For a broader introduction, see the [AI Agents section](/ai-agents).
+AI Agents enable intelligent, automated interactions within your application. They process user messages, trigger tools, and respond with contextually relevant information. For a broader introduction, see the [AI Agents section](/ai-agents).
-> **Note:**
-> Currently, an Agent only responds to **Text Messages**.
+
+Agents only respond to text messages.
+
## Agent Run Lifecycle and Message Flow
-This section explains how a user’s text message to an Agent becomes a structured "run" which emits real-time events and then produces agentic messages for historical retrieval.
-- A user sends a text message to an Agent.
-- The platform starts a run and streams real-time events via the **`AIAssistantListener`**.
-- After the run completes, persisted Agentic Messages arrive via the **`MessageListener`**.
+When a user sends a text message to an Agent:
+1. The platform starts a run and streams real-time events via `AIAssistantListener`
+2. After the run completes, persisted Agentic Messages arrive via `MessageListener`
### Real-time Events
-Events are received via the **`onAIAssistantEventReceived`** method of the **`AIAssistantListener`** class in this general order:
-
-1. Run Start
-2. Zero or more tool call cycles (repeats for each tool invocation):
- - Tool Call Start
- - Tool Call Arguments
- - Tool Call End
- - Tool Call Result
-3. One or more assistant reply streams:
- - Text Message Start
- - Text Message Content (multiple times; token/char streaming)
- - Text Message End
-4. Run Finished
-
-Notes:
-- `Run Start` and `Run Finished` are always emitted.
-- `Tool Call` events appear only when a backend or frontend tool is invoked. There can be multiple tool calls in a single run.
-- `Text Message` events are always emitted and carry the assistant’s reply incrementally.
+
+Events arrive via `onAIAssistantEventReceived` in this order:
+
+| Order | Event | Description |
+|-------|-------|-------------|
+| 1 | Run Start | A new run has begun |
+| 2 | Tool Call Start | Agent decided to invoke a tool |
+| 3 | Tool Call Arguments | Arguments being passed to the tool |
+| 4 | Tool Call End | Tool execution completed |
+| 5 | Tool Call Result | Tool's output is available |
+| 6 | Text Message Start | Agent started composing a reply |
+| 7 | Text Message Content | Streaming content chunks (multiple) |
+| 8 | Text Message End | Agent reply is complete |
+| 9 | Run Finished | Run finalized; persisted messages follow |
+
+
+`Run Start` and `Run Finished` are always emitted. Tool Call events only appear when tools are invoked.
+
@@ -69,23 +95,15 @@ Notes:
-#### Event descriptions
-- Run Start: A new run has begun for the user’s message.
-- Tool Call Start: The agent decided to invoke a tool.
-- Tool Call Arguments: Arguments being passed to the tool.
-- Tool Call End: Tool execution completed.
-- Tool Call Result: Tool’s output is available.
-- Text Message Start: The agent started composing a reply.
-- Text Message Content: Streaming content chunks for progressive rendering.
-- Text Message End: The agent reply is complete.
-- Run Finished: The run is finalized; persisted messages will follow.
-
### Agentic Messages
-These events are received via the **`MessageListener`** after the run completes.
-- `AIAssistantMessage`: The full assistant reply.
-- `AIToolResultMessage`: The final output of a tool call.
-- `AIToolArgumentMessage`: The arguments that were passed to a tool.
+After the run completes, these messages arrive via `MessageListener`:
+
+| Message Type | Description |
+|--------------|-------------|
+| `AIAssistantMessage` | The full assistant reply |
+| `AIToolResultMessage` | The final output of a tool call |
+| `AIToolArgumentMessage` | The arguments passed to a tool |
@@ -131,4 +149,28 @@ These events are received via the **`MessageListener`** after the run completes.
CometChat.removeMessageListener(listnerId);
```
-
\ No newline at end of file
+
+
+
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+
+---
+
+## Next Steps
+
+
+
+ Set up AI-powered chatbots for automated conversations
+
+
+ Automatically moderate messages with AI
+
+
+ AI-powered features like smart replies and conversation summaries
+
+
+ Send text messages that trigger AI Agent responses
+
+
diff --git a/sdk/javascript/ai-integration-quick-reference.mdx b/sdk/javascript/ai-integration-quick-reference.mdx
new file mode 100644
index 000000000..3f3af5c23
--- /dev/null
+++ b/sdk/javascript/ai-integration-quick-reference.mdx
@@ -0,0 +1,258 @@
+---
+title: "AI Integration Quick Reference"
+sidebarTitle: "AI Quick Reference"
+description: "Quick reference for AI features in the CometChat JavaScript SDK: AI Agents, AI Moderation, and AI User Copilot."
+---
+
+
+
+| Field | Value |
+| --- | --- |
+| Package | `@cometchat/chat-sdk-javascript` |
+| AI Features | AI Agents, AI Moderation, AI User Copilot |
+| Activation | Enable from [CometChat Dashboard](https://app.cometchat.com) |
+| Prerequisites | `CometChat.init()` + `CometChat.login()` completed |
+| AI Agents | Real-time streaming via `AIAssistantListener`, persisted messages via `MessageListener` |
+| AI Moderation | Automatic content moderation with `PENDING` → `APPROVED` / `DISAPPROVED` flow |
+| AI User Copilot | Smart Replies, Conversation Starter, Conversation Summary (Dashboard-enabled) |
+
+
+
+## Overview
+
+CometChat provides three AI-powered features to enhance your chat application:
+
+| Feature | Description | Use Case |
+| --- | --- | --- |
+| [AI Agents](/sdk/javascript/ai-agents) | Intelligent automated conversations with real-time streaming | Chatbots, virtual assistants, automated support |
+| [AI Moderation](/sdk/javascript/ai-moderation) | Automatic content moderation for text, image, and video messages | Safety, compliance, content filtering |
+| [AI User Copilot](/fundamentals/ai-user-copilot/overview) | Smart replies, conversation starters, and summaries | Enhanced user experience, productivity |
+
+## AI Features Summary
+
+### AI Agents
+
+AI Agents enable intelligent, automated interactions. They process user messages, trigger tools, and respond with contextually relevant information.
+
+**Key Points:**
+- Agents only respond to text messages
+- Real-time events via `AIAssistantListener`
+- Persisted messages via `MessageListener`
+- Event flow: Run Start → Tool Call(s) → Text Message Stream → Run Finished
+
+
+
+ ```javascript
+ const listnerId = "unique_listener_id";
+
+ // Adding the AIAssistantListener for real-time events
+ CometChat.addAIAssistantListener(listnerId, {
+ onAIAssistantEventReceived: (message) => {
+ console.log("AIAssistant event received successfully", message);
+ }
+ });
+
+ // Adding the MessageListener for persisted agentic messages
+ CometChat.addMessageListener(listnerId, {
+ onAIAssistantMessageReceived: (message) => {
+ console.log("AI Assistant message received successfully", message);
+ },
+ onAIToolResultReceived: (message) => {
+ console.log("AI Tool result message received successfully", message);
+ },
+ onAIToolArgumentsReceived: (message) => {
+ console.log("AI Tool argument message received successfully", message);
+ },
+ });
+
+ // Cleanup - always remove listeners when done
+ CometChat.removeAIAssistantListener(listnerId);
+ CometChat.removeMessageListener(listnerId);
+ ```
+
+
+ ```typescript
+ const listnerId: string = "unique_listener_id";
+
+ // Adding the AIAssistantListener for real-time events
+ CometChat.addAIAssistantListener(listnerId, {
+ onAIAssistantEventReceived: (message: CometChat.AIAssistantBaseEvent) => {
+ console.log("AIAssistant event received successfully", message);
+ }
+ });
+
+ // Adding the MessageListener for persisted agentic messages
+ CometChat.addMessageListener(listnerId, {
+ onAIAssistantMessageReceived: (message: CometChat.AIAssistantMessage) => {
+ console.log("AI Assistant message received successfully", message);
+ },
+ onAIToolResultReceived: (message: CometChat.AIToolResultMessage) => {
+ console.log("AI Tool result message received successfully", message);
+ },
+ onAIToolArgumentsReceived: (message: CometChat.AIToolArgumentMessage) => {
+ console.log("AI Tool argument message received successfully", message);
+ },
+ });
+
+ // Cleanup - always remove listeners when done
+ CometChat.removeAIAssistantListener(listnerId);
+ CometChat.removeMessageListener(listnerId);
+ ```
+
+
+
+### AI Moderation
+
+AI Moderation automatically reviews messages for inappropriate content in real-time.
+
+**Key Points:**
+- Supports Text, Image, and Video messages only
+- Moderation statuses: `PENDING` → `APPROVED` or `DISAPPROVED`
+- Enable and configure rules in the CometChat Dashboard
+
+
+
+ ```javascript
+ // Send message and check initial moderation status
+ const textMessage = new CometChat.TextMessage(
+ receiverUID,
+ "Hello, how are you?",
+ CometChat.RECEIVER_TYPE.USER
+ );
+
+ CometChat.sendMessage(textMessage).then(
+ (message) => {
+ const status = message.getModerationStatus();
+
+ if (status === CometChat.ModerationStatus.PENDING) {
+ console.log("Message is under moderation review");
+ }
+ },
+ (error) => {
+ console.log("Message sending failed:", error);
+ }
+ );
+
+ // Listen for moderation results
+ const listenerID = "MODERATION_LISTENER";
+
+ CometChat.addMessageListener(
+ listenerID,
+ new CometChat.MessageListener({
+ onMessageModerated: (message) => {
+ const status = message.getModerationStatus();
+ const messageId = message.getId();
+
+ switch (status) {
+ case CometChat.ModerationStatus.APPROVED:
+ console.log(`Message ${messageId} approved`);
+ break;
+ case CometChat.ModerationStatus.DISAPPROVED:
+ console.log(`Message ${messageId} blocked`);
+ break;
+ }
+ }
+ })
+ );
+ ```
+
+
+ ```typescript
+ // Send message and check initial moderation status
+ const textMessage = new CometChat.TextMessage(
+ receiverUID,
+ "Hello, how are you?",
+ CometChat.RECEIVER_TYPE.USER
+ );
+
+ CometChat.sendMessage(textMessage).then(
+ (message: CometChat.TextMessage) => {
+ const status: string = message.getModerationStatus();
+
+ if (status === CometChat.ModerationStatus.PENDING) {
+ console.log("Message is under moderation review");
+ }
+ },
+ (error: CometChat.CometChatException) => {
+ console.log("Message sending failed:", error);
+ }
+ );
+
+ // Listen for moderation results
+ const listenerID: string = "MODERATION_LISTENER";
+
+ CometChat.addMessageListener(
+ listenerID,
+ new CometChat.MessageListener({
+ onMessageModerated: (message: CometChat.BaseMessage) => {
+ const status: string = message.getModerationStatus();
+ const messageId: number = message.getId();
+
+ switch (status) {
+ case CometChat.ModerationStatus.APPROVED:
+ console.log(`Message ${messageId} approved`);
+ break;
+ case CometChat.ModerationStatus.DISAPPROVED:
+ console.log(`Message ${messageId} blocked`);
+ break;
+ }
+ }
+ })
+ );
+ ```
+
+
+
+### AI User Copilot
+
+AI User Copilot provides smart features that enhance user productivity. These features are enabled in the Dashboard and auto-integrate with UI Kits.
+
+| Feature | Description | Documentation |
+| --- | --- | --- |
+| Conversation Starter | AI-generated opening lines for new chats | [Learn more](/fundamentals/ai-user-copilot/conversation-starter) |
+| Smart Replies | AI-generated response suggestions | [Learn more](/fundamentals/ai-user-copilot/smart-replies) |
+| Conversation Summary | AI-generated recap of long conversations | [Learn more](/fundamentals/ai-user-copilot/conversation-summary) |
+
+## Configuration Options
+
+### AI Agents Configuration
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| `listenerId` | `string` | Unique identifier for the listener |
+| `onAIAssistantEventReceived` | `function` | Callback for real-time streaming events |
+| `onAIAssistantMessageReceived` | `function` | Callback for persisted assistant messages |
+| `onAIToolResultReceived` | `function` | Callback for tool execution results |
+| `onAIToolArgumentsReceived` | `function` | Callback for tool arguments |
+
+### AI Moderation Configuration
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| `listenerID` | `string` | Unique identifier for the listener |
+| `onMessageModerated` | `function` | Callback when moderation result is available |
+
+### Moderation Status Values
+
+| Status | Enum | Description |
+| --- | --- | --- |
+| Pending | `CometChat.ModerationStatus.PENDING` | Message is being processed |
+| Approved | `CometChat.ModerationStatus.APPROVED` | Message passed moderation |
+| Disapproved | `CometChat.ModerationStatus.DISAPPROVED` | Message was blocked |
+
+## Next Steps
+
+
+
+ Full documentation for AI Agents integration
+
+
+ Complete AI Moderation implementation guide
+
+
+ Smart Replies, Conversation Starter, and Summary
+
+
+ Common issues and fixes
+
+
diff --git a/sdk/javascript/ai-moderation.mdx b/sdk/javascript/ai-moderation.mdx
index 768de5403..3222af96a 100644
--- a/sdk/javascript/ai-moderation.mdx
+++ b/sdk/javascript/ai-moderation.mdx
@@ -1,10 +1,35 @@
---
title: "AI Moderation"
+sidebarTitle: "AI Moderation"
+description: "Automatically moderate chat messages using AI to detect and block inappropriate content in real-time."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// Send message — check moderation status
+CometChat.sendMessage(textMessage).then(message => {
+ const status = message.getModerationStatus();
+ // CometChat.ModerationStatus.PENDING | APPROVED | DISAPPROVED
+});
+
+// Listen for moderation results
+CometChat.addMessageListener("MOD_LISTENER", new CometChat.MessageListener({
+ onMessageModerated: (message) => {
+ const status = message.getModerationStatus();
+ // Handle APPROVED or DISAPPROVED
+ }
+}));
+```
+
+**Supported types:** Text, Image, Video messages only
+**Statuses:** `PENDING` → `APPROVED` or `DISAPPROVED`
+
+
## Overview
-AI Moderation in the CometChat SDK helps ensure that your chat application remains safe and compliant by automatically reviewing messages for inappropriate content. This feature leverages AI to moderate messages in real-time, reducing manual intervention and improving user experience.
+AI Moderation automatically reviews messages for inappropriate content in real-time, reducing manual intervention and improving user experience.
For a broader understanding of moderation features, configuring rules, and managing flagged messages, see the [Moderation Overview](/moderation/overview).
@@ -12,11 +37,9 @@ For a broader understanding of moderation features, configuring rules, and manag
## Prerequisites
-Before using AI Moderation, ensure the following:
-
-1. Moderation is enabled for your app in the [CometChat Dashboard](https://app.cometchat.com)
-2. Moderation rules are configured under **Moderation > Rules**
-3. You're using CometChat SDK version that supports moderation
+1. Moderation enabled in the [CometChat Dashboard](https://app.cometchat.com)
+2. Moderation rules configured under **Moderation > Rules**
+3. CometChat SDK version that supports moderation
## How It Works
@@ -300,5 +323,23 @@ Here's a complete implementation showing the full moderation flow:
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+
## Next Steps
-After implementing AI Moderation, consider adding a reporting feature to allow users to flag messages they find inappropriate. For more details, see the [Flag Message](/sdk/javascript/flag-message) documentation.
+
+
+
+ Allow users to report inappropriate messages manually
+
+
+ Build intelligent automated conversations with AI Agents
+
+
+ Smart replies, conversation summaries, and more
+
+
+ Send text, media, and custom messages
+
+
diff --git a/sdk/javascript/all-real-time-listeners.mdx b/sdk/javascript/all-real-time-listeners.mdx
index a70adfb54..a33575498 100644
--- a/sdk/javascript/all-real-time-listeners.mdx
+++ b/sdk/javascript/all-real-time-listeners.mdx
@@ -1,8 +1,43 @@
---
title: "All Real Time Listeners"
+description: "Complete reference for all CometChat real-time listeners including User, Group, Message, and Call listeners."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// User Listener — online/offline presence
+CometChat.addUserListener("ID", new CometChat.UserListener({
+ onUserOnline: (user) => { },
+ onUserOffline: (user) => { }
+}));
+
+// Message Listener — messages, typing, receipts, reactions
+CometChat.addMessageListener("ID", new CometChat.MessageListener({
+ onTextMessageReceived: (msg) => { },
+ onMediaMessageReceived: (msg) => { },
+ onTypingStarted: (indicator) => { },
+ onMessagesRead: (receipt) => { }
+}));
+
+// Group Listener — member join/leave/kick/ban/scope changes
+CometChat.addGroupListener("ID", new CometChat.GroupListener({ ... }));
+
+// Call Listener — incoming/outgoing call events
+CometChat.addCallListener("ID", new CometChat.CallListener({ ... }));
+
+// Always clean up
+CometChat.removeUserListener("ID");
+CometChat.removeMessageListener("ID");
+CometChat.removeGroupListener("ID");
+CometChat.removeCallListener("ID");
+```
+
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
CometChat provides 4 listeners viz.
@@ -25,7 +60,7 @@ To add the `UserListener`, you need to use the `addUserListener()` method provid
```js
-var listenerID = "UNIQUE_LISTENER_ID";
+const listenerID = "UNIQUE_LISTENER_ID";
CometChat.addUserListener(
listenerID,
new CometChat.UserListener({
@@ -43,7 +78,7 @@ CometChat.addUserListener(
```typescript
-var listenerID: string = "UNIQUE_LISTENER_ID";
+const listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.addUserListener(
listenerID,
new CometChat.UserListener({
@@ -530,3 +565,23 @@ CometChat.removeCallListener(listenerID);
+
+
+---
+
+## Next Steps
+
+
+
+ Handle incoming messages in real-time
+
+
+ Show when users are typing
+
+
+ Track online/offline status of users
+
+
+ Monitor SDK connection state changes
+
+
diff --git a/sdk/javascript/authentication-overview.mdx b/sdk/javascript/authentication-overview.mdx
index 1df057175..03756f7db 100644
--- a/sdk/javascript/authentication-overview.mdx
+++ b/sdk/javascript/authentication-overview.mdx
@@ -1,9 +1,29 @@
---
title: "Authentication"
sidebarTitle: "Overview"
+description: "Create users, log in with Auth Key or Auth Token, check login status, and log out using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Check existing session
+const user = await CometChat.getLoggedinUser();
+
+// Login with Auth Key (development only)
+CometChat.login("UID", "AUTH_KEY").then(user => console.log("Logged in:", user));
+
+// Login with Auth Token (production)
+CometChat.login("AUTH_TOKEN").then(user => console.log("Logged in:", user));
+
+// Logout
+CometChat.logout().then(() => console.log("Logged out"));
+```
+
+**Create users via:** [Dashboard](https://app.cometchat.com) (testing) | [REST API](https://api-explorer.cometchat.com/reference/creates-user) (production)
+**Test UIDs:** `cometchat-uid-1` through `cometchat-uid-5`
+
## Create User
@@ -12,6 +32,26 @@ Before you log in a user, you must add the user to CometChat.
1. **For proof of concept/MVPs**: Create the user using the [CometChat Dashboard](https://app.cometchat.com).
2. **For production apps**: Use the CometChat [Create User API](https://api-explorer.cometchat.com/reference/creates-user) to create the user when your user signs up in your app.
+### Authentication Flow
+
+```mermaid
+sequenceDiagram
+ participant User
+ participant YourApp as Your App
+ participant YourServer as Your Server
+ participant CometChat as CometChat
+
+ User->>YourApp: Signs up / Logs in
+ YourApp->>YourServer: Authenticate user
+ YourServer->>CometChat: Create user (REST API, first time only)
+ CometChat-->>YourServer: User created
+ YourServer->>CometChat: Create Auth Token (REST API)
+ CometChat-->>YourServer: Auth Token
+ YourServer-->>YourApp: Return Auth Token
+ YourApp->>CometChat: CometChat.login(authToken)
+ CometChat-->>YourApp: User object (logged in)
+```
+
We have setup 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`.
@@ -32,11 +72,15 @@ The CometChat SDK maintains the session of the logged-in user within the SDK. Th
This straightforward authentication method is ideal for proof-of-concept (POC) development or during the early stages of application development. For production environments, however, we strongly recommend using an [AuthToken](#login-using-auth-token) instead of an Auth Key to ensure enhanced security.
+
+**Auth Key** is for development/testing only. In production, generate **Auth Tokens** on your server using the REST API and pass them to the client. Never expose Auth Keys in production client code.
+
+
```js
-var UID = "UID";
-var authKey = "AUTH_KEY";
+const UID = "UID";
+const authKey = "AUTH_KEY";
CometChat.getLoggedinUser().then(
(user) => {
@@ -61,8 +105,8 @@ CometChat.getLoggedinUser().then(
```typescript
-var UID: string = "cometchat-uid-1",
- authKey: string = "AUTH_KEY";
+const UID: string = "cometchat-uid-1";
+const authKey: string = "AUTH_KEY";
CometChat.getLoggedinUser().then(
(user: CometChat.User) => {
@@ -85,6 +129,24 @@ CometChat.getLoggedinUser().then(
+
+```javascript
+const UID = "UID";
+const authKey = "AUTH_KEY";
+
+try {
+ const loggedInUser = await CometChat.getLoggedinUser();
+ if (!loggedInUser) {
+ const user = await CometChat.login(UID, authKey);
+ console.log("Login Successful:", { user });
+ }
+} catch (error) {
+ console.log("Login failed with exception:", { error });
+}
+```
+
+
+
| Parameters | Description |
@@ -105,7 +167,7 @@ This advanced authentication procedure does not use the Auth Key directly in you
```js
-var authToken = "AUTH_TOKEN";
+const authToken = "AUTH_TOKEN";
CometChat.getLoggedinUser().then(
(user) => {
@@ -130,7 +192,7 @@ CometChat.getLoggedinUser().then(
```typescript
-var authToken: string = "AUTH_TOKEN";
+const authToken: string = "AUTH_TOKEN";
CometChat.getLoggedinUser().then(
(user: CometChat.User) => {
@@ -153,6 +215,23 @@ CometChat.getLoggedinUser().then(
+
+```javascript
+const authToken = "AUTH_TOKEN";
+
+try {
+ const loggedInUser = await CometChat.getLoggedinUser();
+ if (!loggedInUser) {
+ const user = await CometChat.login(authToken);
+ console.log("Login Successful:", { user });
+ }
+} catch (error) {
+ console.log("Login failed with exception:", { error });
+}
+```
+
+
+
| Parameter | Description |
@@ -194,4 +273,35 @@ CometChat.logout().then(
+
+```javascript
+try {
+ await CometChat.logout();
+ console.log("Logout completed successfully");
+} catch (error) {
+ console.log("Logout failed with exception:", { error });
+}
+```
+
+
+
+
+---
+
+## Next Steps
+
+
+
+ Send your first text, media, or custom message
+
+
+ Install and initialize the CometChat SDK
+
+
+ Create, update, and delete users programmatically
+
+
+ Listen for login and logout events in real-time
+
+
diff --git a/sdk/javascript/best-practices.mdx b/sdk/javascript/best-practices.mdx
new file mode 100644
index 000000000..64cdc95a9
--- /dev/null
+++ b/sdk/javascript/best-practices.mdx
@@ -0,0 +1,175 @@
+---
+title: "Best Practices"
+sidebarTitle: "Best Practices"
+description: "Recommended patterns and practices for building with the CometChat JavaScript SDK."
+---
+
+Follow these best practices to build reliable, performant, and secure applications with the CometChat JavaScript SDK.
+
+## Initialization & Authentication
+
+| Practice | Description |
+|----------|-------------|
+| Initialize once at startup | Call `CometChat.init()` in your entry file (`index.js`, `main.js`, or `App.js`). It only needs to be called once per session. |
+| Use environment variables | Store App ID, Region, and Auth Key in environment variables rather than hardcoding them. |
+| Check for existing sessions | Before calling `login()`, use `CometChat.getLoggedinUser()` to check if a session already exists. |
+| Use Auth Tokens in production | Auth Keys are for development only. Generate Auth Tokens server-side using the [REST API](https://api-explorer.cometchat.com/reference/create-authtoken). |
+| Handle token expiry | Implement a mechanism to detect login failures due to expired tokens. Use the [Login Listener](/sdk/javascript/login-listener) to detect session changes. |
+| Logout on sign-out | Always call `CometChat.logout()` when your user signs out to clear the SDK session and stop real-time events. |
+
+## Listeners
+
+| Practice | Description |
+|----------|-------------|
+| Use unique listener IDs | Use descriptive IDs like `"MESSAGE_LISTENER_CHAT_SCREEN"` to avoid accidental overwrites. |
+| Register early, remove on cleanup | Register listeners after `login()`. Remove them when the component is destroyed to prevent memory leaks. |
+| Keep callbacks lightweight | Avoid heavy processing inside listener callbacks. Dispatch events to your state management layer. |
+| Use specific listeners | Only register the listener types you need. Don't register a `GroupListener` if your page only handles messages. |
+
+## Pagination & Caching
+
+| Practice | Description |
+|----------|-------------|
+| Use reasonable limits | Set `setLimit()` to 30-50 for users, messages, and group members. |
+| Reuse request objects | Call `fetchNext()`/`fetchPrevious()` on the same request instance. Creating a new object resets the cursor. |
+| Cache frequently accessed data | Store user and group objects locally to reduce API calls. |
+
+## Rate Limits
+
+| Practice | Description |
+|----------|-------------|
+| Batch operations | Space out bulk operations using a queue or throttle mechanism. |
+| Monitor rate limit headers | Check `X-Rate-Limit-Remaining` in REST API responses to slow down before hitting limits. |
+| Distinguish operation types | Core operations (login, create/delete user) share a 10,000/min limit. Standard operations have 20,000/min. Avoid frequent login/logout cycles. |
+
+## SSR Frameworks
+
+| Practice | Description |
+|----------|-------------|
+| Initialize client-side only | CometChat requires browser APIs. Use dynamic imports or `useEffect` for Next.js, Nuxt, etc. |
+| Use loading states | Show a loading indicator while the SDK initializes to prevent hydration mismatches. |
+
+## Messaging
+
+| Practice | Description |
+|----------|-------------|
+| Use appropriate message types | Choose text, media, or custom messages based on your content. |
+| Add metadata for context | Use `setMetadata()` to attach location, device info, or other contextual data. |
+| Handle errors gracefully | Always implement error callbacks to handle network issues or invalid parameters. |
+| Validate file types | Before sending media messages, verify the file type matches the message type. |
+| Hide deleted/blocked content | Use `hideDeletedMessages(true)` and `hideMessagesFromBlockedUsers(true)` for cleaner lists. |
+
+## Threaded Messages
+
+| Practice | Description |
+|----------|-------------|
+| Track active thread ID | Store the current thread's `parentMessageId` to filter incoming messages. |
+| Use hideReplies(true) | Exclude thread replies from main conversation to avoid clutter. |
+| Show reply count | Display the number of replies on parent messages to indicate thread activity. |
+
+## Reactions & Mentions
+
+| Practice | Description |
+|----------|-------------|
+| Update UI optimistically | Show reactions immediately, then sync with server response. |
+| Use correct mention format | Always use `<@uid:UID>` format for mentions in message text. |
+| Highlight mentions in UI | Parse message text and style mentions differently. |
+
+## Typing Indicators
+
+| Practice | Description |
+|----------|-------------|
+| Debounce typing events | Don't call `startTyping()` on every keystroke - debounce to ~300ms intervals. |
+| Auto-stop typing | Call `endTyping()` after 3-5 seconds of inactivity or when the user sends a message. |
+
+## Delivery & Read Receipts
+
+| Practice | Description |
+|----------|-------------|
+| Mark as delivered on fetch | Call `markAsDelivered()` when messages are fetched and displayed. |
+| Mark as read on view | Call `markAsRead()` when the user actually views/scrolls to a message. |
+| Batch receipts | Mark the last message in a batch - all previous messages are automatically marked. |
+
+## Groups
+
+| Practice | Description |
+|----------|-------------|
+| Use meaningful GUIDs | Choose descriptive, unique GUIDs (e.g., `"project-alpha-team"`). |
+| Set group type carefully | Group type cannot be changed after creation. Choose between PUBLIC, PASSWORD, and PRIVATE. |
+| Add members at creation | Use `createGroupWithMembers()` to add initial members in a single API call. |
+| Check hasJoined before joining | Avoid unnecessary API calls by checking the group's `hasJoined` property first. |
+| Transfer ownership before leaving | Owners must transfer ownership to another member before they can leave. |
+| Use joinedOnly(true) | Filter to joined groups when building sidebars or group lists. |
+
+## Group Members
+
+| Practice | Description |
+|----------|-------------|
+| Batch member additions | Add multiple members in a single `addMembersToGroup()` call. |
+| Set appropriate scopes | Assign `PARTICIPANT` by default. Only use `ADMIN` or `MODERATOR` when needed. |
+| Handle partial failures | Check each entry in the response array for `"success"` or an error message. |
+| Use scope constants | Use `CometChat.GROUP_MEMBER_SCOPE.ADMIN` instead of raw strings. |
+| Kick vs. Ban | Use kick when the user can rejoin. Use ban for permanent removal until unbanned. |
+
+## Calling
+
+| Practice | Description |
+|----------|-------------|
+| Initialize Calls SDK after Chat SDK | Always initialize Chat SDK (`CometChat.init()`) before Calls SDK (`CometChatCalls.init()`). |
+| Store session ID immediately | Save the session ID from `initiateCall()` response - you'll need it for accept, reject, cancel. |
+| Handle all call states | Implement handlers for all listener events (accepted, rejected, cancelled, busy, ended). |
+| Generate tokens just-in-time | Generate call tokens immediately before starting a session rather than caching them. |
+| Clean up on session end | Always call `CometChatCalls.endSession()` in both `onCallEnded` and `onCallEndButtonPressed` callbacks. |
+| Inform users about recording | Always notify participants when recording starts - this is often a legal requirement. |
+| Limit presenters to 5 | Additional users should join as viewers. |
+
+## Custom CSS (Calling)
+
+| Practice | Description |
+|----------|-------------|
+| Only use documented CSS classes | Undocumented internal classes may break with SDK updates. |
+| Don't resize the grid container | Only customize colors, borders, and visibility. |
+| Test across modes | CSS changes may look different in `DEFAULT`, `TILE`, and `SPOTLIGHT` modes. |
+| Keep button sizes accessible | Minimum 44x44px for touch targets. |
+
+## Connection & WebSocket
+
+| Practice | Description |
+|----------|-------------|
+| Register connection listener early | Add the listener right after `CometChat.init()` succeeds. |
+| Show connection status in UI | Display a banner when disconnected so users know messages may be delayed. |
+| Queue actions during disconnection | Queue user actions and retry once `onConnected` fires. |
+| Don't poll getConnectionStatus() | Use the listener-based approach instead. |
+| Reconnect on app foreground | If you disconnect in background, call `CometChat.connect()` when returning to foreground. |
+
+## AI Features
+
+| Practice | Description |
+|----------|-------------|
+| Register both listeners for AI Agents | Use `AIAssistantListener` for streaming events and `MessageListener` for persisted messages. |
+| Handle streaming progressively | Render the assistant's reply token-by-token using `Text Message Content` events. |
+| Show pending state for moderation | Display a visual indicator when `getModerationStatus()` returns `PENDING`. |
+| Handle disapproved messages gracefully | Show a placeholder or notification so the sender understands what happened. |
+| Track pending messages | Maintain a local map of pending message IDs to update UI when moderation results arrive. |
+
+## Upgrading from V3
+
+| Practice | Description |
+|----------|-------------|
+| Follow the setup guide first | Complete the v4 [setup instructions](/sdk/javascript/setup-sdk) before changing imports. |
+| Update all imports at once | Use find-and-replace to change all `@cometchat-pro/chat` imports to `@cometchat/chat-sdk-javascript`. |
+| Test incrementally | Test each feature area (messaging, calling, groups) individually after updating. |
+| Remove old packages | Uninstall v3 packages (`npm uninstall @cometchat-pro/chat`) to avoid conflicts. |
+
+---
+
+## Next Steps
+
+
+
+ Common issues and solutions
+
+
+ Installation and initialization guide
+
+
diff --git a/sdk/javascript/block-users.mdx b/sdk/javascript/block-users.mdx
index 738e07ab1..5fd991ef8 100644
--- a/sdk/javascript/block-users.mdx
+++ b/sdk/javascript/block-users.mdx
@@ -1,19 +1,35 @@
---
title: "Block Users"
+sidebarTitle: "Block Users"
+description: "Block and unblock users, and retrieve the list of blocked users using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Block users
+await CometChat.blockUsers(["UID1", "UID2"]);
-## Block Users
+// Unblock users
+await CometChat.unblockUsers(["UID1", "UID2"]);
-*In other words, as a logged-in user, how do I block a user from sending me messages?*
+// Get blocked users list
+let request = new CometChat.BlockedUsersRequestBuilder().setLimit(30).build();
+let blockedUsers = await request.fetchNext();
+```
-You can block users using the `blockUsers()` method. Once any user is blocked, all the communication to and from the respective user will be completely blocked. You can block multiple users in a single operation. The `blockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be blocked.
+**Directions:** `BLOCKED_BY_ME` | `HAS_BLOCKED_ME` | `BOTH` (default)
+
+
+## Block Users
+
+Block users to prevent all communication with them. Use `blockUsers()` with an array of UIDs.
-
+
```javascript
-var usersList = ["UID1", "UID2", "UID3"];
+const usersList = ["UID1", "UID2", "UID3"];
CometChat.blockUsers(usersList).then(
list => {
@@ -28,7 +44,7 @@ list => {
```typescript
-var usersList: String[] = ["UID1", "UID2", "UID3"];
+const usersList: String[] = ["UID1", "UID2", "UID3"];
CometChat.blockUsers(usersList).then(
(list: Object) => {
@@ -41,20 +57,41 @@ CometChat.blockUsers(usersList).then(
+
+```javascript
+const usersList = ["UID1", "UID2", "UID3"];
+
+try {
+ const list = await CometChat.blockUsers(usersList);
+ console.log("users list blocked", { list });
+} catch (error) {
+ console.log("Blocking user fails with error", error);
+}
+```
+
+
+
-It returns a Array which contains `UID's` as the keys and "success" or "fail" as the value based on if the block operation for the `UID` was successful or not.
+Returns an object with UIDs as keys and `"success"` or `"fail"` as values.
-## Unblock Users
+The method returns an array of [`User`](/sdk/reference/entities#user) objects with the `blockedByMe` field set to `true`. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| blockedByMe | `getBlockedByMe()` | `boolean` | Whether the logged-in user has blocked this user |
+| hasBlockedMe | `getHasBlockedMe()` | `boolean` | Whether this user has blocked the logged-in user |
-*In other words, as a logged-in user, how do I unblock a user I previously blocked?*
+## Unblock Users
-You can unblock the already blocked users using the `unblockUsers()` method. You can unblock multiple users in a single operation. The `unblockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be unblocked.
+Unblock previously blocked users using `unblockUsers()` with an array of UIDs.
-
+
```javascript
-var usersList = ["UID1", "UID2", "UID3"];
+const usersList = ["UID1", "UID2", "UID3"];
CometChat.unblockUsers(usersList).then(
list => {
@@ -69,7 +106,7 @@ list => {
```typescript
-var usersList: String[] = ["UID1", "UID2", "UID3"];
+const usersList: String[] = ["UID1", "UID2", "UID3"];
CometChat.unblockUsers(usersList).then(
(list: Object) => {
@@ -82,21 +119,40 @@ CometChat.unblockUsers(usersList).then(
+
+```javascript
+const usersList = ["UID1", "UID2", "UID3"];
+
+try {
+ const list = await CometChat.unblockUsers(usersList);
+ console.log("users list unblocked", { list });
+} catch (error) {
+ console.log("unblocking user fails with error", error);
+}
+```
+
+
+
-It returns a Array which contains `UID's` as the keys and `success` or `fail` as the value based on if the unblock operation for the `UID` was successful or not.
+Returns an object with UIDs as keys and `"success"` or `"fail"` as values.
-## Get List of Blocked Users
+The method returns an array of [`User`](/sdk/reference/entities#user) objects with the `blockedByMe` field set to `false`. Access the response data using getter methods:
-*In other words, as a logged-in user, how do I get a list of all users I've blocked?*
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| blockedByMe | `getBlockedByMe()` | `boolean` | Whether the logged-in user has blocked this user |
+| hasBlockedMe | `getHasBlockedMe()` | `boolean` | Whether this user has blocked the logged-in user |
-In order to fetch the list of blocked users, you can use the `BlockedUsersRequest` class. To use this class i.e to create an object of the `BlockedUsersRequest class`, you need to use the `BlockedUsersRequestBuilder` class. The `BlockedUsersRequestBuilder` class allows you to set the parameters based on which the blocked users are to be fetched.
+## Get List of Blocked Users
-The `BlockedUsersRequestBuilder` class allows you to set the below parameters:
+Use `BlockedUsersRequestBuilder` to fetch blocked users with filtering and pagination.
### Set Limit
-This method sets the limit i.e. the number of blocked users that should be fetched in a single iteration.
+Sets the number of blocked users to fetch per request.
@@ -123,7 +179,7 @@ let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUs
### Set Search Keyword
-This method allows you to set the search string based on which the blocked users are to be fetched.
+Filters blocked users by a search string.
@@ -154,9 +210,11 @@ let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUs
### Set Direction
-* CometChat.BlockedUsersRequest.directions.BLOCKED\_BY\_ME - This will ensure that the list of blocked users only contains the users blocked by the logged in user.
-* CometChat.BlockedUsersRequest.directions.HAS\_BLOCKED\_ME - This will ensure that the list of blocked users only contains the users that have blocked the logged in user.
-* CometChat.BlockedUsersRequest.directions.BOTH - This will make sure the list of users includes both the above cases. This is the default value for the direction variable if it is not set.
+Filters by block direction:
+
+- `BLOCKED_BY_ME` — Users blocked by the logged-in user
+- `HAS_BLOCKED_ME` — Users who have blocked the logged-in user
+- `BOTH` — Both directions (default)
@@ -183,15 +241,13 @@ let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUs
-Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BlockedUsersRequest` class.
-
-Once you have the object of the `BlockedUsersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `User` objects containing n number of blocked users where N is the limit set in the builder class.
+After configuring the builder, call `build()` to get the `BlockedUsersRequest` object, then call `fetchNext()` to retrieve blocked users.
-
+
```javascript
-var limit = 30;
-var blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder()
+const limit = 30;
+const blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder()
.setLimit(limit)
.build();
blockedUsersRequest.fetchNext().then(
@@ -224,3 +280,22 @@ blockedUsersRequest.fetchNext().then(
+
+---
+
+## Next Steps
+
+
+
+ Fetch and filter user lists
+
+
+ Track online/offline status of users
+
+
+ Create, update, and delete users
+
+
+ Report inappropriate messages from users
+
+
diff --git a/sdk/javascript/call-logs.mdx b/sdk/javascript/call-logs.mdx
index 74f2b87af..deeac9afd 100644
--- a/sdk/javascript/call-logs.mdx
+++ b/sdk/javascript/call-logs.mdx
@@ -1,20 +1,36 @@
---
title: "Call Logs"
+sidebarTitle: "Call Logs"
+description: "Fetch, filter, and retrieve call history including duration, participants, and recording status using the CometChat Calls SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Fetch call logs
+let request = new CometChatCalls.CallLogRequestBuilder()
+ .setLimit(30)
+ .setAuthToken(loggedInUser.getAuthToken())
+ .setCallCategory("call")
+ .build();
-## Overview
+let logs = await request.fetchNext();
+
+// Get details for a specific call session
+let details = await CometChatCalls.getCallDetails("SESSION_ID", authToken);
+```
-CometChat's Web Call SDK provides a comprehensive way to integrate call logs into your application, enhancing your user experience by allowing users to effortlessly keep track of their communication history. Call logs provide crucial information such as call duration, participants, and more.
+**Filters:** `setCallType()`, `setCallStatus()`, `setCallCategory()`, `setCallDirection()`, `setHasRecording()`, `setUid()`, `setGuid()`
+
-This feature not only allows users to review their past interactions but it also serves as an effective tool to revisit important conversation details. With the flexibility of fetching call logs, filtering them according to specific parameters, and obtaining detailed information of individual calls, application developers can use this feature to build a more robust and interactive communication framework.
+## Overview
-In the following sections, we will guide you through the process of working with call logs, offering a deeper insight into how to optimally use this feature in your Web application.
+Retrieve and display call history including duration, participants, status, and recording information.
## Fetching Call Logs
-To fetch all call logs in your 23b application, you should use the `CallLogRequestBuilder`, This builder allows you to customize the call logs fetching process according to your needs.
+Use `CallLogRequestBuilder` to fetch and filter call logs:
```javascript
let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
@@ -24,7 +40,7 @@ let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
.build()
```
-`CallLogRequestBuilder` has the following settings available.
+### Builder Settings
| Setting | Description |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
@@ -40,7 +56,7 @@ let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
### Fetch Next
-The**`fetchNext()`**method retrieves the next set of call logs.
+Retrieves the next set of call logs:
```javascript
let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
@@ -60,7 +76,7 @@ callLogRequestBuilder.fetchNext()
### Fetch Previous
-The**`fetchPrevious()`**method retrieves the previous set of call logs.
+Retrieves the previous set of call logs:
```javascript
let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
@@ -78,19 +94,78 @@ callLogRequestBuilder.fetchPrevious()
});
```
+The `fetchNext()` and `fetchPrevious()` methods return an array of [`Call`](/sdk/reference/messages#call) log objects. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| sessionId | `getSessionId()` | `string` | Unique session ID for the call |
+| callInitiator | `getCallInitiator()` | `User` | The user who initiated the call |
+| callReceiver | `getCallReceiver()` | `User` \| `Group` | The user or group that received the call |
+| action | `getAction()` | `string` | Call action/status |
+| initiatedAt | `getInitiatedAt()` | `number` | Timestamp when the call was initiated |
+| joinedAt | `getJoinedAt()` | `number` | Timestamp when the user joined the call |
+
## Get Call Details
-To retrieve the specific details of a call, use the**`getCallDetails()`**method. This method requires the Auth token of the logged-in user and the session ID along with a callback listener.
+Retrieve details for a specific call session using `getCallDetails()`:
+
+
```javascript
-var sessionID = "SESSION_ID";
-CometChatCalls.getCallDetails(sessionID, authToken)
-.then((callLogs: Array) => {
- console.log(callLogs);
- })
- .catch(err => {
- console.log(err);
- });
+const sessionID = "SESSION_ID";
+CometChatCalls.getCallDetails(sessionID, authToken).then(
+ (callLogs) => {
+ console.log("Call details:", callLogs);
+ },
+ (error) => {
+ console.log("Error fetching call details:", error);
+ }
+);
+```
+
+
+```typescript
+const sessionID: string = "SESSION_ID";
+CometChatCalls.getCallDetails(sessionID, authToken).then(
+ (callLogs: Array) => {
+ console.log("Call details:", callLogs);
+ },
+ (error: any) => {
+ console.log("Error fetching call details:", error);
+ }
+);
+```
+
+
+```javascript
+const sessionID = "SESSION_ID";
+try {
+ const callLogs = await CometChatCalls.getCallDetails(sessionID, authToken);
+ console.log("Call details:", callLogs);
+} catch (error) {
+ console.log("Error fetching call details:", error);
+}
```
+
+
+
+Note: Replace `"SESSION_ID"` with the ID of the session you are interested in.
+
+---
-Note: Replace**`"SESSION_ID"`**with the ID of the session you are interested in.
+## Next Steps
+
+
+
+ Implement the complete ringing call flow
+
+
+ Record audio and video calls
+
+
+ Start call sessions without the ringing flow
+
+
+ Install and initialize the Calls SDK
+
+
diff --git a/sdk/javascript/calling-overview.mdx b/sdk/javascript/calling-overview.mdx
index 18bc0ea62..a1c0adc69 100644
--- a/sdk/javascript/calling-overview.mdx
+++ b/sdk/javascript/calling-overview.mdx
@@ -1,8 +1,25 @@
---
title: "Calling"
sidebarTitle: "Overview"
+description: "Overview of CometChat voice and video calling capabilities including ringing, direct call sessions, and standalone calling."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+Choose your calling approach:
+- **Ringing** → [Default Call](/sdk/javascript/default-call) — Full call flow with notifications, accept/reject
+- **Call Session** → [Direct Call](/sdk/javascript/direct-call) — Session-based calling with custom UI
+- **Standalone** → [Standalone Calling](/sdk/javascript/standalone-calling) — Calls SDK only, no Chat SDK needed
+
+```bash
+# Install Calls SDK
+npm install @cometchat/calls-sdk-javascript
+```
+
+**Features:** Recording, Virtual Background, Screen Sharing, Custom CSS, Call Logs, Session Timeout
+
+
## Overview
CometChat provides voice and video calling capabilities for your web application. This guide helps you choose the right implementation approach based on your use case.
@@ -96,3 +113,16 @@ Use this when you want:
Configure automatic call termination when participants are inactive.
+
+---
+
+## Next Steps
+
+
+
+ Install and initialize the Calls SDK
+
+
+ Implement the complete ringing call flow
+
+
diff --git a/sdk/javascript/calling-setup.mdx b/sdk/javascript/calling-setup.mdx
index 7cd07247e..96ffa72cb 100644
--- a/sdk/javascript/calling-setup.mdx
+++ b/sdk/javascript/calling-setup.mdx
@@ -1,8 +1,34 @@
---
title: "Setup"
+sidebarTitle: "Setup"
+description: "Install and initialize the CometChat Calls SDK for JavaScript to enable voice and video calling in your application."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+**Quick Setup Reference**
+```bash
+npm install @cometchat/calls-sdk-javascript
+```
+
+```javascript
+import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
+
+const callAppSetting = new CometChatCalls.CallAppSettingsBuilder()
+ .setAppId("APP_ID")
+ .setRegion("REGION")
+ .build();
+
+CometChatCalls.init(callAppSetting).then(() => console.log("Calls SDK ready"));
+```
+
+**Required:** App ID, Region from [CometChat Dashboard](https://app.cometchat.com)
+
+
+
+`CometChatCalls.init()` must be called before any other Calls SDK method. Make sure the Chat SDK is also initialized via `CometChat.init()` first (unless using [Standalone Calling](/sdk/javascript/standalone-calling)).
+
## Get your Application Keys
@@ -53,15 +79,17 @@ import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
### Initialize CometChatCalls
-The `init()` method initialises the settings required for `CometChatCalls`. The `init()` method takes a single paramater, that is the instance of `CallAppSettings` class.
+The `init()` method initializes the Calls SDK. It takes a `CallAppSettings` instance as its parameter.
-The `CallAppSettingsBuilder` class allows you to configure three settings:
+`CallAppSettingsBuilder` accepts three settings:
-1. **appID:** You CometChat App ID
-2. **region**: The region where your app was created
-3. **host:** This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat.
+| Setting | Description |
+| ------- | ----------- |
+| `appID` | Your CometChat App ID |
+| `region` | The region where your app was created |
+| `host` | (Optional) Custom client URL for dedicated deployments |
-You need to call init() before calling any other method from `CometChatCalls`. We suggest you call the init() method on app startup, preferably in the index.js file.
+Call `init()` before any other `CometChatCalls` method — ideally on app startup.
@@ -115,3 +143,22 @@ Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` w
| Parameter | Description |
| ----------------- | ---------------------------------------- |
| `callAppSettings` | An object of the `CallAppSettings` class |
+
+---
+
+## Next Steps
+
+
+
+ Implement the complete ringing call flow
+
+
+ Start call sessions without the ringing flow
+
+
+ Use Calls SDK without the Chat SDK
+
+
+ Compare calling approaches and features
+
+
diff --git a/sdk/javascript/connection-status.mdx b/sdk/javascript/connection-status.mdx
index 7c67128bb..20ecaad73 100644
--- a/sdk/javascript/connection-status.mdx
+++ b/sdk/javascript/connection-status.mdx
@@ -1,8 +1,26 @@
---
title: "Connection Status"
+description: "Monitor real-time WebSocket connection status and respond to connectivity changes using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Get current status: "connecting" | "connected" | "disconnected"
+const status = CometChat.getConnectionStatus();
+
+// Listen for connection changes
+CometChat.addConnectionListener("LISTENER_ID", new CometChat.ConnectionListener({
+ onConnected: () => console.log("Connected"),
+ inConnecting: () => console.log("Connecting..."),
+ onDisconnected: () => console.log("Disconnected")
+}));
+
+// Cleanup
+CometChat.removeConnectionListener("LISTENER_ID");
+```
+
CometChat SDK provides you with a mechanism to get real-time status of the connection to CometChat web-socket servers.
@@ -74,14 +92,14 @@ You can also get the current connection status by using `getConnectionStatus` pr
```javascript
-var connectionStatus = CometChat.getConnectionStatus();
+const connectionStatus = CometChat.getConnectionStatus();
```
```typescript
-var connectionStatus: string = CometChat.getConnectionStatus();
+const connectionStatus: string = CometChat.getConnectionStatus();
```
@@ -93,3 +111,36 @@ The `CometChat.getConnectionStatus` method will return either of the below 3 val
1. connecting
2. connected
3. disconnected
+
+The connection listener callbacks and `getConnectionStatus()` return string enum values representing the current WebSocket connection state:
+
+| Value | Callback | Description |
+|-------|----------|-------------|
+| `"connected"` | `onConnected()` | SDK has an active connection to CometChat servers |
+| `"connecting"` | `inConnecting()` | SDK is attempting to establish or re-establish a connection |
+| `"disconnected"` | `onDisconnected()` | SDK is disconnected due to network issues or other errors |
+| `"featureThrottled"` | — | A feature has been throttled due to rate limiting |
+
+
+
+Always remove connection listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+
+---
+
+## Next Steps
+
+
+
+ Manually manage WebSocket connections
+
+
+ Listen for login and logout events
+
+
+ Complete reference for all SDK listeners
+
+
+ Install and initialize the CometChat SDK
+
+
diff --git a/sdk/javascript/create-group.mdx b/sdk/javascript/create-group.mdx
index 29eed3de5..e288bb58b 100644
--- a/sdk/javascript/create-group.mdx
+++ b/sdk/javascript/create-group.mdx
@@ -1,37 +1,48 @@
---
title: "Create A Group"
+sidebarTitle: "Create Group"
+description: "Create public, private, or password-protected groups and optionally add members during creation using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Create a group
+let group = new CometChat.Group("GUID", "Group Name", CometChat.GROUP_TYPE.PUBLIC, "");
+let createdGroup = await CometChat.createGroup(group);
-## Create a Group
-
-*In other words, as a logged-in user, how do I create a public, private or password-protected group?*
-
-You can create a group using `createGroup()` method. This method takes a `Group` object as input.
-
-To create an object of `Group` class, you can use either of the below two constructors:
+// Create group with members
+let members = [new CometChat.GroupMember("UID", CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT)];
+let result = await CometChat.createGroupWithMembers(group, members, []);
+```
-1. `new Group(String GUID, String name, String groupType, String password)`
-2. `new Group(String GUID, String name, String groupType, String password, String icon, String description)`
+**Group types:** `PUBLIC` | `PASSWORD` | `PRIVATE`
+**Member scopes:** `ADMIN` | `MODERATOR` | `PARTICIPANT`
+
-The `groupType` needs to be either of the below 3 values:
+## Create a Group
-1.`CometChat.GROUP_TYPE.PUBLIC`
+Use `createGroup()` to create a new group. Pass a `Group` object with the group details.
-2.`CometChat.GROUP_TYPE.PASSWORD`
+Group constructors:
+- `new Group(GUID, name, groupType, password)`
+- `new Group(GUID, name, groupType, password, icon, description)`
-3.`CometChat.GROUP_TYPE.PRIVATE`
+Group types:
+- `CometChat.GROUP_TYPE.PUBLIC`
+- `CometChat.GROUP_TYPE.PASSWORD`
+- `CometChat.GROUP_TYPE.PRIVATE`
-
+
```javascript
-var GUID = "GUID";
-var groupName = "Hello Group!";
-var groupType = CometChat.GROUP_TYPE.PUBLIC;
-var password = "";
+const GUID = "GUID";
+const groupName = "Hello Group!";
+const groupType = CometChat.GROUP_TYPE.PUBLIC;
+const password = "";
-var group = new CometChat.Group(GUID, groupName, groupType, password);
+const group = new CometChat.Group(GUID, groupName, groupType, password);
CometChat.createGroup(group).then(
group => {
@@ -46,12 +57,12 @@ CometChat.createGroup(group).then(
```typescript
-var GUID: string = "GUID";
-var groupName: string = "Hello Group!";
-var groupType: string = CometChat.GROUP_TYPE.PUBLIC;
-var password: string = "";
+const GUID: string = "GUID";
+const groupName: string = "Hello Group!";
+const groupType: string = CometChat.GROUP_TYPE.PUBLIC;
+const password: string = "";
-var group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType, password);
+const group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType, password);
CometChat.createGroup(group).then(
(group: CometChat.Group) => {
@@ -64,15 +75,43 @@ CometChat.createGroup(group).then(
+
+```javascript
+const GUID = "GUID";
+const groupName = "Hello Group!";
+const groupType = CometChat.GROUP_TYPE.PUBLIC;
+const password = "";
+
+const group = new CometChat.Group(GUID, groupName, groupType, password);
+
+try {
+ const createdGroup = await CometChat.createGroup(group);
+ console.log("Group created successfully:", createdGroup);
+} catch (error) {
+ console.log("Group creation failed with exception:", error);
+}
+```
+
+
+
-The createGroup() method takes the following parameters:
+| Parameter | Description |
+| --------- | ----------- |
+| `group` | An instance of `Group` class |
-| Parameter | Description |
-| --------- | ---------------------------- |
-| `group` | An instance of `Group` class |
+On success, returns a [`Group`](/sdk/reference/entities#group) object with the created group's details.
-After successful creation of the group, you will receive an instance of `Group` class which contains all the information about the particular group.
+The method returns a [`Group`](/sdk/reference/entities#group) object. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| guid | `getGuid()` | `string` | Unique group ID |
+| name | `getName()` | `string` | Display name of the group |
+| type | `getType()` | `string` | Group type (`"public"`, `"private"`, or `"password"`) |
+| owner | `getOwner()` | `string` | UID of the group owner |
+| membersCount | `getMembersCount()` | `number` | Total number of members in the group |
+| createdAt | `getCreatedAt()` | `number` | Timestamp when the group was created |
@@ -80,24 +119,16 @@ GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and oth
-## Add members while creating a group
-
-You can create a group and add members at the same time using the `createGroupWithMembers()` method. This method takes the `Group` Object, Array of `Group Member` Object to be added & Array of `UIDs` to be banned.
+## Add Members While Creating a Group
-To create an object of `Group` class, you can use either of the below two constructors:
+Use `createGroupWithMembers()` to create a group and add members in one operation.
-1. `new Group(String GUID, String name, String groupType, String password)`
-2. `new Group(String GUID, String name, String groupType, String password, String icon, String description)`
+Parameters:
+- `group` — The `Group` object
+- `members` — Array of `GroupMember` objects to add
+- `bannedMembers` — Array of UIDs to ban (can be empty)
-The `groupType` needs to be either of the below 3 values:
-
-1. `CometChat.GROUP_TYPE.PUBLIC`
-2. `CometChat.GROUP_TYPE.PASSWORD`
-3. `CometChat.GROUP_TYPE.PRIVATE`
-
-To create an object of `Group Member` class, you can use the below constructor:
-
-* new CometChat.GroupMember(String UID, String scope)
+Create a `GroupMember` with: `new CometChat.GroupMember(UID, scope)`
@@ -148,9 +179,34 @@ CometChat.createGroupWithMembers(group, members, banMembers).then(
+
+```javascript
+let GUID = "cometchat-guid-11";
+let UID = "cometchat-uid-1";
+let groupName = "Hello Group!";
+let groupType = CometChat.GROUP_TYPE.PUBLIC;
+
+let group = new CometChat.Group(GUID, groupName, groupType);
+let members = [
+ new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT)
+];
+let banMembers = ["cometchat-uid-2"];
+
+try {
+ const response = await CometChat.createGroupWithMembers(group, members, banMembers);
+ console.log("Group created successfully", response);
+} catch (error) {
+ console.log("Some error occured while creating group", error);
+}
+```
+
+
+
-This method returns an Object which has two keys: `group` & `members` . The group key has the Group Object which contains all the information of the group which is created. The members key has the `UID` of the users and the value will either be `success` or an `error` message describing why the operation to add/ban the user failed.
+Returns an object with two keys:
+- `group` — The created [`Group`](/sdk/reference/entities#group) object
+- `members` — Object with UIDs as keys and `"success"` or error message as values
## Group Class
@@ -171,3 +227,23 @@ This method returns an Object which has two keys: `group` & `members` . The grou
| scope | Yes | Scope of the logged in user. Can be: 1. Admin 2. Moderator 3. Participant |
| membersCount | No | The number of members in the groups |
| tags | Yes | A list of tags to identify specific groups. |
+
+
+---
+
+## Next Steps
+
+
+
+ Join public, private, or password-protected groups
+
+
+ Add users to an existing group
+
+
+ Fetch and filter group lists
+
+
+ Overview of all group management features
+
+
diff --git a/sdk/javascript/custom-css.mdx b/sdk/javascript/custom-css.mdx
index 56698ccf3..e02ba8841 100644
--- a/sdk/javascript/custom-css.mdx
+++ b/sdk/javascript/custom-css.mdx
@@ -1,39 +1,58 @@
---
title: "Custom CSS"
+sidebarTitle: "Custom CSS"
+description: "Customize the CometChat calling UI with custom CSS classes for buttons, video containers, name labels, and grid layouts."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```css
+/* Key CSS classes for call UI customization */
+.cc-main-container { } /* Outermost call container */
+.cc-bottom-buttons-container { } /* Bottom action buttons bar */
+.cc-name-label { } /* User name text */
+.cc-video-container { } /* Video feed container */
+.cc-end-call-icon-container { } /* End call button */
+.cc-audio-icon-container { } /* Audio toggle button */
+.cc-video-icon-container { } /* Video toggle button */
+.cc-screen-share-icon-container { } /* Screen share button */
+```
-Passing custom CSS allows you to personalize and enhance the user interface of the call screen.
-
-## Common CSS Classes
-
-There are a few common classes used for different modes in the call screen
+**Modes:** `DEFAULT` | `TILE` | `SPOTLIGHT`
+
-1. **cc-main-container** - The outermost component of the calling component is represented by a white border in the screenshots above, indicating that it acts as a container for other components.
+Style the calling UI with custom CSS to match your application's design.
-2. **cc-bottom-buttons-container** - The container located at the very bottom of the interface houses various action buttons, such as the mute/unmute audio and video, end call, settings icon, and participants icon, among others. It is represented by the red border in above screenshot.
+## Common CSS Classes
-3. **cc-name-label** - This class is passed in user name text container in all modes. It is represented by green border in the above screenshots.
+These classes are available across all call modes:
-4. **cc-video-container** - This class is passed to the video container in all modes. It is represented by orange border in the above screenshots.
+| Class | Description |
+| ----- | ----------- |
+| `cc-main-container` | Outermost container for the calling component |
+| `cc-bottom-buttons-container` | Bottom bar containing action buttons (mute, end call, etc.) |
+| `cc-name-label` | User name text container |
+| `cc-video-container` | Video feed container |
## Bottom Buttons
-1. **cc-bottom-buttons-container** - This is the container of all the buttons in calling.
-2. **cc-bottom-buttons-icon-container** - This is the div of every button in the button bar.
+| Class | Description |
+| ----- | ----------- |
+| `cc-bottom-buttons-container` | Container for all action buttons |
+| `cc-bottom-buttons-icon-container` | Individual button wrapper |
-### Individual bottom buttons CSS classes
+### Individual Button Classes
-* `cc-audio-icon-container`
-* `cc-audio-icon-container-muted`
-* `cc-video-icon-container`
-* `cc-video-icon-container-muted`
-* `cc-screen-share-icon-container`
-* `cc-switch-video-icon-container`
-* `cc-end-call-icon-container`
+- `cc-audio-icon-container` — Audio toggle button
+- `cc-audio-icon-container-muted` — Audio button (muted state)
+- `cc-video-icon-container` — Video toggle button
+- `cc-video-icon-container-muted` — Video button (muted state)
+- `cc-screen-share-icon-container` — Screen share button
+- `cc-switch-video-icon-container` — Switch camera button
+- `cc-end-call-icon-container` — End call button
-### **Example**
+### Example
@@ -158,15 +177,26 @@ The above example results in the below output:-
+### Guidelines
-### Guidelines for Customizing the Grid Layout
-
-* **CSS Classes:**
-
- * Please ensure that you only apply CSS classes specified in this documentation. Introducing CSS classes not covered here may cause unexpected UI issues.
+- Only use CSS classes documented here — custom classes may cause UI issues
+- Avoid resizing the grid container to prevent layout distortions
-* **Grid Container Resizing:**
-
- * Avoid resizing the grid container. Altering the grid container’s dimensions can negatively impact the grid layout, leading to undesirable visual distortions.
+---
-By following these recommendations, you can maintain a stable and visually consistent grid layout.
+## Next Steps
+
+
+
+ Customize video call layout and participant tiles
+
+
+ Apply blur or custom image backgrounds during calls
+
+
+ Enable screen sharing and presentation mode
+
+
+ Overview of all calling features and approaches
+
+
diff --git a/sdk/javascript/default-call.mdx b/sdk/javascript/default-call.mdx
index 180de4d73..6dff0e20e 100644
--- a/sdk/javascript/default-call.mdx
+++ b/sdk/javascript/default-call.mdx
@@ -1,7 +1,34 @@
---
title: "Ringing"
+sidebarTitle: "Ringing"
+description: "Implement a complete calling workflow with ringing, incoming/outgoing call UI, accept/reject/cancel functionality, and call session management."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// Initiate a call
+const call = new CometChat.Call("UID", CometChat.CALL_TYPE.VIDEO, CometChat.RECEIVER_TYPE.USER);
+await CometChat.initiateCall(call);
+
+// Listen for call events
+CometChat.addCallListener("ID", new CometChat.CallListener({
+ onIncomingCallReceived: (call) => { /* show incoming UI */ },
+ onOutgoingCallAccepted: (call) => { /* start session */ },
+ onOutgoingCallRejected: (call) => { /* dismiss UI */ },
+ onIncomingCallCancelled: (call) => { /* dismiss UI */ }
+}));
+
+// Accept / Reject / Cancel
+await CometChat.acceptCall(sessionId);
+await CometChat.rejectCall(sessionId, CometChat.CALL_STATUS.REJECTED);
+await CometChat.rejectCall(sessionId, CometChat.CALL_STATUS.CANCELLED);
+```
+
+**Flow:** Initiate → Receiver notified → Accept/Reject → Start session
+
+
## Overview
This section explains how to implement a complete calling workflow with ringing functionality, including incoming/outgoing call UI, call acceptance, rejection, and cancellation. Previously known as **Default Calling**.
@@ -110,6 +137,17 @@ CometChat.initiateCall(call).then(
On success, a `Call` object is returned containing the call details including a unique `sessionId` required for starting the call session.
+The `initiateCall()` method returns a [`Call`](/sdk/reference/messages#call) object. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| sessionId | `getSessionId()` | `string` | Unique session ID for the call |
+| callInitiator | `getCallInitiator()` | `User` | The user who initiated the call |
+| callReceiver | `getCallReceiver()` | `User` \| `Group` | The user or group receiving the call |
+| type | `getType()` | `string` | Type of call (`"audio"` or `"video"`) |
+| action | `getAction()` | `string` | Current call action/status |
+| initiatedAt | `getInitiatedAt()` | `number` | Timestamp when the call was initiated |
+
## Call Listeners
Register the `CallListener` to receive real-time call events. Each listener requires a unique `listenerId` string to prevent duplicate registrations and enable targeted removal.
@@ -192,6 +230,16 @@ CometChat.removeCallListener(listenerId);
| `onIncomingCallCancelled(call)` | Invoked on the receiver's device when the caller cancels before answering. Dismiss incoming call UI here. |
| `onCallEndedMessageReceived(call)` | Invoked when a call ends. The `call` contains final status and duration. Update call history here. |
+All call listener callbacks receive a [`Call`](/sdk/reference/messages#call) object. Access the data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| sessionId | `getSessionId()` | `string` | Unique session ID for the call |
+| callInitiator | `getCallInitiator()` | `User` | The user who initiated the call |
+| callReceiver | `getCallReceiver()` | `User` \| `Group` | The user or group receiving the call |
+| action | `getAction()` | `string` | Current call action/status |
+| initiatedAt | `getInitiatedAt()` | `number` | Timestamp when the call was initiated |
+
## Accept Call
When an incoming call is received via `onIncomingCallReceived()`, use `acceptCall()` to accept it. On success, start the call session.
@@ -518,3 +566,27 @@ CometChat.rejectCall(sessionId, status).then(
```
+
+
+
+Always remove call listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+
+---
+
+## Next Steps
+
+
+
+ Manage call sessions, tokens, and settings
+
+
+ Retrieve and display call history
+
+
+ Record audio and video calls
+
+
+ Install and initialize the Calls SDK
+
+
diff --git a/sdk/javascript/delete-conversation.mdx b/sdk/javascript/delete-conversation.mdx
index b91669f6a..fafb284dc 100644
--- a/sdk/javascript/delete-conversation.mdx
+++ b/sdk/javascript/delete-conversation.mdx
@@ -1,12 +1,28 @@
---
-title: "Delete A Conversation"
+title: "Delete Conversation"
+sidebarTitle: "Delete Conversation"
+description: "Delete user or group conversations using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Delete user conversation
+await CometChat.deleteConversation("UID", "user");
+
+// Delete group conversation
+await CometChat.deleteConversation("GUID", "group");
+```
+
+**Note:** Deletes only for the logged-in user. Use [REST API](https://api-explorer.cometchat.com/reference/resets-user-conversation) to delete for all participants.
+
-In case you want to delete a conversation, you can use the `deleteConversation()` method.
+
+This operation is irreversible. Deleted conversations cannot be recovered for the logged-in user.
+
-This method takes two parameters. The unique id (UID/GUID) of the conversation to be deleted & the type (user/group) of conversation to be deleted.
+Use `deleteConversation()` to delete a conversation for the logged-in user.
@@ -71,11 +87,30 @@ CometChat.deleteConversation(GUID, type).then(
-This method deletes the conversation only for the logged-in user. To delete a conversation for all the users of the conversation, please refer to our REST API documentation [here](https://api-explorer.cometchat.com/reference/resets-user-conversation).
+This deletes the conversation only for the logged-in user. To delete for all participants, use the [REST API](https://api-explorer.cometchat.com/reference/resets-user-conversation).
-The `deleteConversation()` method takes the following parameters:
+| Parameter | Description | Required |
+| --- | --- | --- |
+| conversationWith | UID or GUID of the conversation to delete | Yes |
+| conversationType | `user` or `group` | Yes |
+
+On success, returns a confirmation message string.
+
+---
-| Parameter | Description | Required |
-| ---------------- | --------------------------------------------------------------------------------- | -------- |
-| conversationWith | `UID` of the user or `GUID` of the group whose conversation you want to delete. | YES |
-| conversationType | The type of conversation you want to delete . It can be either `user` or `group`. | YES |
+## Next Steps
+
+
+
+ Fetch and filter conversation lists
+
+
+ Delete individual messages from conversations
+
+
+ Show when users are typing in conversations
+
+
+ Track message delivery and read status
+
+
diff --git a/sdk/javascript/delete-group.mdx b/sdk/javascript/delete-group.mdx
index 54bcf4137..643324371 100644
--- a/sdk/javascript/delete-group.mdx
+++ b/sdk/javascript/delete-group.mdx
@@ -1,17 +1,32 @@
---
title: "Delete A Group"
+sidebarTitle: "Delete Group"
+description: "Delete a group permanently using the CometChat JavaScript SDK. Only group admins can perform this operation."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Delete a group (admin only)
+await CometChat.deleteGroup("GUID");
+```
+
+**Requirement:** Logged-in user must be an Admin of the group.
+
+
+
+This operation is irreversible. Deleted groups and their messages cannot be recovered.
+
## Delete a Group
-To delete a group you need to use the `deleteGroup()` method. The user must be an `Admin` of the group they are trying to delete.
+Use `deleteGroup()` to permanently delete a group. Only group admins can perform this operation.
-
+
```javascript
-var GUID = "GUID";
+const GUID = "GUID";
CometChat.deleteGroup(GUID).then(
response => {
@@ -26,7 +41,7 @@ response => {
```typescript
-var GUID: string = "GUID";
+const GUID: string = "GUID";
CometChat.deleteGroup(GUID).then(
(response: boolean) => {
@@ -39,6 +54,20 @@ CometChat.deleteGroup(GUID).then(
+
+```javascript
+const GUID = "GUID";
+
+try {
+ const response = await CometChat.deleteGroup(GUID);
+ console.log("Group deleted successfully:", response);
+} catch (error) {
+ console.log("Group delete failed with exception:", error);
+}
+```
+
+
+
The `deleteGroup()` method takes the following parameters:
@@ -46,3 +75,25 @@ The `deleteGroup()` method takes the following parameters:
| Parameter | Description |
| --------- | ---------------------------------------------- |
| `GUID` | The GUID of the group you would like to delete |
+
+On success, the method resolves with a success message string confirming the operation.
+
+
+---
+
+## Next Steps
+
+
+
+ Update group name, icon, description, and metadata
+
+
+ Leave a group you are a member of
+
+
+ Create public, private, or password-protected groups
+
+
+ Overview of all group management features
+
+
diff --git a/sdk/javascript/delete-message.mdx b/sdk/javascript/delete-message.mdx
index d84b07614..12757717c 100644
--- a/sdk/javascript/delete-message.mdx
+++ b/sdk/javascript/delete-message.mdx
@@ -1,22 +1,43 @@
---
-title: "Delete A Message"
+title: "Delete Message"
+sidebarTitle: "Delete Message"
+description: "Delete messages using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Delete a message
+await CometChat.deleteMessage(messageId);
-While [deleting a message](/sdk/javascript/delete-message#delete-a-message) is straightforward, receiving events for deleted messages with CometChat has two parts:
+// Listen for real-time deletions
+CometChat.addMessageListener("ID", new CometChat.MessageListener({
+ onMessageDeleted: (message) => {
+ console.log("Deleted:", message.getId(), message.getDeletedAt());
+ }
+}));
+```
-1. Adding a listener to receive [real-time message deletes](/sdk/javascript/delete-message#real-time-message-delete-events) when your app is running.
-2. Calling a method to retrieve [missed message deletes](/sdk/javascript/delete-message#missed-message-delete-events) when your app was not running.
+**Who can delete:** Message sender, Group admin, Group moderator
+**Deleted fields:** `deletedAt` (timestamp), `deletedBy` (user who deleted)
+
-## Delete a Message
+
+This operation is irreversible. Deleted messages cannot be recovered.
+
-*In other words, as a sender, how do I delete a message?*
+Deleting a message is straightforward. Receiving delete events has two parts:
+
+1. Adding a listener for [real-time deletes](#real-time-message-delete-events) when your app is running
+2. Fetching [missed deletes](#missed-message-delete-events) when your app was offline
+
+## Delete a Message
-In case you have to delete a message, you can use the `deleteMessage()` method. This method takes the message ID of the message to be deleted.
+Use `deleteMessage()` with the message ID.
-
+
```javascript
let messageId = "ID_OF_THE_MESSAGE_YOU_WANT_TO_DELETE";
@@ -46,9 +67,32 @@ CometChat.deleteMessage(messageId).then(
+
+```javascript
+let messageId = "ID_OF_THE_MESSAGE_YOU_WANT_TO_DELETE";
+
+try {
+ const message = await CometChat.deleteMessage(messageId);
+ console.log("Message deleted", message);
+} catch (error) {
+ console.log("Message delete failed with error:", error);
+}
+```
+
+
+
-Once the message is deleted, In the `onSuccess()` callback, you get an object of the `BaseMessage` class, with the `deletedAt` field set with the timestamp of the time the message was deleted. Also, the `deletedBy` field is set. These two fields can be used to identify if the message is deleted while iterating through a list of messages.
+The deleted message object is returned with `deletedAt` (timestamp) and `deletedBy` (UID of deleter) fields set.
+
+The `deleteMessage()` method returns a [`BaseMessage`](/sdk/reference/messages#basemessage) object. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| deletedAt | `getDeletedAt()` | `number` | Timestamp when the message was deleted |
+| deletedBy | `getDeletedBy()` | `string` | UID of the user who deleted the message |
By default, CometChat allows certain roles to delete a message.
@@ -61,9 +105,7 @@ By default, CometChat allows certain roles to delete a message.
## Real-time Message Delete Events
-*In other words, as a recipient, how do I know when someone deletes a message when my app is running?*
-
-In order to receive real-time events for a message being deleted, you need to override the `onMessageDeleted()` method of the `MessageListener` class.
+Use `onMessageDeleted` in `MessageListener` to receive real-time delete events.
@@ -100,21 +142,48 @@ CometChat.addMessageListener(
-## Missed Message Delete Events
+The `onMessageDeleted` callback receives a [`BaseMessage`](/sdk/reference/messages#basemessage) object with the `deletedAt` and `deletedBy` fields set. Access the data using getter methods:
-*In other words, as a recipient, how do I know if someone deleted a message when my app was not running?*
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| deletedAt | `getDeletedAt()` | `number` | Timestamp when the message was deleted |
+| deletedBy | `getDeletedBy()` | `string` | UID of the user who deleted the message |
-When you retrieve the list of previous messages, for the messages that were deleted, the `deletedAt` and the `deletedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was deleted. Now the message with id 50 will have the `deletedAt` and the `deletedBy` fields set whenever it is pulled from the history. Also, the 101st message will be an Actionc message informing you that the message with id 50 has been deleted.
+## Missed Message Delete Events
-For the message deleted event, in the `Action` object received, the following fields can help you get the relevant information-
+When fetching message history, deleted messages have `deletedAt` and `deletedBy` fields set. Additionally, an `Action` message is created when a message is deleted.
-1. `action` - `deleted`
-2. `actionOn` - Updated message object which was deleted.
-3. `actionBy` - User object containing the details of the user who has deleted the message.
-4. `actionFor` - User/group object having the details of the receiver to which the message was sent.
+The `Action` object contains:
+- `action` — `deleted`
+- `actionOn` — Deleted message object
+- `actionBy` — User who deleted the message
+- `actionFor` — Receiver (User/Group)
+You must be the message sender or a group admin/moderator to delete a message.
+
-In order to edit or delete a message you need to be either the sender of the message or the admin/moderator of the group in which the message was sent.
+
+Always remove message listeners when they're no longer needed to prevent memory leaks.
+
-
+---
+
+## Next Steps
+
+
+
+ Edit sent messages in conversations
+
+
+ Send text, media, and custom messages
+
+
+ Listen for incoming messages in real-time
+
+
+ Report inappropriate messages
+
+
diff --git a/sdk/javascript/delivery-read-receipts.mdx b/sdk/javascript/delivery-read-receipts.mdx
index 464e319fd..3d42ec12d 100644
--- a/sdk/javascript/delivery-read-receipts.mdx
+++ b/sdk/javascript/delivery-read-receipts.mdx
@@ -1,793 +1,584 @@
---
title: "Delivery & Read Receipts"
+sidebarTitle: "Delivery & Read Receipts"
+description: "Mark messages as delivered, read, or unread and receive real-time receipt events using the CometChat JavaScript SDK."
---
+
+| Method | Description |
+| --- | --- |
+| `markAsDelivered(message)` | Mark a message as delivered |
+| `markAsRead(message)` | Mark a message as read |
+| `markConversationAsDelivered(id, type)` | Mark entire conversation as delivered |
+| `markConversationAsRead(id, type)` | Mark entire conversation as read |
+| `markMessageAsUnread(message)` | Mark a message as unread |
+| `getMessageReceipts(messageId)` | Get delivery/read receipts for a message |
-## Mark Messages as Delivered
-
-*In other words, as a recipient, how do I inform the sender that I've received a message?*
-
-You can mark the messages for a particular conversation as read using the `markAsDelivered()` method. This method takes the below parameters as input:
-
-| Parameter | Information |
-| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `messageId` | The ID of the message above which all the messages for a particular conversation are to be marked as read. |
-| `receiverId` | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id. |
-| `receiverType` | Type of the receiver. Could be either of the two values( user or group). |
-| `senderId` | The `UID` of the sender of the message. |
-
-Messages for both user & group conversations can be marked as read using this method.
-
-Ideally, you would like to mark all the messages as delivered for any conversation when the user opens the chat window for that conversation. This includes two scenarios:
-
-1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message ID of that message to the markAsDelivered() method.
-2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message ID of the message and pass it to the markAsDelivered() method.
-
-
-
-```javascript
-var messageId = "MESSAGE_ID";
-var receiverId = "MESSAGE_RECEIVER_UID";
-var receiverType = "user";
-var senderId = "MESSAGE_SENDER_UID";
-CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
-```
-
-
-
-
```javascript
-var messageId = "MESSAGE_ID";
-var receiverId = "MESSAGE_RECEIVER_GUID";
-var receiverType = "group";
-var senderId = "MESSAGE_SENDER_UID";
-CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
-```
-
-
-
-
-```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_RECEIVER_UID";
-var receiverType: string = "user";
-var senderId: string = "MESSAGE_SENDER_UID";
-CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
-```
+// Mark as delivered/read (pass message object)
+CometChat.markAsDelivered(message);
+CometChat.markAsRead(message);
-
+// Mark entire conversation
+CometChat.markConversationAsRead("UID", "user");
-
-```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_RECEIVER_GUID";
-var receiverType: string = "group";
-var senderId: string = "MESSAGE_SENDER_UID";
-CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
+// Listen for receipt events
+CometChat.addMessageListener("LISTENER_ID", new CometChat.MessageListener({
+ onMessagesDelivered: (receipt) => { },
+ onMessagesRead: (receipt) => { },
+ onMessagesDeliveredToAll: (receipt) => { }, // Groups only
+ onMessagesReadByAll: (receipt) => { } // Groups only
+}));
```
+
-
+Delivery and read receipts track whether messages have been delivered to and read by recipients.
-
+## Mark as Delivered
-This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as delivered.
+Use `markAsDelivered()` to mark messages as delivered. You can pass either a message object or individual parameters.
-In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.
+### Using Message Object
-
+
```javascript
-CometChat.markAsDelivered(
- message.getId(),
- message.getSender().getUid(),
- "user",
- message.getSender().getUid()
-).then(
+CometChat.markAsDelivered(message).then(
() => {
- console.log("mark as delivered success.");
+ console.log("Marked as delivered successfully");
},
(error) => {
- console.log(
- "An error occurred when marking the message as delivered.",
- error
- );
+ console.log("Error marking as delivered:", error);
}
);
```
-
-
-
-```javascript
-CometChat.markAsDelivered(
- message.getId(),
- message.getReceiverUid(),
- "group",
- message.getSender().getUid()
-).then(
+
+```typescript
+CometChat.markAsDelivered(message).then(
() => {
- console.log("mark as delivered success.");
+ console.log("Marked as delivered successfully");
},
- (error) => {
- console.log(
- "An error occurred when marking the message as delivered.",
- error
- );
+ (error: CometChat.CometChatException) => {
+ console.log("Error marking as delivered:", error);
}
);
```
-
+
+
+### Using Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `messageId` | ID of the message to mark as delivered |
+| `receiverId` | For user chats: sender's UID. For groups: group GUID |
+| `receiverType` | `"user"` or `"group"` |
+| `senderId` | UID of the message sender |
+
+
+
+```javascript
+let messageId = "MESSAGE_ID";
+let receiverId = "MESSAGE_SENDER_UID";
+let receiverType = "user";
+let senderId = "MESSAGE_SENDER_UID";
-
-```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_SENDER_UID";
-var receiverType: string = "user";
-var senderId: string = "MESSAGE_SENDER_UID";
CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as delivered success.");
+ console.log("Marked as delivered successfully");
},
- (error: CometChat.CometChatException) => {
- console.log(
- "An error occurred when marking the message as delivered.",
- error
- );
+ (error) => {
+ console.log("Error marking as delivered:", error);
}
);
```
-
+
+```javascript
+let messageId = "MESSAGE_ID";
+let receiverId = "GROUP_GUID";
+let receiverType = "group";
+let senderId = "MESSAGE_SENDER_UID";
-
-```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_RECEIVER_GUID";
-var receiverType: string = "group";
-var senderId: string = "MESSAGE_SENDER_UID";
CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as delivered success.");
+ console.log("Marked as delivered successfully");
},
- (error: CometChat.CometChatException) => {
- console.log(
- "An error occurred when marking the message as delivered.",
- error
- );
+ (error) => {
+ console.log("Error marking as delivered:", error);
}
);
```
-
-
-
-
-Another option the CometChat SDK provides is to pass the entire message object to the markAsDelivered() method.
-
-
-
-```javascript
-CometChat.markAsDelivered(message);
-```
-
-
-
-
+
```typescript
-let message: CometChat.BaseMessage;
-CometChat.markAsDelivered(message);
-```
+let messageId: string = "MESSAGE_ID";
+let receiverId: string = "MESSAGE_SENDER_UID";
+let receiverType: string = "user";
+let senderId: string = "MESSAGE_SENDER_UID";
-
-
-
-
-In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.
-
-
-
-```javascript
-CometChat.markAsDelivered(message).then(
+CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as delivered success.");
+ console.log("Marked as delivered successfully");
},
- (error) => {
- console.log(
- "An error occurred when marking the message as delivered.",
- error
- );
+ (error: CometChat.CometChatException) => {
+ console.log("Error marking as delivered:", error);
}
);
```
-
-
-
+
```typescript
-let message: CometChat.BaseMessage;
-CometChat.markAsDelivered(message).then(
+let messageId: string = "MESSAGE_ID";
+let receiverId: string = "GROUP_GUID";
+let receiverType: string = "group";
+let senderId: string = "MESSAGE_SENDER_UID";
+
+CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as delivered success.");
+ console.log("Marked as delivered successfully");
},
(error: CometChat.CometChatException) => {
- console.log(
- "An error occurred when marking the message as delivered.",
- error
- );
+ console.log("Error marking as delivered:", error);
}
);
```
-
-
## Mark Conversation as Delivered
-You can mark an entire conversation as delivered for a user or group using the `markConversationAsDelivered()` method. This method takes the below parameters as input:
-
-| Parameter | Information |
-| ------------------ | ------------------------------------------------------------------------------ |
-| `conversationWith` | The ID of the user (UID) or group (GUID) for the conversation. |
-| `conversationType` | Type of the conversation. Could be either `user` or `group`. |
-
-This method will mark all messages in the conversation as delivered.
+Use `markConversationAsDelivered()` to mark all messages in a conversation as delivered.
```javascript
-var conversationWith = "USER_UID";
-var conversationType = "user";
+let conversationWith = "USER_UID";
+let conversationType = "user";
CometChat.markConversationAsDelivered(conversationWith, conversationType).then(
(response) => {
console.log("Conversation marked as delivered", response);
},
(error) => {
- console.log("Error marking conversation as delivered", error);
+ console.log("Error:", error);
}
);
```
-
```javascript
-var conversationWith = "GROUP_GUID";
-var conversationType = "group";
+let conversationWith = "GROUP_GUID";
+let conversationType = "group";
CometChat.markConversationAsDelivered(conversationWith, conversationType).then(
(response) => {
console.log("Conversation marked as delivered", response);
},
(error) => {
- console.log("Error marking conversation as delivered", error);
+ console.log("Error:", error);
}
);
```
-
-
+
```typescript
-var conversationWith: string = "USER_UID";
-var conversationType: string = "user";
+let conversationWith: string = "USER_UID";
+let conversationType: string = "user";
CometChat.markConversationAsDelivered(conversationWith, conversationType).then(
(response: string) => {
console.log("Conversation marked as delivered", response);
},
(error: CometChat.CometChatException) => {
- console.log("Error marking conversation as delivered", error);
+ console.log("Error:", error);
}
);
```
-
-
+
```typescript
-var conversationWith: string = "GROUP_GUID";
-var conversationType: string = "group";
+let conversationWith: string = "GROUP_GUID";
+let conversationType: string = "group";
CometChat.markConversationAsDelivered(conversationWith, conversationType).then(
(response: string) => {
console.log("Conversation marked as delivered", response);
},
(error: CometChat.CometChatException) => {
- console.log("Error marking conversation as delivered", error);
+ console.log("Error:", error);
}
);
```
-## Mark Messages as Read
+## Mark as Read
-*In other words, as a recipient, how do I inform the sender I've read a message?*
+Use `markAsRead()` to mark messages as read. You can pass either a message object or individual parameters.
-You can mark the messages for a particular conversation as read using the `markAsRead()` method. This method takes the below parameters as input:
-
-| Parameter | Information |
-| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `messageId` | The ID of the message above which all the messages for a particular conversation are to be marked as read. |
-| `receiverId` | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id |
-| `receiverType` | Type of the receiver. Could be either of the two values( user or group) |
-| `senderId` | The `UID` of the sender of the message. |
-
-Messages for both user and group conversations can be marked as read using this method.
-
-Ideally, you would like to mark all the messages as read for any conversation when the user opens the chat window for that conversation. This includes two scenarios:
-
-1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message ID of that message to the markAsRead() method.
-2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message ID of the message and pass it to the markAsRead() method
+### Using Message Object
-
-```javascript
-var messageId = "MESSAGE_ID";
-var receiverId = "MESSAGE_SENDER_UID";
-var receiverType = "user";
-var senderId = "MESSAGE_SENDER_UID";
-CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
-```
-
-
-
-
+
```javascript
-var receiverId = "MESSAGE_RECEIVER_GUID";
-var receiverType = "group";
-var senderId = "MESSAGE_SENDER_UID";
-CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
-```
-
-
-
-
-```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_SENDER_UID";
-var receiverType: string = "user";
-var senderId: string = "MESSAGE_SENDER_UID";
-CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
+CometChat.markAsRead(message).then(
+ () => {
+ console.log("Marked as read successfully");
+ },
+ (error) => {
+ console.log("Error marking as read:", error);
+ }
+);
```
-
-
-
+
```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_RECEIVER_GUID";
-var receiverType: string = "group";
-var senderId: string = "MESSAGE_SENDER_UID";
-CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
+CometChat.markAsRead(message).then(
+ () => {
+ console.log("Marked as read successfully");
+ },
+ (error: CometChat.CometChatException) => {
+ console.log("Error marking as read:", error);
+ }
+);
```
-
-
-This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as read.
-
-In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.
+### Using Parameters
```javascript
-CometChat.markAsRead(
- message.getId(),
- message.getSender().getUid(),
- "user",
- message.getSender().getUid()
-).then(
+let messageId = "MESSAGE_ID";
+let receiverId = "MESSAGE_SENDER_UID";
+let receiverType = "user";
+let senderId = "MESSAGE_SENDER_UID";
+
+CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as read success.");
+ console.log("Marked as read successfully");
},
(error) => {
- console.log("An error occurred when marking the message as read.", error);
+ console.log("Error marking as read:", error);
}
);
```
-
-
```javascript
-CometChat.markAsRead(
- message.getId(),
- message.getReceiverUid(),
- "group",
- message.getSender().getUid()
-).then(
- () => {
- console.log("mark as read success.");
- },
- (error) => {
- console.log("An error occurred when marking the message as read.", error);
- }
-);
-```
-
-
+let messageId = "MESSAGE_ID";
+let receiverId = "GROUP_GUID";
+let receiverType = "group";
+let senderId = "MESSAGE_SENDER_UID";
-
-```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_SENDER_UID";
-var receiverType: string = "user";
-var senderId: string = "MESSAGE_SENDER_UID";
CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as read success.");
+ console.log("Marked as read successfully");
},
- (error: CometChat.CometChatException) => {
- console.log("An error occurred when marking the message as read.", error);
+ (error) => {
+ console.log("Error marking as read:", error);
}
);
```
-
-
-
+
```typescript
-var messageId: string = "MESSAGE_ID";
-var receiverId: string = "MESSAGE_RECEIVER_GUID";
-var receiverType: string = "group";
-var senderId: string = "MESSAGE_SENDER_UID";
+let messageId: string = "MESSAGE_ID";
+let receiverId: string = "MESSAGE_SENDER_UID";
+let receiverType: string = "user";
+let senderId: string = "MESSAGE_SENDER_UID";
+
CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as read success.");
+ console.log("Marked as read successfully");
},
(error: CometChat.CometChatException) => {
- console.log("An error occurred when marking the message as read.", error);
+ console.log("Error marking as read:", error);
}
);
```
-
-
-
-
-Another option the CometChat SDK provides is to pass the entire message object to the markAsRead() method.
-
-
-
-```javascript
-CometChat.markAsRead(message);
-```
-
-
-
-
+
```typescript
-let message: CometChat.BaseMessage;
-CometChat.markAsRead(message);
-```
+let messageId: string = "MESSAGE_ID";
+let receiverId: string = "GROUP_GUID";
+let receiverType: string = "group";
+let senderId: string = "MESSAGE_SENDER_UID";
-
-
-
-
-In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.
-
-
-
-```javascript
-CometChat.markAsRead(message).then(
- () => {
- console.log("mark as read success.");
- },
- (error) => {
- console.log("An error occurred when marking the message as read.", error);
- }
-);
-```
-
-
-
-
-```typescript
-let message: CometChat.BaseMessage;
-CometChat.markAsRead(message).then(
+CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(
() => {
- console.log("mark as read success.");
+ console.log("Marked as read successfully");
},
(error: CometChat.CometChatException) => {
- console.log("An error occurred when marking the message as read.", error);
+ console.log("Error marking as read:", error);
}
);
```
-
-
## Mark Conversation as Read
-You can mark an entire conversation as read for a user or group using the `markConversationAsRead()` method. This method takes the below parameters as input:
-
-| Parameter | Information |
-| ------------------ | ------------------------------------------------------------------------------ |
-| `conversationWith` | The ID of the user (UID) or group (GUID) for the conversation. |
-| `conversationType` | Type of the conversation. Could be either `user` or `group`. |
-
-This method will mark all messages in the conversation as read.
+Use `markConversationAsRead()` to mark all messages in a conversation as read.
```javascript
-var conversationWith = "USER_UID";
-var conversationType = "user";
+let conversationWith = "USER_UID";
+let conversationType = "user";
CometChat.markConversationAsRead(conversationWith, conversationType).then(
(response) => {
console.log("Conversation marked as read", response);
},
(error) => {
- console.log("Error marking conversation as read", error);
+ console.log("Error:", error);
}
);
```
-
```javascript
-var conversationWith = "GROUP_GUID";
-var conversationType = "group";
+let conversationWith = "GROUP_GUID";
+let conversationType = "group";
CometChat.markConversationAsRead(conversationWith, conversationType).then(
(response) => {
console.log("Conversation marked as read", response);
},
(error) => {
- console.log("Error marking conversation as read", error);
+ console.log("Error:", error);
}
);
```
-
-
+
```typescript
-var conversationWith: string = "USER_UID";
-var conversationType: string = "user";
+let conversationWith: string = "USER_UID";
+let conversationType: string = "user";
CometChat.markConversationAsRead(conversationWith, conversationType).then(
(response: string) => {
console.log("Conversation marked as read", response);
},
(error: CometChat.CometChatException) => {
- console.log("Error marking conversation as read", error);
+ console.log("Error:", error);
}
);
```
-
-
+
```typescript
-var conversationWith: string = "GROUP_GUID";
-var conversationType: string = "group";
+let conversationWith: string = "GROUP_GUID";
+let conversationType: string = "group";
CometChat.markConversationAsRead(conversationWith, conversationType).then(
(response: string) => {
console.log("Conversation marked as read", response);
},
(error: CometChat.CometChatException) => {
- console.log("Error marking conversation as read", error);
+ console.log("Error:", error);
}
);
```
-## Mark Messages as Unread
-
-The Mark messages as Unread feature allows users to designate specific messages or conversations as unread, even if they have been previously viewed.
-
-This feature is valuable for users who want to revisit and respond to important messages or conversations later, ensuring they don't forget or overlook them.
+## Mark as Unread
-In other words, how I can mark a message as unread?
-
-You can mark the messages for a particular conversation as unread using the `markMessageAsUnread()` method. This method takes the below parameters as input:
-
-| Parameter | Information |
-| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| message | To mark a message as unread, pass a non-null `BaseMessage` instance to the `markMessageAsUnread()` function. All messages below that message in the conversation will contribute to the unread messages count. Example: When User B sends User A a total of 10 messages, and User A invokes the `markMessageAsUnread()` method on the fifth message, all messages located below the fifth message within the conversation list will be designated as unread. This results in a notification indicating there are 5 unread messages in the conversation list. |
+Use `markMessageAsUnread()` to mark a message as unread. All messages below that message will contribute to the unread count.
You cannot mark your own messages as unread. This method only works for messages received from other users.
-
-```javascript
-CometChat.markMessageAsUnread(message);
-```
-
-
-
-
-```typescript
-let message: CometChat.BaseMessage;
-CometChat.markMessageAsUnread(message);
-```
-
-
-
-
-
-In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback).` On success, this method returns an updated `Conversation` object with the updated unread message count and other conversation data.
-
-
-
+
```javascript
CometChat.markMessageAsUnread(message).then(
(conversation) => {
- console.log("mark messages as unread success.", conversation);
- console.log("Unread message count:", conversation.getUnreadMessageCount());
+ console.log("Marked as unread successfully", conversation);
+ console.log("Unread count:", conversation.getUnreadMessageCount());
},
(error) => {
- console.log("An error occurred when marking the message as unread.", error);
+ console.log("Error marking as unread:", error);
}
);
```
-
-
```typescript
-let message: CometChat.BaseMessage;
CometChat.markMessageAsUnread(message).then(
(conversation: CometChat.Conversation) => {
- console.log("mark messages as unread success.", conversation);
- console.log("Unread message count:", conversation.getUnreadMessageCount());
+ console.log("Marked as unread successfully", conversation);
+ console.log("Unread count:", conversation.getUnreadMessageCount());
},
(error: CometChat.CometChatException) => {
- console.log("An error occurred when marking the message as unread.", error);
+ console.log("Error marking as unread:", error);
}
);
```
-
-
-Receive Delivery & Read Receipts
+On success, returns an updated [`Conversation`](/sdk/reference/entities#conversation) object with the new unread message count.
-*In other words, as a recipient, how do I know when a message I sent has been delivered or read by someone?*
+## Real-Time Receipt Events
-### Real-time events
+Register a `MessageListener` to receive delivery and read receipt events.
-1. `onMessagesDelivered()` - This event is triggered when a message is delivered to a user.
-2. `onMessagesRead()` - This event is triggered when a message is read by a user.
-3. `onMessagesDeliveredToAll()` - This event is triggered when a group message is delivered to all members of the group. This event is only for Group conversations.
-4. `onMessagesReadByAll()` - This event is triggered when a group message is read by all members of the group. This event is only for Group conversations.
+| Callback | Description |
+| --- | --- |
+| `onMessagesDelivered` | Message delivered to a user |
+| `onMessagesRead` | Message read by a user |
+| `onMessagesDeliveredToAll` | Group message delivered to all members |
+| `onMessagesReadByAll` | Group message read by all members |
-
+
```javascript
-let listenerId = "UNIQUE_LISTENER_ID";
+let listenerID = "UNIQUE_LISTENER_ID";
CometChat.addMessageListener(
- "listenerId",
+ listenerID,
new CometChat.MessageListener({
onMessagesDelivered: (messageReceipt) => {
- console.log("Message is delivered to a user: ", { messageReceipt });
+ console.log("Message delivered:", messageReceipt);
},
onMessagesRead: (messageReceipt) => {
- console.log("Message is read by a user: ", { messageReceipt });
+ console.log("Message read:", messageReceipt);
},
- /** This event is only for Group Conversation. */
onMessagesDeliveredToAll: (messageReceipt) => {
- console.log("Message delivered to all members of group: ", {
- messageReceipt,
- });
+ console.log("Message delivered to all group members:", messageReceipt);
},
- /** This event is only for Group Conversation. */
onMessagesReadByAll: (messageReceipt) => {
- console.log("Message read by all members of group: ", { messageReceipt });
- },
+ console.log("Message read by all group members:", messageReceipt);
+ }
})
);
```
-
-
```typescript
-let listenerId: string = "UNIQUE_LISTENER_ID";
+let listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.addMessageListener(
- listenerId,
+ listenerID,
new CometChat.MessageListener({
onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => {
- console.log("Message is delivered to a user: ", { messageReceipt });
+ console.log("Message delivered:", messageReceipt);
},
onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => {
- console.log("Message is read by a user: ", { messageReceipt });
+ console.log("Message read:", messageReceipt);
},
- /** This event is only for Group Conversation. */
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
- console.log("Message delivered to all members of group: ", {
- messageReceipt,
- });
+ console.log("Message delivered to all group members:", messageReceipt);
},
- /** This event is only for Group Conversation. */
onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => {
- console.log("Message read by all members of group: ", { messageReceipt });
- },
+ console.log("Message read by all group members:", messageReceipt);
+ }
})
);
```
-
-
-You will receive events in the form of `MessageReceipt` objects. The message receipt contains the below parameters:
+
+Always remove listeners when no longer needed to prevent memory leaks.
-| Parameter | Information |
-| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
-| `messageId` | The Id of the message prior to which all the messages for that particular conversation have been marked as read. |
-| `sender` | User object containing the details of the user who has marked the message as read. System User for `deliveredToAll` & `readByAll` events. |
-| `receiverId` | Id of the receiver whose conversation has been marked as read. |
-| `receiverType` | type of the receiver (user/group) |
-| `receiptType` | Type of the receipt (read/delivered) |
-| `deliveredAt` | The timestamp of the time when the message was delivered. This will only be present if the receiptType is delivered. |
-| `readAt` | The timestamp of the time when the message was read. This will only be present when the receiptType is read. |
+```javascript
+CometChat.removeMessageListener("UNIQUE_LISTENER_ID");
+```
+
-### Missed Receipts
+### MessageReceipt Object
-You will receive message receipts when you load offline messages. While fetching messages in bulk, the message object will have two fields i.e. `deliveredAt` and `readAt` which hold the timestamp for the time the message was delivered and read respectively. Using these two variables, the delivery and read status for a message can be obtained.
+The listener callbacks receive a [`MessageReceipt`](/sdk/reference/auxiliary#messagereceipt) object:
-However, for a group message, if you wish to fetch the `deliveredAt` and `readAt` fields of individual member of the group you can use the below-described method.
+| Field | Getter | Return Type | Description |
+| --- | --- | --- | --- |
+| messageId | `getMessageId()` | `string` | ID of the message |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | User who triggered the receipt |
+| receiverId | `getReceiverId()` | `string` | ID of the receiver |
+| receiverType | `getReceiverType()` | `string` | `"user"` or `"group"` |
+| receiptType | `getReceiptType()` | `string` | `"delivery"` or `"read"` |
+| deliveredAt | `getDeliveredAt()` | `number` | Timestamp when delivered |
+| readAt | `getReadAt()` | `number` | Timestamp when read |
-### Receipt History for a Single Message
+## Get Receipt History
-To fetch the message receipts, you can use the `getMessageReceipts()` method.
+Use `getMessageReceipts()` to fetch delivery and read receipts for a specific message. Useful for group messages to see which members have received/read the message.
-
+
```javascript
-let messageId = msgId;
+let messageId = 123;
+
CometChat.getMessageReceipts(messageId).then(
(receipts) => {
- console.log("Message details fetched:", receipts);
+ console.log("Message receipts:", receipts);
},
(error) => {
- console.log("Error in getting messag details ", error);
+ console.log("Error fetching receipts:", error);
}
);
```
-
-
```typescript
-let messageId: number = 1;
+let messageId: number = 123;
+
CometChat.getMessageReceipts(messageId).then(
(receipts: CometChat.MessageReceipt[]) => {
- console.log("Message details fetched:", receipts);
+ console.log("Message receipts:", receipts);
},
(error: CometChat.CometChatException) => {
- console.log("Error in getting messag details ", error);
+ console.log("Error fetching receipts:", error);
}
);
```
-
-
-You will receive a list of `MessageReceipt` objects.
+Returns an array of [`MessageReceipt`](/sdk/reference/auxiliary#messagereceipt) objects.
-
+## Missed Receipts
-The following features will be available only if the **Enhanced Messaging Status** feature is enabled for your app.
+When fetching messages, each message object includes `deliveredAt` and `readAt` timestamps indicating when the message was delivered and read.
-* `onMessagesDeliveredToAll` event,
-* `onMessagesReadByAll` event,
-* `deliveredAt` field in a group message,
-* `readAt` field in a group message.
-* `markMessageAsUnread` method.
+```javascript
+let deliveredAt = message.getDeliveredAt();
+let readAt = message.getReadAt();
+```
+
+
+The following features require **Enhanced Messaging Status** to be enabled for your app:
+- `onMessagesDeliveredToAll` event
+- `onMessagesReadByAll` event
+- `deliveredAt` field in group messages
+- `readAt` field in group messages
+- `markMessageAsUnread()` method
+
+
+---
-
+## Next Steps
+
+
+
+ Show real-time typing status in conversations
+
+
+ Listen for incoming messages in real time
+
+
+ Fetch conversation list with unread counts
+
+
+ Complete reference for all SDK event listeners
+
+
diff --git a/sdk/javascript/direct-call.mdx b/sdk/javascript/direct-call.mdx
index 0bedb0234..110a9d887 100644
--- a/sdk/javascript/direct-call.mdx
+++ b/sdk/javascript/direct-call.mdx
@@ -1,7 +1,31 @@
---
title: "Call Session"
+sidebarTitle: "Call Session"
+description: "Learn how to generate call tokens, start and manage call sessions, configure call settings, and handle call events using the CometChat JavaScript Calls SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// Generate call token
+const callToken = await CometChatCalls.generateToken(sessionId, authToken);
+
+// Build call settings
+const callSettings = new CometChatCalls.CallSettingsBuilder()
+ .enableDefaultLayout(true)
+ .setIsAudioOnlyCall(false)
+ .setCallListener(callListener)
+ .build();
+
+// Start call session
+CometChatCalls.startSession(callToken.token, callSettings, htmlElement);
+
+// End call session
+CometChatCalls.endSession();
+```
+
+
## Overview
This section demonstrates how to start a call session in a web application. Previously known as **Direct Calling**.
@@ -332,6 +356,16 @@ CometChatCalls.removeCallEventListener(listenerId);
| `onCallSwitchedToVideo(event)` | Invoked when an audio call is upgraded to a video call. Contains `sessionId`, `initiator`, and `responder`. |
| `onError(error)` | Invoked when an error occurs during the call session. |
+The ringing flow methods (`initiateCall()`, `acceptCall()`, `rejectCall()`, `endCall()`) return [`Call`](/sdk/reference/messages#call) objects. Access the data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| sessionId | `getSessionId()` | `string` | Unique session ID for the call |
+| callInitiator | `getCallInitiator()` | `User` | The user who initiated the call |
+| callReceiver | `getCallReceiver()` | `User` \| `Group` | The user or group receiving the call |
+| action | `getAction()` | `string` | Current call action/status |
+| initiatedAt | `getInitiatedAt()` | `number` | Timestamp when the call was initiated |
+
## End Call Session
Ending a call session properly is essential to release media resources (camera, microphone, network connections) and update call state across all participants. The termination process differs based on whether you're using the Ringing flow or Session Only flow.
@@ -695,14 +729,36 @@ CometChatCalls.switchToVideoCall();
Terminates the current call session and releases all media resources (camera, microphone, network connections). After calling this method, the call view should be closed.
-
+
```javascript
CometChatCalls.endSession();
```
-
-```typescript
-CometChatCalls.endSession();
-```
-
+
+
+Always remove call event listeners when they're no longer needed (e.g., on component unmount or when the call screen is closed). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+```javascript
+CometChatCalls.removeCallEventListener("UNIQUE_LISTENER_ID");
+```
+
+
+---
+
+## Next Steps
+
+
+
+ Implement calls with incoming/outgoing ringing UI
+
+
+ Record call sessions for playback
+
+
+ Customize the video layout and main video container
+
+
+ Retrieve and display call history
+
+
diff --git a/sdk/javascript/edit-message.mdx b/sdk/javascript/edit-message.mdx
index 8b91b4aea..4587506ca 100644
--- a/sdk/javascript/edit-message.mdx
+++ b/sdk/javascript/edit-message.mdx
@@ -1,23 +1,37 @@
---
-title: "Edit A Message"
+title: "Edit Message"
+sidebarTitle: "Edit Message"
+description: "Edit text and custom messages using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Edit a text message
+const textMessage = new CometChat.TextMessage(receiverID, "Updated text", receiverType);
+textMessage.setId(messageId);
+await CometChat.editMessage(textMessage);
-While [editing a message](/sdk/javascript/edit-message#edit-a-message) is straightforward, receiving events for edited messages with CometChat has two parts:
+// Listen for real-time edits
+CometChat.addMessageListener("edits", new CometChat.MessageListener({
+ onMessageEdited: (message) => console.log("Edited:", message)
+}));
+```
+
-1. Adding a listener to receive [real-time message edits](/sdk/javascript/edit-message#real-time-message-edit-events) when your app is running
-2. Calling a method to retrieve [missed message edits](/sdk/javascript/edit-message#missed-message-edit-events) when your app was not running
+Editing a message is straightforward. Receiving edit events has two parts:
-## Edit a Message
+1. Adding a listener for [real-time edits](#real-time-message-edit-events) when your app is running
+2. Fetching [missed edits](#missed-message-edit-events) when your app was offline
-*In other words, as a sender, how do I edit a message?*
+## Edit a Message
-In order to edit a message, you can use the `editMessage()` method. This method takes an object of the `BaseMessage` class. At the moment, you are only allowed to edit `TextMessage` and `CustomMessage`. Thus, the `BaseMessage` object must either be a Text or a Custom Message.
+Use `editMessage()` with a [`TextMessage`](/sdk/reference/messages#textmessage) or [`CustomMessage`](/sdk/reference/messages#custommessage) object. Set the message ID using `setId()`.
### Add/Update Tags
-While editing a message, you can update the tags associated with the Message. You can use the `setTags()` method to do so. The tags added while editing a message will replace the tags set when the message was sent.
+Use `setTags()` to update tags when editing. New tags replace existing ones.
@@ -58,7 +72,7 @@ customMessage.setTags(tags);
-Once the message object is ready, you can use the `editMessage()` method and pass the message object to it.
+Once the message object is ready, call `editMessage()`.
@@ -103,9 +117,39 @@ CometChat.editMessage(textMessage).then(
+
+```javascript
+try {
+ let receiverID = "RECEIVER_UID";
+ let messageText = "Hello world!";
+ let receiverType = CometChat.RECEIVER_TYPE.USER;
+ let messageId = "MESSAGE_ID_OF_THE_MESSAGE_TO_BE_EDITED";
+ let textMessage = new CometChat.TextMessage(receiverID, messageText, receiverType);
+
+ textMessage.setId(messageId);
+
+ const message = await CometChat.editMessage(textMessage);
+ console.log("Message Edited", message);
+} catch (error) {
+ console.log("Message editing failed with error:", error);
+}
+```
+
+
+
-The object of the edited message will be returned in the `onSuccess()` callback method of the listener. The message object will contain the `editedAt` field set with the timestamp of the time the message was edited. This will help you identify if the message was edited while iterating through the list of messages. The `editedBy` field is also set to the UID of the user who edited the message.
+The edited message object is returned with `editedAt` (timestamp) and `editedBy` (UID of editor) fields set.
+
+The `editMessage()` method returns a [`BaseMessage`](/sdk/reference/messages#basemessage) object (or a subclass like [`TextMessage`](/sdk/reference/messages#textmessage)). Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| text | `getText()` | `string` | Updated text content (TextMessage only) |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| editedAt | `getEditedAt()` | `number` | Timestamp when the message was edited |
+| editedBy | `getEditedBy()` | `string` | UID of the user who edited the message |
By default, CometChat allows certain roles to edit a message.
@@ -118,9 +162,7 @@ By default, CometChat allows certain roles to edit a message.
## Real-time Message Edit Events
-*In other words, as a recipient, how do I know when someone has edited their message when my app is running?*
-
-In order to receive real-time events for message being edited, you need to override the `onMessageEdited()` method of the `MessageListener` class.
+Use `onMessageEdited` in `MessageListener` to receive real-time edit events.
@@ -157,21 +199,52 @@ new CometChat.MessageListener({
-## Missed Message Edit Events
+
+Always remove message listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
-*In other words, as a recipient, how do I know when someone edited their message when my app was not running?*
+```javascript
+CometChat.removeMessageListener("UNIQUE_LISTENER_ID");
+```
+
-When you retrieve the list of previous messages, for the message that was edited, the `editedAt` and the `editedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was edited. Now the message with id 50 will have the `editedAt` and the `editedBy` fields set whenever it is pulled from the history. Also, the 101st message will be and \[Action] message informing you that the message with id 50 has been edited.
+The `onMessageEdited` callback receives a [`BaseMessage`](/sdk/reference/messages#basemessage) object with the `editedAt` and `editedBy` fields set. Access the data using getter methods:
-For the message edited event, in the `Action` object received, the following fields can help you get the relevant information-
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| editedAt | `getEditedAt()` | `number` | Timestamp when the message was edited |
+| editedBy | `getEditedBy()` | `string` | UID of the user who edited the message |
-1. `action` - `edited`
-2. `actionOn` - Updated message object with the edited details.
-3. `actionBy` - User object containing the details of the user who has edited the message.
-4. `actionFor` - User/group object having the details of the receiver to which the message was sent.
+## Missed Message Edit Events
-
+When fetching message history, edited messages have `editedAt` and `editedBy` fields set. Additionally, an `Action` message is created when a message is edited.
-In order to edit a message, you need to be either the sender of the message or the admin/moderator of the group in which the message was sent.
+The `Action` object contains:
+- `action` — `edited`
+- `actionOn` — Updated message object
+- `actionBy` — User who edited the message
+- `actionFor` — Receiver (User/Group)
+
+You must be the message sender or a group admin/moderator to edit a message.
+
+---
+
+## Next Steps
+
+
+
+ Remove messages from conversations
+
+
+ Send text, media, and custom messages
+
+
+ Organize conversations with message threads
+
+
+ Listen for incoming messages in real time
+
+
diff --git a/sdk/javascript/flag-message.mdx b/sdk/javascript/flag-message.mdx
index 350149f5d..3e310ff16 100644
--- a/sdk/javascript/flag-message.mdx
+++ b/sdk/javascript/flag-message.mdx
@@ -1,7 +1,24 @@
---
title: "Flag Message"
+sidebarTitle: "Flag Message"
+description: "Flag inappropriate messages for moderation review using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// Get available flag reasons
+const reasons = await CometChat.getFlagReasons();
+
+// Flag a message
+await CometChat.flagMessage("MESSAGE_ID", {
+ reasonId: "spam",
+ remark: "Promotional content"
+});
+```
+
+
## Overview
Flagging messages allows users to report inappropriate content to moderators or administrators. When a message is flagged, it appears in the [CometChat Dashboard](https://app.cometchat.com) under **Moderation > Flagged Messages** for review.
@@ -149,6 +166,15 @@ To flag a message, use the `flagMessage()` method with the message ID and a payl
}
```
+The `flagMessage()` method flags a [`BaseMessage`](/sdk/reference/messages#basemessage) object for moderation. The flagged message can be identified using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| type | `getType()` | `string` | Message type (`text`, `image`, `custom`, etc.) |
+| sentAt | `getSentAt()` | `number` | Timestamp when the message was sent |
+
## Complete Example
Here's a complete implementation showing how to build a report message flow:
@@ -218,3 +244,22 @@ if (result.success) {
showToast("Message reported successfully");
}
```
+
+---
+
+## Next Steps
+
+
+
+ Automate content moderation with AI
+
+
+ Remove messages from conversations
+
+
+ Listen for incoming messages in real time
+
+
+ Send text, media, and custom messages
+
+
diff --git a/sdk/javascript/group-add-members.mdx b/sdk/javascript/group-add-members.mdx
index 98170bf0b..d12c385ba 100644
--- a/sdk/javascript/group-add-members.mdx
+++ b/sdk/javascript/group-add-members.mdx
@@ -1,16 +1,37 @@
---
title: "Add Members To A Group"
+sidebarTitle: "Add Members"
+description: "Learn how to add members to a group, receive real-time member added events, and handle missed events using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Add members to a group
+const members = [
+ new CometChat.GroupMember("UID", CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT)
+];
+await CometChat.addMembersToGroup("GUID", members, []);
+
+// Listen for member added events
+CometChat.addGroupListener("listener", new CometChat.GroupListener({
+ onMemberAddedToGroup: (message, userAdded, userAddedBy, userAddedIn) => { }
+}));
+```
+
+
+You can add members to a group programmatically and listen for real-time events when members are added.
## Add Members to Group
-You can add members to the group using the `addMembersToGroup()` method. This method takes the below parameters:
+Use `addMembersToGroup()` to add members to a [Group](/sdk/reference/entities#group).
-1. `GUID` - GUID of the group the members are to be added to.
-2. `members` - This is a list of `GroupMember` objects. In order to add members, you need to create an object of the `GroupMember` class. The UID and the scope of the `GroupMember` are mandatory.
-3. `bannedMembers` - This is the list of `UID's` that need to be banned from the Group. This can be set to `null` if there are no members to be banned.
+| Parameter | Description |
+|-----------|-------------|
+| `GUID` | The group to add members to |
+| `members` | Array of [GroupMember](/sdk/reference/entities#groupmember) objects (UID and scope required) |
+| `bannedMembers` | Array of UIDs to ban (can be empty) |
@@ -57,24 +78,20 @@ CometChat.addMembersToGroup(GUID, membersList, []).then(
It will return a Array which will contain the `UID` of the users and the value will either be `success` or an error message describing why the operation to add the user to the group.
-## Real-Time Group Member Added Events
+The method returns a response object where each key is a `UID` and the value is either `"success"` or an error message.
-*In other words, as a member of a group, how do I know when someone is added to the group when my app is running?*
+## Real-Time Group Member Added Events
-
When a group member is added by another member, this event is triggered. When a user joins a group on their own, the joined event is triggered.
-
-To receive real-time events whenever a new member is added to a group, you need to implement the `onMemberAddedToGroup()` methods of the `GroupListener` class.
-
-`onMemberAddedToGroup()` - This method is triggered when any user is added to the group so that the logged in user is informed of the other members added to the group.
+Implement `onMemberAddedToGroup()` in `GroupListener` to receive real-time notifications when members are added.
```javascript
-var listenerID = "UNIQUE_LISTENER_ID";
+const listenerID = "UNIQUE_LISTENER_ID";
CometChat.addGroupListener(
listenerID,
@@ -95,7 +112,7 @@ CometChat.addGroupListener(
```typescript
-var listenerID: string = "UNIQUE_LISTENER_ID";
+const listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.addGroupListener(
listenerID,
@@ -121,15 +138,40 @@ CometChat.addGroupListener(
+
+Always remove group listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+```javascript
+CometChat.removeGroupListener("UNIQUE_LISTENER_ID");
+```
+
+
## Member Added to Group event in Message History
-*In other words, as a member of a group, how do I know when someone is added to the group when my app is not running?*
+When fetching previous messages, member additions appear as [Action](/sdk/reference/messages#action) messages (a subclass of `BaseMessage`).
-When you retrieve the list of previous messages if a member has been added to any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class.
+| Field | Value/Type | Description |
+|-------|------------|-------------|
+| `action` | `"added"` | The action type |
+| `actionOn` | [User](/sdk/reference/entities#user) | The user who was added |
+| `actionBy` | [User](/sdk/reference/entities#user) | The user who added the member |
+| `actionFor` | [Group](/sdk/reference/entities#group) | The group the member was added to |
-For the group member added event, in the `Action` object received, the following fields can help you get the relevant information-
+---
-1. `action` - `added`
-2. `actionOn` - User object containing the details of the user who was added to the group
-3. `actionBy` - User object containing the details of the user who added the member to the group
-4. `actionFor` - Group object containing the details of the group to which the member was added
+## Next Steps
+
+
+
+ Remove or ban members from a group
+
+
+ Promote or demote group members
+
+
+ Fetch the list of members in a group
+
+
+ Allow users to join public or password-protected groups
+
+
diff --git a/sdk/javascript/group-change-member-scope.mdx b/sdk/javascript/group-change-member-scope.mdx
index 422ae34b8..da3338c2b 100644
--- a/sdk/javascript/group-change-member-scope.mdx
+++ b/sdk/javascript/group-change-member-scope.mdx
@@ -1,12 +1,28 @@
---
title: "Change Member Scope"
+sidebarTitle: "Change Scope"
+description: "Learn how to change group member roles (admin, moderator, participant) and receive real-time scope change events using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Change member scope to admin
+await CometChat.updateGroupMemberScope("GUID", "UID", CometChat.GROUP_MEMBER_SCOPE.ADMIN);
+
+// Listen for scope change events
+CometChat.addGroupListener("listener", new CometChat.GroupListener({
+ onGroupMemberScopeChanged: (message, changedUser, newScope, oldScope, changedGroup) => { }
+}));
+```
+
+
+You can change the role of a group member between admin, moderator, and participant.
## Change Scope of a Group Member
-In order to change the scope of a group member, you can use the `changeGroupMemberScope()`.
+Use `updateGroupMemberScope()` to change a member's role within a [Group](/sdk/reference/entities#group).
@@ -49,17 +65,17 @@ This method takes the below parameters:
| Parameter | Description |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `UID` | The UID of the member whose scope you would like to change |
-| `GUID` | The GUID of the group for which the member's scope needs to be changed |
-| `scope` | The updated scope of the member. This can be either of the 3 values: 1.`CometChat.SCOPE.ADMIN`2.`CometChat.SCOPE.MODERATOR` 3.`CometChat.SCOPE.PARTICIPANT` |
+| `UID` | The UID of the member whose scope you want to change |
+| `GUID` | The GUID of the group |
+| `scope` | The new scope: `CometChat.SCOPE.ADMIN`, `CometChat.SCOPE.MODERATOR`, or `CometChat.SCOPE.PARTICIPANT` |
-The default scope of any member is `participant`. Only the **Admin** of the group can change the scope of any participant in the group.
+The default scope is `participant`. Only Admins can change member scopes.
-## Real-Time Group Member Scope Changed Events
+On success, the method resolves with a success message string.
-*In other words, as a member of a group, how do I know when someone's scope is changed when my app is running?*
+## Real-Time Group Member Scope Changed Events
-In order to receive real-time events for the change member scope event, you will need to override the `onGroupMemberScopeChanged()` method of the `GroupListener` class
+Implement `onGroupMemberScopeChanged()` in `GroupListener` to receive real-time notifications when a member's scope changes.
@@ -96,17 +112,42 @@ CometChat.addGroupListener(
+
+Always remove group listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+```javascript
+CometChat.removeGroupListener("UNIQUE_LISTENER_ID");
+```
+
+
## Missed Group Member Scope Changed Events
-*In other words, as a member of a group, how do I know when someone's scope is changed when my app is not running?*
+When fetching previous messages, scope changes appear as [Action](/sdk/reference/messages#action) messages (a subclass of `BaseMessage`).
-When you retrieve the list of previous messages if a member's scope has been changed for any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class.
+| Field | Value/Type | Description |
+|-------|------------|-------------|
+| `action` | `"scopeChanged"` | The action type |
+| `actionOn` | [User](/sdk/reference/entities#user) | The user whose scope changed |
+| `actionBy` | [User](/sdk/reference/entities#user) | The user who changed the scope |
+| `actionFor` | [Group](/sdk/reference/entities#group) | The group |
+| `oldScope` | `string` | The previous scope |
+| `newScope` | `string` | The new scope |
-For the group member scope changed event, in the `Action` object received, the following fields can help you get the relevant information-
+---
-1. `action` - `scopeChanged`
-2. `actionOn` - User object containing the details of the user whose scope has been changed
-3. `actionBy` - User object containing the details of the user who changed the scope of the member
-4. `actionFor` - Group object containing the details of the group in which the member scope was changed
-5. `oldScope` - The original scope of the member
-6. `newScope` - The updated scope of the member
+## Next Steps
+
+
+
+ Transfer ownership of a group to another member
+
+
+ Remove or ban members from a group
+
+
+ Add new members to a group
+
+
+ Fetch the list of members in a group
+
+
diff --git a/sdk/javascript/group-kick-ban-members.mdx b/sdk/javascript/group-kick-ban-members.mdx
index 7433686cd..a711f8283 100644
--- a/sdk/javascript/group-kick-ban-members.mdx
+++ b/sdk/javascript/group-kick-ban-members.mdx
@@ -1,8 +1,27 @@
---
title: "Ban Or Kick Member From A Group"
+sidebarTitle: "Kick & Ban Members"
+description: "Learn how to kick, ban, and unban group members, fetch banned member lists, and receive real-time events using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Kick a member
+await CometChat.kickGroupMember("GUID", "UID");
+
+// Ban a member
+await CometChat.banGroupMember("GUID", "UID");
+
+// Unban a member
+await CometChat.unbanGroupMember("GUID", "UID");
+
+// Fetch banned members
+const request = new CometChat.BannedMembersRequestBuilder("GUID").setLimit(30).build();
+const bannedMembers = await request.fetchNext();
+```
+
There are certain actions that can be performed on the group members:
@@ -11,17 +30,17 @@ There are certain actions that can be performed on the group members:
3. Unban a member from the group
4. Update the scope of the member of the group
-All the above actions can only be performed by the **Admin** or the **Moderator** of the group.
+Only Admins or Moderators can perform these actions.
## Kick a Group Member
-The Admin or Moderator of a group can kick a member out of the group using the `kickGroupMember()` method.
+Admins or Moderators can remove a member using `kickGroupMember()`. The kicked user can rejoin the group later.
```javascript
-var GUID = "GUID";
-var UID = "UID";
+const GUID = "GUID";
+const UID = "UID";
CometChat.kickGroupMember(GUID, UID).then(
response => {
@@ -52,24 +71,24 @@ CometChat.kickGroupMember(GUID, UID).then(
-The `kickGroupMember()` takes following parameters
+The `kickGroupMember()` method takes the following parameters:
| Parameter | Description |
| --------- | ----------------------------------------------------- |
-| `UID` | The UID of the user to be kicked. |
+| `UID` | The UID of the user to be kicked |
| `GUID` | The GUID of the group from which user is to be kicked |
-The kicked user will be no longer part of the group and can not perform any actions in the group, but the kicked user can rejoin the group.
+On success, the method resolves with a success message string.
## Ban a Group Member
-The Admin or Moderator of the group can ban a member from the group using the `banGroupMember()` method.
+Admins or Moderators can ban a member using `banGroupMember()`. Unlike kicked users, banned users cannot rejoin until unbanned.
```javascript
-var GUID = "GUID";
-var UID = "UID";
+const GUID = "GUID";
+const UID = "UID";
CometChat.banGroupMember(GUID, UID).then(
response => {
@@ -104,20 +123,20 @@ The `banGroupMember()` method takes the following parameters:
| Parameter | Description |
| --------- | ------------------------------------------------------ |
-| `UID` | The UID of the user to be banned. |
-| `GUID` | The GUID of the group from which user is to be banned. |
+| `UID` | The UID of the user to be banned |
+| `GUID` | The GUID of the group from which user is to be banned |
-The banned user will be no longer part of the group and can not perform any actions in the group. A banned user cannot rejoin the same group without being unbanned.
+On success, the method resolves with a success message string.
## Unban a Banned Group Member from a Group
-Only Admin or Moderators of the group can unban a previously banned member from the group using the `unbanGroupMember()` method.
+Admins or Moderators can unban a previously banned member using `unbanGroupMember()`.
```javascript
-var GUID = "GUID";
-var UID = "UID";
+const GUID = "GUID";
+const UID = "UID";
CometChat.unbanGroupMember(GUID, UID).then(
response => {
@@ -152,22 +171,18 @@ The `unbanGroupMember()` method takes the following parameters
| Parameter | Description |
| --------- | ---------------------------------------------------- |
-| `UID` | The UID of the user to be unbanned. |
-| `GUID` | The UID of the group from which user is to be banned |
+| `UID` | The UID of the user to be unbanned |
+| `GUID` | The GUID of the group from which user is to be unbanned |
-The unbanned user can now rejoin the group.
+Once unbanned, the user can rejoin the group.
## Get List of Banned Members for a Group
-In order to fetch the list of banned groups members for a group, you can use the `BannedGroupMembersRequest` class. To use this class i.e to create an object of the BannedGroupMembersRequest class, you need to use the `BannedGroupMembersRequestBuilder` class. The `BannedGroupMembersRequestBuilder` class allows you to set the parameters based on which the banned group members are to be fetched.
-
-The `BannedGroupMembersRequestBuilder` class allows you to set the below parameters:
-
-The `GUID` of the group for which the banned members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class.
+Use `BannedMembersRequestBuilder` to fetch banned members of a [Group](/sdk/reference/entities#group). The GUID must be specified in the constructor.
### Set Limit
-This method sets the limit i.e. the number of banned members that should be fetched in a single iteration.
+Sets the number of banned members to fetch per request.
@@ -196,7 +211,7 @@ let bannedGroupMembersRequest: CometChat.BannedMembersRequest = new CometChat.Ba
### Set Search Keyword
-This method allows you to set the search string based on which the banned group members are to be fetched.
+Filters banned members by a search string.
@@ -227,9 +242,7 @@ let bannedGroupMembersRequest: CometChat.BannedMembersRequest = new CometChat.Ba
-Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BannedGroupMembersRequest` class.
-
-Once you have the object of the `BannedGroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of banned members where n is the limit set in the builder class.
+Once configured, call `build()` to create the request, then `fetchNext()` to retrieve banned members.
@@ -274,13 +287,13 @@ bannedGroupMembersRequest.fetchNext().then(
## Real-Time Group Member Kicked/Banned Events
-*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is running?*
+Implement these `GroupListener` methods to receive real-time notifications:
-In order to get real-time events for the kick/ban/unban group members you need to override the following methods of the `GroupListener` class.
-
-1. `onGroupMemberKicked()` - triggered when any group member has been kicked.
-2. `onGroupMemberBanned()` - triggered when any group member has been banned.
-3. `onGroupMemberUnbanned()` - triggered when any group member has been unbanned.
+| Method | Triggered When |
+|--------|----------------|
+| `onGroupMemberKicked()` | A member is kicked |
+| `onGroupMemberBanned()` | A member is banned |
+| `onGroupMemberUnbanned()` | A member is unbanned |
@@ -329,29 +342,60 @@ CometChat.addGroupListener(
+
+Always remove group listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+```javascript
+CometChat.removeGroupListener("UNIQUE_LISTENER_ID");
+```
+
+
## Missed Group Member Kicked/Banned Events
-*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is not running?*
+When fetching previous messages, kick/ban/unban actions appear as [Action](/sdk/reference/messages#action) messages (a subclass of `BaseMessage`).
+
+**Kicked event:**
-When you retrieve the list of previous messages if a member has been kicked/banned/unbanned from any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class.
+| Field | Value/Type | Description |
+|-------|------------|-------------|
+| `action` | `"kicked"` | The action type |
+| `actionBy` | [User](/sdk/reference/entities#user) | The user who kicked the member |
+| `actionOn` | [User](/sdk/reference/entities#user) | The member who was kicked |
+| `actionFor` | [Group](/sdk/reference/entities#group) | The group |
-For group member kicked event, the details can be obtained using the below fields of the `Action` class-
+**Banned event:**
-1. `action` - `kicked`
-2. `actionBy` - User object containing the details of the user who has kicked the member
-3. `actionOn` - User object containing the details of the member that has been kicked
-4. `actionFor` - Group object containing the details of the Group from which the member was kicked
+| Field | Value/Type | Description |
+|-------|------------|-------------|
+| `action` | `"banned"` | The action type |
+| `actionBy` | [User](/sdk/reference/entities#user) | The user who banned the member |
+| `actionOn` | [User](/sdk/reference/entities#user) | The member who was banned |
+| `actionFor` | [Group](/sdk/reference/entities#group) | The group |
-For group member banned event, the details can be obtained using the below fields of the `Action` class-
+**Unbanned event:**
-1. `action` - `banned`
-2. `actionBy` - User object containing the details of the user who has banned the member
-3. `actionOn` - User object containing the details of the member that has been banned
-4. `actionFor` - Group object containing the details of the Group from which the member was banned
+| Field | Value/Type | Description |
+|-------|------------|-------------|
+| `action` | `"unbanned"` | The action type |
+| `actionBy` | [User](/sdk/reference/entities#user) | The user who unbanned the member |
+| `actionOn` | [User](/sdk/reference/entities#user) | The member who was unbanned |
+| `actionFor` | [Group](/sdk/reference/entities#group) | The group |
-For group member unbanned event, the details can be obtained using the below fields of the `Action` class-
+---
-1. `action` - `unbanned`
-2. `actionBy` - User object containing the details of the user who has unbanned the member
-3. `actionOn` - User object containing the details of the member that has been unbanned
-4. `actionFor` - Group object containing the details of the Group from which the member was unbanned
+## Next Steps
+
+
+
+ Add new members to a group
+
+
+ Promote or demote group members
+
+
+ Fetch the list of members in a group
+
+
+ Allow members to leave a group
+
+
diff --git a/sdk/javascript/groups-overview.mdx b/sdk/javascript/groups-overview.mdx
index 4f3d1c363..df477b297 100644
--- a/sdk/javascript/groups-overview.mdx
+++ b/sdk/javascript/groups-overview.mdx
@@ -1,10 +1,59 @@
---
title: "Groups"
sidebarTitle: "Overview"
+description: "Overview of group management in the CometChat JavaScript SDK including group types, member roles, and available operations."
---
+
+| Field | Value |
+| --- | --- |
+| Package | `@cometchat/chat-sdk-javascript` |
+| Key Classes | `CometChat.Group` |
+| Group Types | `PUBLIC`, `PRIVATE`, `PASSWORD` |
+| Member Roles | `owner`, `admin`, `moderator`, `participant` |
+| Key Methods | `createGroup()`, `joinGroup()`, `leaveGroup()`, `deleteGroup()` |
+| Prerequisites | SDK initialized, user logged in |
+| Related | [Create Group](/sdk/javascript/create-group), [Join Group](/sdk/javascript/join-group), [Retrieve Groups](/sdk/javascript/retrieve-groups) |
+
+
Groups help your users to converse together in a single space. You can have three types of groups- private, public and password protected.
Each group includes three kinds of users- owner, moderator, member.
+
+## Group Types
+
+| Type | Description | Join Behavior |
+|------|-------------|---------------|
+| **Public** | Open to all users | Any user can join without approval |
+| **Private** | Invite-only | Users must be added by admin/moderator |
+| **Password** | Protected by password | Users must provide correct password to join |
+
+## Member Roles
+
+| Role | Permissions |
+|------|-------------|
+| **Owner** | Full control: manage members, settings, delete group. Cannot leave without transferring ownership. |
+| **Admin** | Manage members (add, kick, ban), change member scope, update group settings |
+| **Moderator** | Kick and ban members, moderate content |
+| **Member** | Send/receive messages, leave group |
+
+---
+
+## Next Steps
+
+
+
+ Create public, private, or password-protected groups
+
+
+ Join existing groups as a participant
+
+
+ Fetch and filter the list of groups
+
+
+ Get the member list for a group
+
+
diff --git a/sdk/javascript/initialization.mdx b/sdk/javascript/initialization.mdx
new file mode 100644
index 000000000..bc918d41a
--- /dev/null
+++ b/sdk/javascript/initialization.mdx
@@ -0,0 +1,167 @@
+---
+title: "Initialization"
+description: "Configure and initialize the CometChat JavaScript SDK with your App ID and settings."
+---
+
+The `init()` method initializes the SDK and must be called before any other CometChat method. Call it once at app startup, typically in your entry file (`index.js`, `main.js`, or `App.js`).
+
+## Basic Initialization
+
+
+
+```javascript
+let appID = "APP_ID";
+let region = "APP_REGION";
+
+let appSetting = new CometChat.AppSettingsBuilder()
+ .subscribePresenceForAllUsers()
+ .setRegion(region)
+ .autoEstablishSocketConnection(true)
+ .build();
+
+CometChat.init(appID, appSetting).then(
+ () => {
+ console.log("Initialization completed successfully");
+ },
+ (error) => {
+ console.log("Initialization failed with error:", error);
+ }
+);
+```
+
+
+
+
+```typescript
+let appID: string = "APP_ID";
+let region: string = "APP_REGION";
+
+let appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder()
+ .subscribePresenceForAllUsers()
+ .setRegion(region)
+ .autoEstablishSocketConnection(true)
+ .build();
+
+CometChat.init(appID, appSetting).then(
+ (initialized: boolean) => {
+ console.log("Initialization completed successfully", initialized);
+ },
+ (error: CometChat.CometChatException) => {
+ console.log("Initialization failed with error:", error);
+ }
+);
+```
+
+
+
+
+```javascript
+let appID = "APP_ID";
+let region = "APP_REGION";
+
+let appSetting = new CometChat.AppSettingsBuilder()
+ .subscribePresenceForAllUsers()
+ .setRegion(region)
+ .autoEstablishSocketConnection(true)
+ .build();
+
+try {
+ await CometChat.init(appID, appSetting);
+ console.log("Initialization completed successfully");
+} catch (error) {
+ console.log("Initialization failed with error:", error);
+}
+```
+
+
+
+
+
+Replace `APP_ID` with your CometChat App ID and `APP_REGION` with your Region from the [Dashboard](https://app.cometchat.com).
+
+
+`CometChat.init()` must be called before any other SDK method. Calling `login()`, `sendMessage()`, or registering listeners before `init()` will fail.
+
+
+## Parameters
+
+| Parameter | Type | Description |
+|-----------|------|-------------|
+| appID | string | Your CometChat App ID |
+| appSetting | AppSettings | Configuration object built with AppSettingsBuilder |
+
+## AppSettings Options
+
+| Method | Description | Default |
+|--------|-------------|---------|
+| `setRegion(region)` | Region where your app was created (`us`, `eu`, `in`, `in-private`) | Required |
+| `subscribePresenceForAllUsers()` | Subscribe to presence events for all users | — |
+| `subscribePresenceForRoles(roles)` | Subscribe to presence for specific roles | — |
+| `subscribePresenceForFriends()` | Subscribe to presence for friends only | — |
+| `autoEstablishSocketConnection(bool)` | Let SDK manage WebSocket connections | `true` |
+| `overrideAdminHost(adminHost)` | Custom admin URL (dedicated deployment) | — |
+| `overrideClientHost(clientHost)` | Custom client URL (dedicated deployment) | — |
+| `setStorageMode(storageMode)` | Local storage mode (`CometChat.StorageMode.SESSION` for session storage) | — |
+
+### Presence Subscription
+
+Choose how to subscribe to user presence (online/offline status):
+
+```javascript
+// All users
+new CometChat.AppSettingsBuilder()
+ .subscribePresenceForAllUsers()
+ .setRegion(region)
+ .build();
+
+// Specific roles
+new CometChat.AppSettingsBuilder()
+ .subscribePresenceForRoles(["admin", "moderator"])
+ .setRegion(region)
+ .build();
+
+// Friends only
+new CometChat.AppSettingsBuilder()
+ .subscribePresenceForFriends()
+ .setRegion(region)
+ .build();
+```
+
+See [User Presence](/sdk/javascript/user-presence) for more details.
+
+### WebSocket Connection
+
+By default, the SDK manages WebSocket connections automatically. To manage them manually:
+
+```javascript
+let appSetting = new CometChat.AppSettingsBuilder()
+ .setRegion(region)
+ .autoEstablishSocketConnection(false)
+ .build();
+```
+
+See [Managing WebSocket Connections](/sdk/javascript/managing-web-sockets-connections-manually) for manual control.
+
+### Session Storage
+
+Use session storage instead of local storage (data clears when browser closes):
+
+```javascript
+let appSetting = new CometChat.AppSettingsBuilder()
+ .setRegion(region)
+ .setStorageMode(CometChat.StorageMode.SESSION)
+ .build();
+```
+
+---
+
+## Next Steps
+
+
+
+ Log in users with Auth Key or Auth Token
+
+
+ Setup for Next.js, Nuxt, and Ionic
+
+
diff --git a/sdk/javascript/installation.mdx b/sdk/javascript/installation.mdx
new file mode 100644
index 000000000..c0ece3d34
--- /dev/null
+++ b/sdk/javascript/installation.mdx
@@ -0,0 +1,59 @@
+---
+title: "Installation"
+description: "Add the CometChat JavaScript SDK to your project using npm or CDN."
+---
+
+## Package Manager
+
+Install the SDK using npm:
+
+```bash
+npm install @cometchat/chat-sdk-javascript
+```
+
+Then import the `CometChat` object wherever you need it:
+
+```javascript
+import { CometChat } from "@cometchat/chat-sdk-javascript";
+```
+
+## CDN
+
+Include the CometChat JavaScript library directly in your HTML:
+
+```html
+
+```
+
+When using the CDN, `CometChat` is available as a global variable.
+
+## Get Your Credentials
+
+Before initializing the SDK, get your credentials from the [CometChat Dashboard](https://app.cometchat.com):
+
+1. Sign up or log in
+2. Create a new app (or use an existing one)
+3. Go to **API & Auth Keys** and note your:
+ - App ID
+ - Region
+ - Auth Key
+
+
+**Auth Key** is for development/testing only. In production, generate **Auth Tokens** on your server using the REST API. Never expose Auth Keys in production client code.
+
+
+---
+
+## Next Steps
+
+
+
+ Configure and initialize the SDK
+
+
+ Setup for Next.js, Nuxt, and Ionic
+
+
diff --git a/sdk/javascript/interactive-messages.mdx b/sdk/javascript/interactive-messages.mdx
index 2f083f734..db180414d 100644
--- a/sdk/javascript/interactive-messages.mdx
+++ b/sdk/javascript/interactive-messages.mdx
@@ -1,203 +1,551 @@
---
title: "Interactive Messages"
+sidebarTitle: "Interactive Messages"
+description: "Send and receive interactive messages with embedded forms, buttons, and other UI elements using the CometChat JavaScript SDK."
---
+
+
+| Component | Description |
+| --- | --- |
+| `InteractiveMessage` | Message containing interactive UI elements (forms, buttons, etc.) |
+| `InteractionGoal` | Defines the desired outcome of user interactions |
+| `Interaction` | Represents a single user action on an interactive element |
+
+```javascript
+// Create and send an interactive form
+const interactiveMessage = new CometChat.InteractiveMessage(
+ receiverId,
+ receiverType,
+ "form",
+ interactiveData
+);
+await CometChat.sendInteractiveMessage(interactiveMessage);
+// Listen for interactive messages
+CometChat.addMessageListener("LISTENER_ID", new CometChat.MessageListener({
+ onInteractiveMessageReceived: (message) => console.log("Received:", message),
+ onInteractionGoalCompleted: (receipt) => console.log("Goal completed:", receipt)
+}));
+```
+
-An InteractiveMessage is a specialised object that encapsulates an interactive unit within a chat message, such as an embedded form that users can fill out directly within the chat interface. This enhances user engagement by making the chat experience more interactive and responsive to user input.
+Interactive messages embed UI elements like forms, buttons, and dropdowns directly within chat messages. Users can interact with these elements without leaving the conversation, enabling surveys, quick actions, and data collection.
## InteractiveMessage
-`InteractiveMessage` is a chat message with embedded interactive content. It can contain various properties:
+The [`InteractiveMessage`](/sdk/reference/messages#interactivemessage) class represents a message with embedded interactive content.
-| Parameter | Description | Required |
-| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
-| receiverId | The UID or GUID of the recipient | Yes |
-| receiverType | The type of the receiver to whom the message is to be sent i.e CometChatConstants.RECEIVER\_TYPE\_USER (user) or CometChatConstants.RECEIVER\_TYPE\_GROUP (group) | Yes |
-| messageType | The type of the message that needs to be sent | Yes |
-| interactiveData | A JSONObject holding structured data for the interactive element. | Yes |
-| allowSenderInteraction | A boolean determining whether the message sender can interact with the message by default it is set to false. | Optional (Default: false) |
-| interactionGoal | An InteractionGoal object encapsulating the intended outcome of interacting with the InteractiveMessage by default it is set to none | Optional (Default: none) |
+| Parameter | Type | Description | Required |
+| --- | --- | --- | --- |
+| `receiverId` | `string` | UID of user or GUID of group | Yes |
+| `receiverType` | `string` | `CometChat.RECEIVER_TYPE.USER` or `GROUP` | Yes |
+| `messageType` | `string` | Type identifier (e.g., `"form"`, `"card"`) | Yes |
+| `interactiveData` | `Object` | JSON structure defining the interactive elements | Yes |
+| `allowSenderInteraction` | `boolean` | Whether sender can interact with the message | No (default: `false`) |
+| `interactionGoal` | `InteractionGoal` | Defines when the interaction is considered complete | No (default: `none`) |
-## Interaction
+## Send an Interactive Message
-An `Interaction` represents a user action involved with an `InteractiveMessage`. It includes:
+Use `sendInteractiveMessage()` to send an interactive message.
-* `elementId`: An identifier for a specific interactive element.
-* `interactedAt`: A timestamp indicating when the interaction occurred.
+
+
+```javascript
+let receiverId = "UID";
+let receiverType = CometChat.RECEIVER_TYPE.USER;
+
+let interactiveData = {
+ title: "Survey",
+ formFields: [
+ {
+ elementType: "textInput",
+ elementId: "name",
+ optional: false,
+ label: "Name",
+ placeholder: { text: "Enter your name" }
+ },
+ {
+ elementType: "textInput",
+ elementId: "age",
+ optional: true,
+ label: "Age",
+ maxLines: 1,
+ placeholder: { text: "Enter your age" }
+ },
+ {
+ elementType: "dropdown",
+ elementId: "gender",
+ optional: false,
+ label: "Gender",
+ defaultValue: "male",
+ options: [
+ { label: "Male", value: "male" },
+ { label: "Female", value: "female" }
+ ]
+ },
+ {
+ elementType: "Select",
+ elementId: "interests",
+ optional: true,
+ label: "Interests",
+ defaultValue: ["tech"],
+ options: [
+ { label: "Technology", value: "tech" },
+ { label: "Sports", value: "sports" },
+ { label: "Music", value: "music" }
+ ]
+ }
+ ],
+ submitElement: {
+ elementType: "button",
+ elementId: "submitButton",
+ buttonText: "Submit",
+ disableAfterInteracted: true,
+ action: {
+ actionType: "urlNavigation",
+ url: "https://www.cometchat.com/"
+ }
+ }
+};
-## Goal Completion
+let interactiveMessage = new CometChat.InteractiveMessage(
+ receiverId,
+ receiverType,
+ "form",
+ interactiveData
+);
-A key feature of `InteractiveMessage` is checking whether a user's interactions with the message meet the defined `InteractionGoal`
+CometChat.sendInteractiveMessage(interactiveMessage).then(
+ (message) => {
+ console.log("Interactive message sent successfully", message);
+ },
+ (error) => {
+ console.log("Interactive message sending failed with error:", error);
+ }
+);
+```
+
+
+```typescript
+let receiverId: string = "UID";
+let receiverType: string = CometChat.RECEIVER_TYPE.USER;
+
+let interactiveData: Object = {
+ title: "Survey",
+ formFields: [
+ {
+ elementType: "textInput",
+ elementId: "name",
+ optional: false,
+ label: "Name",
+ placeholder: { text: "Enter your name" }
+ },
+ {
+ elementType: "textInput",
+ elementId: "age",
+ optional: true,
+ label: "Age",
+ maxLines: 1,
+ placeholder: { text: "Enter your age" }
+ },
+ {
+ elementType: "dropdown",
+ elementId: "gender",
+ optional: false,
+ label: "Gender",
+ defaultValue: "male",
+ options: [
+ { label: "Male", value: "male" },
+ { label: "Female", value: "female" }
+ ]
+ },
+ {
+ elementType: "Select",
+ elementId: "interests",
+ optional: true,
+ label: "Interests",
+ defaultValue: ["tech"],
+ options: [
+ { label: "Technology", value: "tech" },
+ { label: "Sports", value: "sports" },
+ { label: "Music", value: "music" }
+ ]
+ }
+ ],
+ submitElement: {
+ elementType: "button",
+ elementId: "submitButton",
+ buttonText: "Submit",
+ disableAfterInteracted: true,
+ action: {
+ actionType: "urlNavigation",
+ url: "https://www.cometchat.com/"
+ }
+ }
+};
-You would be tracking every interaction users perform on an `InteractiveMessage` (captured as `Interaction` objects) and comparing those with the defined `InteractionGoal`. The completion of a goal can vary depending on the goal type:
+let interactiveMessage: CometChat.InteractiveMessage = new CometChat.InteractiveMessage(
+ receiverId,
+ receiverType,
+ "form",
+ interactiveData
+);
-| Goals | Description | Keys |
-| -------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------- |
-| **Any Interaction** | The goal is considered completed if there is at least one interaction. | CometChatConstants.INTERACTION\_TYPE\_ANY |
-| **Any of Specific Interactions** | The goal is achieved if any of the specified interactions occurred. | CometChatConstants.INTERACTION\_TYPE\_ANY\_OF |
-| **All of Specific Interactions** | The goal is completed when all specified interactions occur. | CometChatConstants.INTERACTION\_TYPE\_ALL\_OF |
-| **None** | The goal is never completed. | CometChatConstants.INTERACTION\_TYPE\_NONE |
+CometChat.sendInteractiveMessage(interactiveMessage).then(
+ (message: CometChat.InteractiveMessage) => {
+ console.log("Interactive message sent successfully", message);
+ },
+ (error: CometChat.CometChatException) => {
+ console.log("Interactive message sending failed with error:", error);
+ }
+);
+```
+
+
-This user interaction tracking mechanism provides a flexible and efficient way to monitor user engagement within an interactive chat session. By defining clear interaction goals and checking user interactions against these goals, you can manage user engagement and improve the overall chat experience in your CometChat-enabled application.
+On success, `sendInteractiveMessage()` returns an [`InteractiveMessage`](/sdk/reference/messages#interactivemessage) object.
-## InteractionGoal
+| Field | Getter | Return Type | Description |
+| --- | --- | --- | --- |
+| interactiveData | `getInteractiveData()` | `Object` | The structured JSON data for the interactive element |
+| interactionGoal | `getInteractionGoal()` | [`InteractionGoal`](/sdk/reference/auxiliary#interactiongoal) | The intended outcome of interacting with the message |
+| interactions | `getInteractions()` | [`Interaction[]`](/sdk/reference/auxiliary#interaction) | List of user interactions performed on the message |
+| allowSenderInteraction | `getIsSenderInteractionAllowed()` | `boolean` | Whether the sender can interact with the message |
-The `InteractionGoal` represents the desired outcome of an interaction with an `InteractiveMessage`. It includes:
+## Interactive Elements
-* `elementIds`: A list of identifiers for the interactive elements.
-* `type`: The type of interaction goal from the `CometChatConstants`.
+The `interactiveData` object defines the UI elements. Common element types:
-## Sending InteractiveMessages
+| Element Type | Description |
+| --- | --- |
+| `textInput` | Single or multi-line text field |
+| `dropdown` | Single-select dropdown menu |
+| `Select` | Multi-select checkbox group |
+| `button` | Clickable button with action |
-The `InteractiveMessage` can be sent using the `sendInteractiveMessage` method of the `CometChat` class. The method requires an `InteractiveMessage` object and a `CallbackListener` for handling the response.
+### Text Input
-Here is an example of how to use it:
+```javascript
+{
+ elementType: "textInput",
+ elementId: "name",
+ optional: false,
+ label: "Name",
+ maxLines: 1, // Optional: limit to single line
+ placeholder: { text: "Enter text here" }
+}
+```
-
-
-```js
-const interactiveData = {
-title: "Survey",
-formFields: [
- {
- elementType: "textInput",
- elementId: "name",
- optional: false,
- label: "Name",
- placeholder: {
- text: "Enter text here"
- }
- },
- {
- elementType: "textInput",
- elementId: "age",
- optional: true,
- label: "Age",
- maxLines: 1,
- placeholder: {
- text: "Enter text here"
- }
- },
- {
- elementType: "Select",
- elementId: "checkBox1",
- optional: true,
- label: "Check box element",
- defaultValue: ["chk_option_2"],
- options: [
- {
- label: "Option 1",
- value: "chk_option_1"
- },
- {
- label: "Option 2",
- value: "chk_option_2"
- }
- ]
- },
- {
- elementType: "dropdown",
- elementId: "gender",
- optional: false,
- label: "Gender",
- defaultValue: "male",
- options: [
- {
- label: "Male",
- value: "male"
- },
- {
- label: "Female",
- value: "female"
- }
- ]
- }
-],
-submitElement: {
+### Dropdown (Single Select)
+
+```javascript
+{
+ elementType: "dropdown",
+ elementId: "country",
+ optional: false,
+ label: "Country",
+ defaultValue: "us",
+ options: [
+ { label: "United States", value: "us" },
+ { label: "United Kingdom", value: "uk" },
+ { label: "Canada", value: "ca" }
+ ]
+}
+```
+
+### Checkbox (Multi Select)
+
+```javascript
+{
+ elementType: "Select",
+ elementId: "preferences",
+ optional: true,
+ label: "Preferences",
+ defaultValue: ["email"],
+ options: [
+ { label: "Email notifications", value: "email" },
+ { label: "SMS notifications", value: "sms" },
+ { label: "Push notifications", value: "push" }
+ ]
+}
+```
+
+### Submit Button
+
+```javascript
+{
elementType: "button",
- elementId: "submitButton",
+ elementId: "submitBtn",
buttonText: "Submit",
- disableAfterInteracted: false,
+ disableAfterInteracted: true,
action: {
actionType: "urlNavigation",
- url: "https://www.cometchat.com/"
+ url: "https://example.com/submit"
}
}
-};
+```
+## Interaction Goals
+An `InteractionGoal` defines when the user's interaction with the message is considered complete. Use this to track engagement and trigger follow-up actions.
-const interactiveMessage = new CometChat.InteractiveMessage(receiverId,receiverType,"form", interactiveData);
+| Goal Type | Constant | Description |
+| --- | --- | --- |
+| Any Interaction | `CometChat.GoalType.ANY_ACTION` | Complete when any element is interacted with |
+| Any of Specific | `CometChat.GoalType.ANY_OF` | Complete when any of the specified elements is interacted with |
+| All of Specific | `CometChat.GoalType.ALL_OF` | Complete when all specified elements are interacted with |
+| None | `CometChat.GoalType.NONE` | Never considered complete (default) |
+### Set an Interaction Goal
-CometChat.sendInteractiveMessage(interactiveMessage)
- .then((message: CometChat.InteractiveMessage) => {
- // This block is executed when the InteractiveMessage is sent successfully.
- })
- .catch((error: CometChat.CometChatException) => {
- // This block is executed if an error occurs while sending the InteractiveMessage.
- });
-```
+
+
+```javascript
+let elementIds = ["name", "gender", "submitButton"];
+let interactionGoal = new CometChat.InteractionGoal(
+ CometChat.GoalType.ALL_OF,
+ elementIds
+);
+
+let interactiveMessage = new CometChat.InteractiveMessage(
+ receiverId,
+ receiverType,
+ "form",
+ interactiveData
+);
+interactiveMessage.setInteractionGoal(interactionGoal);
+CometChat.sendInteractiveMessage(interactiveMessage).then(
+ (message) => {
+ console.log("Interactive message sent successfully", message);
+ },
+ (error) => {
+ console.log("Interactive message sending failed with error:", error);
+ }
+);
+```
+
+```typescript
+let elementIds: Array = ["name", "gender", "submitButton"];
+let interactionGoal: CometChat.InteractionGoal = new CometChat.InteractionGoal(
+ CometChat.GoalType.ALL_OF,
+ elementIds
+);
+let interactiveMessage: CometChat.InteractiveMessage = new CometChat.InteractiveMessage(
+ receiverId,
+ receiverType,
+ "form",
+ interactiveData
+);
+interactiveMessage.setInteractionGoal(interactionGoal);
+
+CometChat.sendInteractiveMessage(interactiveMessage).then(
+ (message: CometChat.InteractiveMessage) => {
+ console.log("Interactive message sent successfully", message);
+ },
+ (error: CometChat.CometChatException) => {
+ console.log("Interactive message sending failed with error:", error);
+ }
+);
+```
+
-## Event Listeners
+## Interactions
-CometChat SDK provides event listeners to handle real-time events related to `InteractiveMessage`.
+An `Interaction` represents a single user action on an interactive element.
-## On InteractiveMessage Received
+| Property | Type | Description |
+| --- | --- | --- |
+| `elementId` | `string` | Identifier of the interacted element |
+| `interactedAt` | `number` | Unix timestamp of the interaction |
-The `onInteractiveMessageReceived` event listener is triggered when an `InteractiveMessage` is received.
+## Mark as Interacted
-Here is an example:
+Use `markAsInteracted()` to record when a user interacts with an element.
-```js
+```javascript
+let messageId = 123;
+let elementId = "submitButton";
+
+CometChat.markAsInteracted(messageId, elementId).then(
+ (response) => {
+ console.log("Marked as interacted successfully", response);
+ },
+ (error) => {
+ console.log("Failed to mark as interacted:", error);
+ }
+);
+```
+
+
+```typescript
+let messageId: number = 123;
+let elementId: string = "submitButton";
+
+CometChat.markAsInteracted(messageId, elementId).then(
+ (response: string) => {
+ console.log("Marked as interacted successfully", response);
+ },
+ (error: CometChat.CometChatException) => {
+ console.log("Failed to mark as interacted:", error);
+ }
+);
+```
+
+
+
+## Real-Time Events
+
+Register a `MessageListener` to receive interactive message events.
+
+### Receive Interactive Messages
+
+
+
+```javascript
+let listenerID = "UNIQUE_LISTENER_ID";
+
CometChat.addMessageListener(
- "UNIQUE_ID",
+ listenerID,
new CometChat.MessageListener({
- onInteractiveMessageReceived: (message: CometChat.InteractiveMessage) => {
- // This block is executed when an InteractiveMessage is received.
- // Here you can define logic to handle the received InteractiveMessage and display it in your chat interface.
- },
+ onInteractiveMessageReceived: (message) => {
+ console.log("Interactive message received", message);
+ // Render the interactive UI based on message.getInteractiveData()
+ }
})
);
```
-
+
+```typescript
+let listenerID: string = "UNIQUE_LISTENER_ID";
+CometChat.addMessageListener(
+ listenerID,
+ new CometChat.MessageListener({
+ onInteractiveMessageReceived: (message: CometChat.InteractiveMessage) => {
+ console.log("Interactive message received", message);
+ // Render the interactive UI based on message.getInteractiveData()
+ }
+ })
+);
+```
+
-On Interaction Goal Completed
+### Interaction Goal Completed
-The `onInteractionGoalCompleted` event listener is invoked when an interaction goal is achieved.
-
-Here is an example:
+Triggered when a user's interactions satisfy the defined `InteractionGoal`.
-```js
+```javascript
+let listenerID = "UNIQUE_LISTENER_ID";
+
+CometChat.addMessageListener(
+ listenerID,
+ new CometChat.MessageListener({
+ onInteractionGoalCompleted: (receipt) => {
+ console.log("Interaction goal completed", receipt);
+ // Handle goal completion (e.g., show confirmation, trigger next step)
+ }
+ })
+);
+```
+
+
+```typescript
+let listenerID: string = "UNIQUE_LISTENER_ID";
+
CometChat.addMessageListener(
- "UNIQUE_ID",
+ listenerID,
new CometChat.MessageListener({
- onInteractionGoalCompleted: (receipt: CometChat.InteractionReceipt) => {
- // This block is executed when an interaction goal is completed.
- // Here you can specify the actions your application should take once an interaction goal is achieved, such as updating the UI or notifying the user.
- },
+ onInteractionGoalCompleted: (receipt: CometChat.InteractionReceipt) => {
+ console.log("Interaction goal completed", receipt);
+ // Handle goal completion (e.g., show confirmation, trigger next step)
+ }
})
);
```
+
+
+
+
+Always remove listeners when they're no longer needed to prevent memory leaks.
+
+```javascript
+CometChat.removeMessageListener("UNIQUE_LISTENER_ID");
+```
+
+
+## Allow Sender Interaction
+By default, the sender cannot interact with their own interactive message. Enable sender interaction:
+
+
+
+```javascript
+let interactiveMessage = new CometChat.InteractiveMessage(
+ receiverId,
+ receiverType,
+ "form",
+ interactiveData
+);
+interactiveMessage.setIsSenderInteractionAllowed(true);
+
+CometChat.sendInteractiveMessage(interactiveMessage).then(
+ (message) => {
+ console.log("Interactive message sent successfully", message);
+ },
+ (error) => {
+ console.log("Interactive message sending failed with error:", error);
+ }
+);
+```
+
+```typescript
+let interactiveMessage: CometChat.InteractiveMessage = new CometChat.InteractiveMessage(
+ receiverId,
+ receiverType,
+ "form",
+ interactiveData
+);
+interactiveMessage.setIsSenderInteractionAllowed(true);
+CometChat.sendInteractiveMessage(interactiveMessage).then(
+ (message: CometChat.InteractiveMessage) => {
+ console.log("Interactive message sent successfully", message);
+ },
+ (error: CometChat.CometChatException) => {
+ console.log("Interactive message sending failed with error:", error);
+ }
+);
+```
+
-These event listeners offer your application a way to provide real-time updates in response to incoming interactive messages and goal completions, contributing to a more dynamic and responsive user chat experience.
-
-## Usage
+---
-An InteractiveMessage is constructed with the receiver's UID, the receiver type, the interactive type, and interactive data as a JSONObject. Once created, the InteractiveMessage can be sent using CometChat's sendInteractiveMessage() method. Incoming InteractiveMessages can be received and processed via CometChat's message listener framework.
+## Next Steps
+
+
+
+ Send text, media, and custom messages
+
+
+ Listen for incoming messages in real time
+
+
+ Send ephemeral messages that aren't stored
+
+
+ Understand message types and hierarchy
+
+
diff --git a/sdk/javascript/join-group.mdx b/sdk/javascript/join-group.mdx
index 744f9e723..20b35ec77 100644
--- a/sdk/javascript/join-group.mdx
+++ b/sdk/javascript/join-group.mdx
@@ -1,19 +1,38 @@
---
title: "Join A Group"
+sidebarTitle: "Join Group"
+description: "Learn how to join public, password-protected, and private groups, and receive real-time join events using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Join a public group
+await CometChat.joinGroup("GUID", CometChat.GROUP_TYPE.PUBLIC, "");
+
+// Join a password-protected group
+await CometChat.joinGroup("GUID", CometChat.GROUP_TYPE.PASSWORD, "password123");
+
+// Listen for member joined events
+CometChat.addGroupListener("listener", new CometChat.GroupListener({
+ onGroupMemberJoined: (message, joinedUser, joinedGroup) => { }
+}));
+```
+
+
+Join groups to participate in group conversations and receive real-time events when members join.
## Join a Group
-In order to start participating in group conversations, you will have to join a group. You can do so using the `joinGroup()` method.
+Use `joinGroup()` to join a group.
```javascript
-var GUID = "GUID";
-var password = "";
-var groupType = CometChat.GROUP_TYPE.PUBLIC;
+const GUID = "GUID";
+const password = "";
+const groupType = CometChat.GROUP_TYPE.PUBLIC;
CometChat.joinGroup(GUID, groupType, password).then(
group => {
@@ -28,7 +47,7 @@ group => {
```typescript
-var GUID: string = "GUID";
+const GUID: string = "GUID";
CometChat.joinGroup(GUID, CometChat.GroupType.Public).then(
(group: CometChat.Group) => {
@@ -43,25 +62,28 @@ CometChat.joinGroup(GUID, CometChat.GroupType.Public).then(
-The `joinGroup()` method takes the below parameters
-
-| Parameter | Description |
-| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `GUID` | The GUID of the group you would like to join. |
-| `groupType` | Type of the group. CometChat provides 3 types of groups viz. 1. CometChat.GROUP\_TYPE.PUBLIC 2. CometChat.GROUP\_TYPE.PASSWORD 3. CometChats.GROUP\_TYPE.PRIVATE |
-| `password` | Password is mandatory in case of a password protected group. |
+| Parameter | Description |
+| --------- | ----------- |
+| `GUID` | The GUID of the group to join |
+| `groupType` | `CometChat.GROUP_TYPE.PUBLIC`, `PASSWORD`, or `PRIVATE` |
+| `password` | Required for password-protected groups |
-Once you have joined a group successfully, you can send and receive messages in that group.
+Once joined, you can send and receive messages in the group. CometChat tracks joined groups — you don't need to rejoin each session. Check `hasJoined` on the `Group` object to verify membership.
-CometChat keeps a track of the groups joined and you do not need to join the group every time you want to communicate in the group.
+The method returns a [`Group`](/sdk/reference/entities#group) object with `hasJoined` set to `true`. Access the response data using getter methods:
-You can identify if a group is joined using the `hasJoined` parameter in the `Group` object.
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| guid | `getGuid()` | `string` | Unique group ID |
+| name | `getName()` | `string` | Display name of the group |
+| type | `getType()` | `string` | Group type (`"public"`, `"private"`, or `"password"`) |
+| hasJoined | `getHasJoined()` | `boolean` | Whether the logged-in user has joined this group |
+| scope | `getScope()` | `string` | Scope of the logged-in user in the group |
+| membersCount | `getMembersCount()` | `number` | Total number of members in the group |
## Real-time Group Member Joined Events
-*In other words, as a member of a group, how do I know if someone joins the group when my app is running?*
-
-If a user joins any group, the members of the group receive a real-time event in the `onGroupMemberJoined()` method of the `GroupListener` class.
+Register a `GroupListener` to receive events when members join.
@@ -94,14 +116,36 @@ CometChat.addGroupListener(
-## Missed Group Member Joined Events
+
+Always remove group listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+```javascript
+CometChat.removeGroupListener("UNIQUE_LISTNER_ID");
+```
+
-*In other words, as a member of a group, how do I know if someone joins the group when my app is not running?*
+## Missed Group Member Joined Events
-When you retrieve the list of previous messages if a member has joined any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class.
+When fetching message history, join events appear as `Action` messages with:
+- `action` — `"joined"`
+- `actionBy` — [`User`](/sdk/reference/entities#user) who joined
+- `actionFor` — [`Group`](/sdk/reference/entities#group) that was joined
-For the group member joined event, in the `Action` object received, the following fields can help you get the relevant information-
+---
-1. `action` - `joined`
-2. `actionBy` - User object containing the details of the user who joined the group
-3. `actionFor`- Group object containing the details of the group the user has joined
+## Next Steps
+
+
+
+ Allow members to leave a group
+
+
+ Fetch the list of members in a group
+
+
+ Send messages to group conversations
+
+
+ Programmatically add members to a group
+
+
diff --git a/sdk/javascript/key-concepts.mdx b/sdk/javascript/key-concepts.mdx
index 37e5885f1..138c523c9 100644
--- a/sdk/javascript/key-concepts.mdx
+++ b/sdk/javascript/key-concepts.mdx
@@ -1,127 +1,151 @@
---
title: "Key Concepts"
+description: "Understand the core concepts of CometChat including users, groups, messaging categories, authentication, and member roles."
---
+
+Key identifiers:
+- **UID** — Unique User Identifier (alphanumeric, underscore, hyphen)
+- **GUID** — Group Unique Identifier (alphanumeric, underscore, hyphen)
+- **Auth Key** — Development-only credential for quick testing
+- **Auth Token** — Secure per-user token for production use
+- **REST API Key** — Server-side credential, never expose in client code
-### CometChat Dashboard
+Group types: `Public` | `Password` | `Private`
+Member scopes: `Admin` | `Moderator` | `Participant`
+Message categories: `message` | `custom` | `action` | `call`
+
-The CometChat Dashboard enables you to create new apps (projects) and manage your existing apps.
+This guide covers the fundamental concepts you need to understand when building with CometChat.
-
-How many apps to create?
+## CometChat Dashboard
-Ideally, you should create two apps- one for development and one for production. And you should use a single app irrespective of the number of platforms.
+The [CometChat Dashboard](https://app.cometchat.com) enables you to create new apps (projects) and manage your existing apps.
-Do not create separate apps for every platform; if you do, your users on different platforms will not be able to communicate with each other!
+- For every app, a unique App ID is generated. This App ID is required when integrating CometChat within your app.
+- Along with the App ID, you will need to create an Auth Key (from the Dashboard) which can be used for user authentication.
+
+Ideally, create two apps — one for development and one for production. Use a single app regardless of the number of platforms. Do not create separate apps for every platform; if you do, your users on different platforms will not be able to communicate with each other.
-* For every app, a unique App ID is generated. This App ID will be required when integrating CometChat within your app.
-* Along with the App ID, you will need to create an Auth Key (from the Dashboard) which can be used for user authentication.
-
-### Auth & Rest API Keys
-
-You can generate two types of keys from the dashboard.
+## API Keys
-| Type | Privileges | Recommended Use |
-| ------------ | ---------------------------------------------------------------- | --------------------------------------------- |
-| Auth Key | The Auth Key can be used to create & login users. | In your client side code (during development) |
-| Rest API Key | The Rest API Key can be used to perform any CometChat operation. | In your server side code |
+You can generate two types of keys from the dashboard:
-### Users
-
-A user is anyone who uses CometChat.
-
-### UID
-
-* Each user is uniquely identified using UID.
-* The UID is typically the primary ID of the user from your database.
+| Type | Privileges | Recommended Use |
+| --- | --- | --- |
+| Auth Key | Create & login users | Client-side code (development only) |
+| REST API Key | Perform any CometChat operation | Server-side code only |
-
-UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.
-
+Never expose your REST API Key in client-side code. Use Auth Tokens for production authentication.
-### Auth Token
-
-* A single user can have multiple auth tokens. The auth tokens should be per user per device.
-* It should be generated by API call ideally, via server to server call. The auth token should then be given to CometChat for login.
-* An Auth Token can only be deleted via dashboard or using REST API.
+## Users
-### Authentication
+A user is anyone who uses CometChat. Each user is uniquely identified using a UID (Unique User Identifier).
-To allow a user to use CometChat, the user must log in to CometChat.
+- The UID is typically the primary ID of the user from your database
+- UID can be alphanumeric with underscore and hyphen only — spaces, punctuation, and other special characters are not allowed
-**CometChat does not handle user management.** You must handle user registration and login at your end. Once the user is logged into your app/site, you can log in the user to CometChat **programmatically**. So the user does not ever directly login to CometChat.
+## Auth Tokens
-**CometChat does not handle friends management.** If you want to associate friends with your users, you must handle friends management in your app. Once two users are friends (i.e. they have accepted each other as friends), then you can associate them as friends in CometChat.
+Auth Tokens are secure, per-user credentials for production use:
-### Typical Workflow
+- A single user can have multiple auth tokens (one per device)
+- Generate tokens server-side via the [REST API](https://api-explorer.cometchat.com/reference/create-authtoken)
+- Tokens can only be deleted via the Dashboard or REST API
-| Your App | Your Server | CometChat |
-| ----------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
-| User registers in your app | You store the user information in your database (e.g. ID, name, email, phone, location etc. in `users` table) | You add the user to CometChat (only ID & name) using the Rest API |
-| User logs in to your app | You verify the credentials, login the user and retrieve the user ID | You log in the user to CometChat using the same user ID programmatically |
-| User sends a friend request | You display the request to the potential friend | No action required |
-| User accepts a friend request | You display the users as friends | You add both the users as friends using the Rest API |
+## Authentication Flow
-### User Roles
+CometChat does not handle user management or friends management. You handle registration and login in your app, then log users into CometChat programmatically.
-A role is a category for a group of similar users. For example, you may want to group your premium users using the role "Premium". You then use this to filter users or enable/disable features by writing conditional code.
+| Your App | Your Server | CometChat |
+| --- | --- | --- |
+| User registers | Store user info in your database | Create user via REST API (UID & name) |
+| User logs in | Verify credentials, retrieve user ID | Log in user programmatically with UID |
+| User sends friend request | Display request to potential friend | No action required |
+| User accepts friend request | Display users as friends | Add both users as friends via REST API |
-### User List
+## User Roles
-* The User List can be used to build the **Contacts** or **Who's Online** view in your app.
-* The list of users can be different based on the logged-in user.
+A role is a category for grouping similar users. For example, group premium users with the role "Premium" to filter users or enable/disable features conditionally.
-### Groups
+## Groups
-A group can be used for multiple users to communicate with each other on a particular topic/interest.
+A group enables multiple users to communicate on a particular topic or interest. Each group is uniquely identified using a GUID (Group Unique Identifier).
-### GUID
+- The GUID is typically the primary ID of the group from your database
+- GUID can be alphanumeric with underscore and hyphen only
-* Each group is uniquely identified using GUID.
-* The GUID is typically the primary ID of the group from your database. If you do not store group information in your database, you can generate a random string for use as GUID.
+## Group Types
-
+| Type | Visibility | Participation |
+| --- | --- | --- |
+| Public | All users | Any user can join |
+| Password | All users | Users with valid password can join |
+| Private | Members only | Users must be invited (auto-joined) |
-GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.
+## Member Scopes
-
+Once a user joins a group, they become a member with one of three scopes:
-### Types
+| Scope | Default | Privileges |
+| --- | --- | --- |
+| Admin | Group creator | Full control: manage members, change scopes, kick/ban anyone, update/delete group |
+| Moderator | — | Moderate: change participant scopes, kick/ban participants, update group |
+| Participant | All other members | Basic: send & receive messages and calls |
-CometChat supports three different types of groups:
+## Message Categories
-| Type | Visibility | Participation |
-| -------- | ---------------------------- | ------------------------------------------------- |
-| Public | All users | Any user can choose to join |
-| Password | All users | Any user with a valid password can choose to join |
-| Private | Only users part of the group | Invited users will be auto-joined |
+Every message belongs to one of these categories:
-### Members
+| Category | Types | Description |
+| --- | --- | --- |
+| `message` | `text`, `image`, `video`, `audio`, `file` | Standard messages |
+| `custom` | Developer-defined | Custom data (e.g., location, polls) |
+| `action` | `groupMember`, `message` | System-generated (joins, edits, deletes) |
+| `call` | `audio`, `video` | Call-related messages |
-Once a participant joins a group, they become a member of the group. Members are part of the group indefinitely i.e. they will keep receiving messages, calls & notifications. To stop, the participant must either be kicked, banned or intentionally leave the group.
+For more details, see the [Message Structure and Hierarchy](/sdk/javascript/message-structure-and-hierarchy) guide.
-CometChat supports three different types of member scopes in a group:
+## Glossary
-| Member | Default | Privileges |
-| ----------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Admin | Group creator is assigned Admin scope | - Change scope of Group Members to admin, moderator or participant. - Can add members to a group. - Kick & Ban Participants/Moderators/Admins - Send & Receive Messages & Calls - Update group - Delete group |
-| Moderator | - | - Change scope of moderator or participant. - Update group - Kick & Ban Participants - Send & Receive Messages & Calls |
-| Participant | Any other user is assigned Participant scope | - Send & Receive Messages & Calls |
+| Term | Definition | Learn More |
+| --- | --- | --- |
+| UID | Unique User Identifier — alphanumeric string you assign to each user | [Users Overview](/sdk/javascript/users-overview) |
+| GUID | Group Unique Identifier — alphanumeric string you assign to each group | [Groups Overview](/sdk/javascript/groups-overview) |
+| Auth Key | Development-only credential for quick testing. Never use in production | [Authentication](/sdk/javascript/authentication-overview) |
+| Auth Token | Secure, per-user token generated via REST API. Use in production | [Authentication](/sdk/javascript/authentication-overview#login-using-auth-token) |
+| REST API Key | Server-side credential for REST API calls. Never expose in client code | [CometChat Dashboard](https://app.cometchat.com) |
+| Receiver Type | Specifies if a message target is a `user` or `group` | [Send Message](/sdk/javascript/send-message) |
+| Scope | Group member scope: `admin`, `moderator`, or `participant` | [Change Member Scope](/sdk/javascript/group-change-member-scope) |
+| Listener | Callback handler for real-time events (messages, presence, calls, groups) | [All Real-Time Listeners](/sdk/javascript/all-real-time-listeners) |
+| Conversation | A chat thread between two users or within a group | [Retrieve Conversations](/sdk/javascript/retrieve-conversations) |
+| Metadata | Custom JSON data attached to users, groups, or messages | [Send Message](/sdk/javascript/send-message) |
+| Tags | String labels for categorizing users, groups, conversations, or messages | [Additional Filtering](/sdk/javascript/additional-message-filtering) |
+| RequestBuilder | Builder pattern class for constructing filtered/paginated queries | [Additional Filtering](/sdk/javascript/additional-message-filtering) |
+| AppSettings | Configuration object for initializing the SDK (App ID, Region, presence) | [Setup SDK](/sdk/javascript/setup-sdk) |
+| Transient Message | Ephemeral message not stored on server (typing indicators, live reactions) | [Transient Messages](/sdk/javascript/transient-messages) |
+| Interactive Message | Message with actionable UI elements (forms, cards, buttons) | [Interactive Messages](/sdk/javascript/interactive-messages) |
-### Messaging
-
-Any message in CometChat can belong to either one of the below categories
-
-| Category | Description |
-| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| message | Any message belonging to the category `message` can belong to either one of the below types: 1. text 2. image 3. video 4. audio 5. file |
-| custom | Custom messages are an option available for developers to send custom data across to users/groups. To send any additional data that does not fit in the default categories and types provided by CometChat, you can use the custom messages. |
-| action | Action messages are system-generated messages. These can belong to either of the below types: 1. groupMember - when the action is performed on a group member 2. message - when the action is performed on a message |
-| call | These are call-related messages. These can belong to either one of the two types: 1. audio 2. video |
+---
-For more information, you can refer to the [Message structure and hierarchy guide](/sdk/javascript/message-structure-and-hierarchy).
+## Next Steps
+
+
+
+ Install and initialize the CometChat SDK
+
+
+ Log users in and manage auth tokens
+
+
+ Send your first text or media message
+
+
+ Create and manage group conversations
+
+
diff --git a/sdk/javascript/leave-group.mdx b/sdk/javascript/leave-group.mdx
index a9534b8aa..18988a705 100644
--- a/sdk/javascript/leave-group.mdx
+++ b/sdk/javascript/leave-group.mdx
@@ -1,17 +1,33 @@
---
title: "Leave A Group"
+sidebarTitle: "Leave Group"
+description: "Learn how to leave a group and receive real-time events when members leave using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Leave a group
+await CometChat.leaveGroup("GUID");
+
+// Listen for member left events
+CometChat.addGroupListener("listener", new CometChat.GroupListener({
+ onGroupMemberLeft: (message, leavingUser, group) => { }
+}));
+```
+
+
+Leave a group to stop receiving updates and messages from that conversation.
## Leave a Group
-In order to stop receiving updates and messages for any particular joined group, you will have to leave the group using the `leaveGroup()` method.
+Use `leaveGroup()` to leave a group.
```javascript
-var GUID = "GUID";
+const GUID = "GUID";
CometChat.leaveGroup(GUID).then(
hasLeft => {
@@ -26,7 +42,7 @@ hasLeft => {
```typescript
-var GUID: string = "GUID";
+const GUID: string = "GUID";
CometChat.leaveGroup(GUID).then(
(hasLeft: boolean) => {
@@ -47,11 +63,11 @@ CometChat.leaveGroup(GUID).then(
Once a group is left, the user will no longer receive any updates or messages pertaining to the group.
-## Real-time Group Member Left Events
+On success, the method resolves with a success message string confirming the operation.
-*In other words, as a member of a group, how do I know if someone has left it?*
+## Real-time Group Member Left Events
-If a user leaves any group, The members of the group receive a real-time event in the `onGroupMemberLeft()` method of the `GroupListener` class.
+Register a `GroupListener` to receive events when members leave.
@@ -84,14 +100,36 @@ CometChat.addGroupListener(
-## Missed Group Member Left Events
+
+Always remove group listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+```javascript
+CometChat.removeGroupListener("UNIQUE_LISTENER_ID");
+```
+
-*In other words, as a member of a group, how do I know if someone has left it when my app is not running?*
+## Missed Group Member Left Events
-When you retrieve the list of previous messages if a member has left any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class.
+When fetching message history, leave events appear as `Action` messages with:
+- `action` — `"left"`
+- `actionBy` — [`User`](/sdk/reference/entities#user) who left
+- `actionFor` — [`Group`](/sdk/reference/entities#group) that was left
-For the group member left event, in the `Action` object received, the following fields can help you get the relevant information-
+---
-1. `action` - `left`
-2. `actionBy` - User object containing the details of the user who left the group
-3. `actionFor` - Group object containing the details of the group the user has left
+## Next Steps
+
+
+
+ Join public or password-protected groups
+
+
+ Permanently delete a group
+
+
+ Remove or ban members from a group
+
+
+ Fetch and filter the list of groups
+
+
diff --git a/sdk/javascript/login-listener.mdx b/sdk/javascript/login-listener.mdx
index 4c98ff4c4..5a103fd20 100644
--- a/sdk/javascript/login-listener.mdx
+++ b/sdk/javascript/login-listener.mdx
@@ -1,8 +1,24 @@
---
title: "Login Listener"
+description: "Listen for real-time login and logout events using the CometChat JavaScript SDK LoginListener class."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Add login listener
+CometChat.addLoginListener("LISTENER_ID", new CometChat.LoginListener({
+ loginSuccess: (user) => { },
+ loginFailure: (error) => { },
+ logoutSuccess: () => { },
+ logoutFailure: (error) => { }
+}));
+
+// Remove login listener
+CometChat.removeLoginListener("LISTENER_ID");
+```
+
The CometChat SDK provides you with real-time updates for the `login` and `logout` events. This can be achieved using the `LoginListener` class provided. LoginListener consists of 4 events that can be triggered. These are as follows:
@@ -42,7 +58,7 @@ To add the `LoginListener`, you need to use the `addLoginListener()` method prov
```typescript
- var listenerID: string = "UNIQUE_LISTENER_ID";
+ const listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.addLoginListener(
listenerID,
new CometChat.LoginListener({
@@ -66,12 +82,86 @@ To add the `LoginListener`, you need to use the `addLoginListener()` method prov
+### React Example
+
+If you're using React, register the listener inside a `useEffect` hook and clean it up on unmount:
+
+
+
+```javascript
+import { useEffect } from "react";
+import { CometChat } from "@cometchat/chat-sdk-javascript";
+
+function useLoginListener() {
+ useEffect(() => {
+ const listenerID = "LOGIN_LISTENER";
+ CometChat.addLoginListener(
+ listenerID,
+ new CometChat.LoginListener({
+ loginSuccess: (user) => {
+ console.log("User logged in:", user);
+ },
+ loginFailure: (error) => {
+ console.log("Login failed:", error);
+ },
+ logoutSuccess: () => {
+ console.log("User logged out");
+ // Redirect to login page, clear app state, etc.
+ },
+ logoutFailure: (error) => {
+ console.log("Logout failed:", error);
+ },
+ })
+ );
+
+ return () => {
+ CometChat.removeLoginListener(listenerID);
+ };
+ }, []);
+}
+```
+
+
+```typescript
+import { useEffect } from "react";
+import { CometChat } from "@cometchat/chat-sdk-javascript";
+
+function useLoginListener(): void {
+ useEffect(() => {
+ const listenerID: string = "LOGIN_LISTENER";
+ CometChat.addLoginListener(
+ listenerID,
+ new CometChat.LoginListener({
+ loginSuccess: (user: CometChat.User) => {
+ console.log("User logged in:", user);
+ },
+ loginFailure: (error: CometChat.CometChatException) => {
+ console.log("Login failed:", error);
+ },
+ logoutSuccess: () => {
+ console.log("User logged out");
+ },
+ logoutFailure: (error: CometChat.CometChatException) => {
+ console.log("Logout failed:", error);
+ },
+ })
+ );
+
+ return () => {
+ CometChat.removeLoginListener(listenerID);
+ };
+ }, []);
+}
+```
+
+
+
In order to stop receiving events related to login and logout you need to use the removeLoginListener() method provided by the SDK and pass the ID of the listener that needs to be removed.
```js
- var listenerID = "UNIQUE_LISTENER_ID";
+ const listenerID = "UNIQUE_LISTENER_ID";
CometChat.removeLoginListener(listenerID);
```
@@ -79,10 +169,33 @@ In order to stop receiving events related to login and logout you need to use th
```typescript
- var listenerID: string = "UNIQUE_LISTENER_ID";
+ const listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.removeLoginListener(listenerID);
```
+
+
+Always remove login listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+
+---
+
+## Next Steps
+
+
+
+ Learn about login methods and auth tokens
+
+
+ Monitor the SDK connection state in real time
+
+
+ Complete reference for all SDK event listeners
+
+
+ Manually manage WebSocket connections
+
+
diff --git a/sdk/javascript/managing-web-sockets-connections-manually.mdx b/sdk/javascript/managing-web-sockets-connections-manually.mdx
index 90cf107b5..6cd7a7380 100644
--- a/sdk/javascript/managing-web-sockets-connections-manually.mdx
+++ b/sdk/javascript/managing-web-sockets-connections-manually.mdx
@@ -1,8 +1,24 @@
---
title: "Managing Web Sockets Connections Manually"
+description: "Learn how to manually manage WebSocket connections for real-time messaging using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Disable auto WebSocket connection during init
+const appSettings = new CometChat.AppSettingsBuilder()
+ .setRegion("REGION")
+ .autoEstablishSocketConnection(false)
+ .build();
+await CometChat.init("APP_ID", appSettings);
+
+// Manually connect/disconnect
+CometChat.connect();
+CometChat.disconnect();
+```
+
## Default SDK behaviour on login
@@ -98,3 +114,22 @@ CometChat.disconnect();
+
+---
+
+## Next Steps
+
+
+
+ Monitor the SDK connection state in real time
+
+
+ Listen for login and logout events
+
+
+ Complete reference for all SDK event listeners
+
+
+ SDK installation and initialization guide
+
+
diff --git a/sdk/javascript/mentions.mdx b/sdk/javascript/mentions.mdx
index c3ce4742a..72ce3d6cc 100644
--- a/sdk/javascript/mentions.mdx
+++ b/sdk/javascript/mentions.mdx
@@ -1,8 +1,29 @@
---
title: "Mentions"
+sidebarTitle: "Mentions"
+description: "Send messages with user mentions, retrieve mentioned users, and filter messages by mention metadata using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// Send a message with a mention (use <@uid:UID> format)
+const msg = new CometChat.TextMessage("receiverUID", "Hello <@uid:cometchat-uid-1>", CometChat.RECEIVER_TYPE.USER);
+await CometChat.sendMessage(msg);
+
+// Get mentioned users from a message
+const mentionedUsers = message.getMentionedUsers();
+
+// Fetch messages with mention tag info
+const request = new CometChat.MessagesRequestBuilder()
+ .setUID("UID").setLimit(30).mentionsWithTagInfo(true).build();
+const messages = await request.fetchPrevious();
+```
+
+
+
Mentions in messages enable users to refer to specific individual within a conversation. This is done by using the `<@uid:UID>` format, where `UID` represents the user’s unique identification.
@@ -127,7 +148,7 @@ To get a list of messages in a conversation where users are mentioned along with
let UID = "UID";
let limit = 30;
-var messagesRequest = new CometChat.MessagesRequestBuilder()
+let messagesRequest = new CometChat.MessagesRequestBuilder()
.setUID(UID)
.setLimit(limit)
.mentionsWithTagInfo(true)
@@ -154,7 +175,7 @@ messagesRequest.fetchPrevious().then(
let GUID = "GUID";
let limit = 30;
-var messagesRequest = new CometChat.MessagesRequestBuilder()
+let messagesRequest = new CometChat.MessagesRequestBuilder()
.setGUID(GUID)
.setLimit(limit)
.mentionsWithTagInfo(true)
@@ -246,7 +267,7 @@ To get a list of messages in a conversation where users are mentioned along with
let UID = "UID";
let limit = 30;
-var messagesRequest = new CometChat.MessagesRequestBuilder()
+let messagesRequest = new CometChat.MessagesRequestBuilder()
.setUID(UID)
.setLimit(limit)
.mentionsWithBlockedInfo(true)
@@ -274,7 +295,7 @@ messagesRequest.fetchPrevious().then(
let GUID = "GUID";
let limit = 30;
-var messagesRequest = new CometChat.MessagesRequestBuilder()
+let messagesRequest = new CometChat.MessagesRequestBuilder()
.setGUID(GUID)
.setLimit(limit)
.mentionsWithBlockedInfo(true)
@@ -366,3 +387,29 @@ To retrieve the list of users mentioned in the particular message, you can use t
```javascript
message.getMentionedUsers()
```
+
+Messages containing mentions are returned as [`BaseMessage`](/sdk/reference/messages#basemessage) objects with mention-related fields populated. Access the mention data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| mentionedUsers | `getMentionedUsers()` | [`User[]`](/sdk/reference/entities#user) | Array of users mentioned in the message |
+| hasMentionedMe | `hasMentionedMe()` | `boolean` | Whether the logged-in user is mentioned in the message |
+
+---
+
+## Next Steps
+
+
+
+ Send text, media, and custom messages
+
+
+ Listen for incoming messages in real time
+
+
+ Add emoji reactions to messages
+
+
+ Organize conversations with message threads
+
+
diff --git a/sdk/javascript/message-structure-and-hierarchy.mdx b/sdk/javascript/message-structure-and-hierarchy.mdx
index 797cb91df..1f93fc379 100644
--- a/sdk/javascript/message-structure-and-hierarchy.mdx
+++ b/sdk/javascript/message-structure-and-hierarchy.mdx
@@ -1,86 +1,187 @@
---
-title: "Message"
-sidebarTitle: "Message Structure And Hierarchy"
+title: "Message Structure and Hierarchy"
+sidebarTitle: "Message Structure"
+description: "Understand the message categories, types, and hierarchy in the CometChat JavaScript SDK including text, media, custom, action, interactive, and call messages."
---
+
+Message categories and types:
+- **message** → `text`, `image`, `video`, `audio`, `file`
+- **custom** → Developer-defined types (e.g., `location`, `poll`)
+- **interactive** → `form`, `card`, `customInteractive`
+- **action** → `groupMember` (joined/left/kicked/banned), `message` (edited/deleted)
+- **call** → `audio`, `video`
+
-The below diagram helps you better understand the various message categories and types that a CometChat message can belong to.
+Every message in CometChat belongs to a category and has a specific type. Understanding this hierarchy helps you handle different message types correctly in your application.
+
+## Message Hierarchy
-As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
-
-1. Message
-2. Custom
-3. Action
-4. Call
-
-Each category can be further be classified into types.
-
-A message belonging to the category `message` can be classified into either 1 of the below types:
-
-1. text - A plain text message
-2. image- An image message
-3. video- A video message
-4. audio- An audio message
-5. file- A file message
-
-## Custom
-
-In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
-
-## Interactive
-
-An InteractiveMessage is a specialized object that encapsulates an interactive unit within a chat message, such as an embedded form that users can fill out directly within the chat interface. Messages belonging to the interactive category can further be classified into one of the below types:
-
-1. form- for interactive form
-2. card- for interactive card
-3. customInteractive- for custom interaction messages
-
-
-
-to know about Interactive messages please [click here](/sdk/javascript/interactive-messages)
+## Categories Overview
+
+| Category | Types | Description |
+| --- | --- | --- |
+| `message` | `text`, `image`, `video`, `audio`, `file` | Standard user messages |
+| `custom` | Developer-defined | Custom data (location, polls, etc.) |
+| `interactive` | `form`, `card`, `customInteractive` | Messages with actionable UI elements |
+| `action` | `groupMember`, `message` | System-generated events |
+| `call` | `audio`, `video` | Call-related messages |
+
+## Checking Message Category and Type
+
+Use `getCategory()` and `getType()` to determine how to handle a received message:
+
+
+
+```javascript
+const category = message.getCategory();
+const type = message.getType();
+
+switch (category) {
+ case CometChat.CATEGORY_MESSAGE:
+ if (type === CometChat.MESSAGE_TYPE.TEXT) {
+ console.log("Text:", message.getText());
+ } else if (type === CometChat.MESSAGE_TYPE.IMAGE) {
+ console.log("Image URL:", message.getData().url);
+ }
+ break;
+ case CometChat.CATEGORY_CUSTOM:
+ console.log("Custom type:", type, "data:", message.getData());
+ break;
+ case CometChat.CATEGORY_ACTION:
+ console.log("Action:", message.getAction());
+ break;
+ case CometChat.CATEGORY_CALL:
+ console.log("Call status:", message.getStatus());
+ break;
+}
+```
+
+
+```typescript
+const category: string = message.getCategory();
+const type: string = message.getType();
+
+switch (category) {
+ case CometChat.CATEGORY_MESSAGE:
+ if (type === CometChat.MESSAGE_TYPE.TEXT) {
+ const textMsg = message as CometChat.TextMessage;
+ console.log("Text:", textMsg.getText());
+ } else if (type === CometChat.MESSAGE_TYPE.IMAGE) {
+ const mediaMsg = message as CometChat.MediaMessage;
+ console.log("Image URL:", mediaMsg.getData().url);
+ }
+ break;
+ case CometChat.CATEGORY_CUSTOM:
+ const customMsg = message as CometChat.CustomMessage;
+ console.log("Custom type:", type, "data:", customMsg.getData());
+ break;
+ case CometChat.CATEGORY_ACTION:
+ const actionMsg = message as CometChat.Action;
+ console.log("Action:", actionMsg.getAction());
+ break;
+ case CometChat.CATEGORY_CALL:
+ const callMsg = message as CometChat.Call;
+ console.log("Call status:", callMsg.getStatus());
+ break;
+}
+```
+
+
+
+## Message Category
+
+Messages with category `message` are standard user-sent messages:
+
+| Type | Description |
+| --- | --- |
+| `text` | Plain text message |
+| `image` | Image attachment |
+| `video` | Video attachment |
+| `audio` | Audio attachment |
+| `file` | File attachment |
+
+## Custom Category
+
+Custom messages allow you to send data that doesn't fit the default categories. You define your own type to identify the message (e.g., `location`, `poll`, `sticker`).
+
+```javascript
+// Example: Sending a location as a custom message
+const customMessage = new CometChat.CustomMessage(
+ receiverID,
+ CometChat.RECEIVER_TYPE.USER,
+ "location",
+ { latitude: 37.7749, longitude: -122.4194 }
+);
+```
+
+See [Send Message → Custom Messages](/sdk/javascript/send-message#custom-message) for details.
+
+## Interactive Category
+
+Interactive messages contain actionable UI elements that users can interact with directly in the chat:
+
+| Type | Description |
+| --- | --- |
+| `form` | Embedded form with input fields |
+| `card` | Card with buttons and actions |
+| `customInteractive` | Custom interactive elements |
+
+See [Interactive Messages](/sdk/javascript/interactive-messages) for implementation details.
+
+## Action Category
+
+Action messages are system-generated events. They have a `type` and an `action` property:
+
+**Type: `groupMember`** — Actions on group members:
+- `joined` — Member joined the group
+- `left` — Member left the group
+- `kicked` — Member was kicked
+- `banned` — Member was banned
+- `unbanned` — Member was unbanned
+- `added` — Member was added
+- `scopeChanged` — Member's scope was changed
+
+**Type: `message`** — Actions on messages:
+- `edited` — Message was edited
+- `deleted` — Message was deleted
+
+## Call Category
+
+Call messages track call events with types `audio` or `video`. The `status` property indicates the call state:
+
+| Status | Description |
+| --- | --- |
+| `initiated` | Call started |
+| `ongoing` | Call accepted and in progress |
+| `canceled` | Caller canceled |
+| `rejected` | Receiver rejected |
+| `unanswered` | No answer |
+| `busy` | Receiver on another call |
+| `ended` | Call completed |
+
+See [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) for implementation.
-
-
-## Action
-
-Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types:
-
-1. groupMember - action performed on a group member.
-2. message - action performed on a message.
-
-Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below:
-
-1. joined - when a group member joins a group
-2. left - when a group member leaves a group
-3. kicked - when a group member is kicked from the group
-4. banned - when a group member is banned from the group
-5. unbanned - when a group member is unbanned from the group
-6. added - when a user is added to the group
-7. scopeChanged - When the scope of a group member is changed.
-
-For the type `message`, the action can be either one of the below:
-
-1. edited - when a message is edited.
-2. deleted - when a message is deleted.
-
-## Call
-
-Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types
-
-1. audio
-2. video
-
-The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values:
+---
-1. initiated - when a is initiated to a user/group
-2. ongoing - when the receiver of the call has accepted the call
-3. canceled - when the call has been canceled by the initiator of the call
-4. rejected - when the call has been rejected by the receiver of the call
-5. unanswered - when the call was not answered by the receiver.
-6. busy - when the receiver of the call was busy on another call.
-7. ended - when the call was successfully completed and ended by either the initiator or receiver.
+## Next Steps
+
+
+
+ Send text, media, and custom messages
+
+
+ Listen for incoming messages in real time
+
+
+ Send messages with embedded forms and buttons
+
+
+ Advanced message filtering with RequestBuilder
+
+
diff --git a/sdk/javascript/messaging-overview.mdx b/sdk/javascript/messaging-overview.mdx
index 5a8902b43..4914e383e 100644
--- a/sdk/javascript/messaging-overview.mdx
+++ b/sdk/javascript/messaging-overview.mdx
@@ -1,12 +1,40 @@
---
title: "Messaging"
sidebarTitle: "Overview"
+description: "Overview of messaging capabilities in the CometChat JavaScript SDK including sending, receiving, editing, deleting messages, and advanced features."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+Choose your path:
+- **Send Messages** → [Send Message](/sdk/javascript/send-message) - Text, media, custom
+- **Receive Messages** → [Receive Message](/sdk/javascript/receive-message) - Real-time listeners
+- **Edit/Delete** → [Edit](/sdk/javascript/edit-message) | [Delete](/sdk/javascript/delete-message)
+- **Advanced** → [Threads](/sdk/javascript/threaded-messages) | [Reactions](/sdk/javascript/reactions) | [Mentions](/sdk/javascript/mentions)
+
Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history.
At the minimum, you must add code for [sending messages](/sdk/javascript/send-message) and [receiving messages](/sdk/javascript/receive-message).
Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/javascript/typing-indicators) and [delivery & read receipts](/sdk/javascript/delivery-read-receipts).
+
+---
+
+## Next Steps
+
+
+
+ Send text, media, and custom messages
+
+
+ Listen for incoming messages in real time
+
+
+ Understand message categories and types
+
+
+ Show real-time typing status in conversations
+
+
diff --git a/sdk/javascript/overview.mdx b/sdk/javascript/overview.mdx
index 05fa4c3d2..9be62764f 100644
--- a/sdk/javascript/overview.mdx
+++ b/sdk/javascript/overview.mdx
@@ -1,554 +1,96 @@
---
-title: "Overview"
+title: "JavaScript SDK"
+sidebarTitle: "Overview"
+description: "Add real-time chat, voice, and video to your JavaScript application with the CometChat SDK."
---
-
-
-This guide demonstrates how to add chat to a JavaScript application using CometChat. Before you begin, we strongly recommend you read the [Key Concepts](/sdk/javascript/key-concepts) guide.
-
-#### I want to integrate with my app
-
-1. [Get your application keys](overview#get-your-application-keys)
-2. [Add the CometChat dependency](overview#add-the-cometchat-dependency)
-3. [Initialize CometChat](overview#initialize-cometchat)
-4. [Register and Login your user](overview#register-and-login-your-user)
-5. [Integrate our UI Kits](overview#integrate-our-ui-kits)
-6. [Integrate our Chat Widget](overview#integrate-our-chat-widget)
-
-#### I want to explore a sample app (includes UI)
-
-Open the app folder in your favorite code editor and follow the steps mentioned in the `README.md` file.
-
-[React Sample App](https://github.com/cometchat-pro/javascript-react-chat-app)
-
-[Angular Sample App](https://github.com/cometchat-pro/javascript-angular-chat-app)
-
-[Vue Sample App](https://github.com/cometchat-pro/javascript-vue-chat-app)
-
-### Get your Application Keys
-
-[Signup for CometChat](https://app.cometchat.com) and then:
-
-1. Create a new app
-2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region**
-
-## Add the CometChat Dependency
-
-### NPM
-
-
-
-```js
- npm install @cometchat/chat-sdk-javascript
-```
-
-
-
-
-
-Then, import the `CometChat` object wherever you want to use CometChat.
-
-
-
-```js
- import { CometChat } from "@cometchat/chat-sdk-javascript";
-```
-
-
-
-
-
-### HTML (via CDN)
-
-Include the CometChat JavaScript library in your HTML code
-
-
-
-```html
-
-```
-
-
-
-
-
-### Server Side Rendering (SSR) Compatibility
-
-You can use CometChat with SSR frameworks such as [Next.js](https://nextjs.org/) or [NuxtJS](https://nuxtjs.org/) by importing it dynamically on the client side.
-
-#### Next.js
-
-You need to import the CometChat SDK dynamically in the `useEffect` React Hook or `componentDidMount()` lifecycle method.
-
-
-
-```javascript
-import React from "react";
-import Chat from "./Chat";
-
-export default function Home() {
- let [libraryImported, setLibraryImported] = React.useState(false);
-
- React.useEffect(() => {
- window.CometChat = require("@cometchat/chat-sdk-javascript").CometChat;
- setLibraryImported(true);
- });
-
- return libraryImported ? :
-
-
-
-```
-
-
-
-
-```javascript
-module.exports = {
- APP_ID: "APP_ID",
- REGION: "REGION",
- AUTH_KEY: "AUTH_KEY",
-};
-```
-
-
-
-
-
-#### Ionic/Cordova
-
-For Ionic and Cordova applications, you can use the JavaScript SDK directly. Import the CometChat SDK in your component or service:
-
-
-
-```typescript
-import { Component, OnInit } from '@angular/core';
-import { CometChat } from '@cometchat/chat-sdk-javascript';
-
-@Component({
- selector: 'app-root',
- templateUrl: 'app.component.html',
-})
-export class AppComponent implements OnInit {
-
- ngOnInit() {
- this.initCometChat();
- }
-
- initCometChat() {
- const appID = 'APP_ID';
- const region = 'APP_REGION';
-
- const appSetting = new CometChat.AppSettingsBuilder()
- .subscribePresenceForAllUsers()
- .setRegion(region)
- .autoEstablishSocketConnection(true)
- .build();
-
- CometChat.init(appID, appSetting).then(
- () => {
- console.log('CometChat initialized successfully');
- },
- (error) => {
- console.log('CometChat initialization failed:', error);
- }
- );
- }
-}
-```
-
-
-
-
-
-
-
-The dedicated Ionic Cordova SDK has been deprecated. For new Ionic/Cordova applications, use the JavaScript SDK as shown above. Existing users of the Ionic SDK can refer to the [legacy documentation](/sdk/ionic-legacy/overview) for reference.
-
-
-
-## Initialize CometChat
-
-The `init()` method initializes the settings required for CometChat. The `init()` method takes the below parameters:
-
-1. appID - Your CometChat App ID
-2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method.
-
-The `AppSettings` class allows you to configure the following settings:
-
-* **Region**: The region where your app was created.
-* [Presence Subscription](/sdk/javascript/user-presence): Represents the subscription type for user presence (real-time online/offline status)
-* **autoEstablishSocketConnection(boolean value)**: This property takes a boolean value which when set to `true` informs the SDK to manage the web-socket connection internally. If set to `false`, it informs the SDK that the web-socket connection will be managed manually. The default value for this parameter is true. For more information on this, please check the [Managing Web-Socket connections manually](/sdk/javascript/managing-web-sockets-connections-manually) section. The default value for this property is **true.**
-* **overrideAdminHost(adminHost: string)**: This method takes the admin URL as input and uses this admin URL instead of the default admin URL. This can be used in case of dedicated deployment of CometChat.
-* **overrideClientHost(clientHost: string)**: This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat.
-* **setStorageMode(storageMode)**: This method allows you to configure how CometChat stores data locally. The storageMode parameter can be set to `CometChat.StorageMode.SESSION` to use session storage, which persists data only for the current browser session, or other available storage modes for different persistence behaviors.
-
-You need to call `init()` before calling any other method from CometChat. We suggest you call the `init()` method on app startup, preferably in the `index.js` file.
-
-
-
-```js
-let appID = "APP_ID";
-let region = "APP_REGION";
-let appSetting = new CometChat.AppSettingsBuilder()
- .subscribePresenceForAllUsers()
- .setRegion(region)
- .autoEstablishSocketConnection(true)
- .setStorageMode(CometChat.StorageMode.SESSION)
- .build();
-CometChat.init(appID, appSetting).then(
- () => {
- console.log("Initialization completed successfully");
- },
- (error) => {
- console.log("Initialization failed with error:", error);
- }
-);
-```
-
-
-
-
-```typescript
-let appID: string = "APP_ID",
- region: string = "APP_REGION",
- appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder()
- .subscribePresenceForAllUsers()
- .setRegion(region)
- .autoEstablishSocketConnection(true)
- .setStorageMode(CometChat.StorageMode.SESSION)
- .build();
-CometChat.init(appID, appSetting).then(
- (initialized: boolean) => {
- console.log("Initialization completed successfully", initialized);
- }, (error: CometChat.CometChatException) => {
- console.log("Initialization failed with error:", error);
- }
-);
-```
-
-
-
-
-
-Make sure you replace the `APP_ID` with your CometChat **App ID** and `APP_REGION` with your **App Region** in the above code.
-
-## Register and Login your user
-
-Once initialization is successful, you will need to create a user. To create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful.
-
-
-
-```js
-let authKey = "AUTH_KEY";
-var UID = "user1";
-var name = "Kevin";
-
-var user = new CometChat.User(UID);
-
-user.setName(name);
-
-CometChat.createUser(user, authKey).then(
- (user) => {
- console.log("user created", user);
- },
- (error) => {
- console.log("error", error);
- }
-);
-```
-
-
-
-
-```typescript
-let authKey: string = "AUTH_KEY",
- UID: string = "user1",
- name: string = "Kevin";
-
-var user = new CometChat.User(UID);
-
-user.setName(name);
-
-CometChat.createUser(user, authKey).then(
- (user: CometChat.User) => {
- console.log("user created", user);
- },
- (error: CometChat.CometChatException) => {
- console.log("error", error);
- }
-);
-```
-
-
-
-
-
-Make sure that `UID` and `name` are specified as these are mandatory fields to create a user.
-
-Once you have created the user successfully, you will need to log the user into CometChat using the `login()` method.
-
-We recommend you call the CometChat `login()` method once your user logs into your app. The `login()` method needs to be called only once.
-
-
-
-This straightforward authentication method is ideal for proof-of-concept (POC) development or during the early stages of application development. For production environments, however, we strongly recommend using an [Auth Token](/sdk/javascript/authentication-overview#login-using-auth-token) instead of an Auth Key to ensure enhanced security.
-
-
-
-
-
-```js
-var UID = "cometchat-uid-1";
-var authKey = "AUTH_KEY";
-
-CometChat.getLoggedinUser().then(
- (user) => {
- if (!user) {
- CometChat.login(UID, authKey).then(
- (user) => {
- console.log("Login Successful:", { user });
- },
- (error) => {
- console.log("Login failed with exception:", { error });
- }
- );
- }
- },
- (error) => {
- console.log("Some Error Occured", { error });
- }
-);
-```
-
-
-
-
-```typescript
-var UID: string = "cometchat-uid-1",
- authKey: string = "AUTH_KEY";
-
-CometChat.getLoggedinUser().then(
- (user: CometChat.User) => {
- if (!user) {
- CometChat.login(UID, authKey).then(
- (user: CometChat.User) => {
- console.log("Login Successful:", { user });
- },
- (error: CometChat.CometChatException) => {
- console.log("Login failed with exception:", { error });
- }
- );
- }
- },
- (error: CometChat.CometChatException) => {
- console.log("Some Error Occured", { error });
- }
-);
-```
-
-
-
-
-
-Make sure you replace the `AUTH_KEY` with your CometChat **AuthKey** in the above code.
-
-
-Sample Users
-
-We have set up 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`.
-
-
-
-The `login()` method returns the `User` object on `Promise` resolved containing all the information of the logged-in user.
-
-
-
-UID can be alphanumeric with an underscore and hyphen. Spaces, punctuation and other special characters are not allowed.
-
-
-
-## Integrate our UI Kits
-
-* Please refer to the section to integrate [React UI Kit](/ui-kit/react/overview) into your website.
-* Please refer to the section to integrate [Angular UI Kit](/ui-kit/angular/overview) into your website.
-* Please refer to the section to integrate [Vue UI Kit](/ui-kit/vue/overview) into your website.
-
-## Integrate our Chat Widget
-
-* Please refer to the section to integrate [Chat Widget](/widget/html-bootstrap-jquery) into your Website.
+The CometChat JavaScript SDK enables you to add real-time messaging, voice, and video calling capabilities to any JavaScript application — whether it's a web app built with React, Angular, Vue, or vanilla JavaScript.
+
+## What You Can Build
+
+- One-on-one and group messaging
+- Voice and video calling
+- Typing indicators and read receipts
+- User presence (online/offline status)
+- Message reactions and threads
+- File and media sharing
+- Push notifications
+
+## Requirements
+
+| Requirement | Version |
+|-------------|---------|
+| npm | 8.x or above |
+| Node.js | 16 or above |
+
+The SDK works in all modern browsers (Chrome, Firefox, Safari, Edge) and can be used with SSR frameworks like Next.js and Nuxt.
+
+## Getting Started
+
+
+
+ [Sign up for CometChat](https://app.cometchat.com) and create an app. Note your App ID, Region, and Auth Key from the Dashboard.
+
+
+ Add the SDK to your project and initialize it with your credentials. See [Setup SDK](/sdk/javascript/setup-sdk).
+
+
+ Log in users with Auth Key (development) or Auth Token (production). See [Authentication](/sdk/javascript/authentication-overview).
+
+
+ Send and receive messages in real-time. See [Send Messages](/sdk/javascript/send-message).
+
+
+
+## Sample Apps
+
+Explore working examples with full source code:
+
+
+
+ React sample app
+
+
+ Angular sample app
+
+
+ Vue sample app
+
+
+
+## UI Kits
+
+Skip the UI work and use our pre-built components:
+
+
+
+ Ready-to-use React components
+
+
+ Ready-to-use Angular components
+
+
+ Ready-to-use Vue components
+
+
+
+## Chat Widget
+
+For the fastest integration, embed our [Chat Widget](/widget/html/overview) with just a few lines of code — no SDK knowledge required.
+
+## Resources
+
+
+
+ Understand UIDs, GUIDs, auth tokens, and core concepts
+
+
+ See what's new in the latest SDK version
+
+
+ Migration guide for V3 users
+
+
+ Common issues and solutions
+
+
diff --git a/sdk/javascript/presenter-mode.mdx b/sdk/javascript/presenter-mode.mdx
index 42b2bdc2a..bc995697d 100644
--- a/sdk/javascript/presenter-mode.mdx
+++ b/sdk/javascript/presenter-mode.mdx
@@ -1,41 +1,45 @@
---
title: "Presenter Mode"
+sidebarTitle: "Presenter Mode"
+description: "Learn how to implement Presenter Mode for webinars, keynotes, and online classes using the CometChat JavaScript Calls SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Start a presentation session
+const settings = new CometChatCalls.PresenterSettingsBuilder()
+ .setIsPresenter(true)
+ .enableDefaultLayout(true)
+ .setCallEventListener(callListener)
+ .build();
-## Overview
-
-The Presenter Mode feature allows developers to create a calling service experience in which:
+CometChatCalls.joinPresentation(callToken, settings, htmlElement);
+```
-1. There are one or more users who are presenting their video, audio and/or screen (Maximum 5)
-2. Viewers who are consumers of that presentation. (They cannot send their audio, video or screen streams out).
-3. The total number of presenters and viewers can go up to 100.
-4. Features such as mute/unmute audio, show/hide camera capture, recording, etc. will be enabled only for the Presenter in this mode.
-5. Other call participants will not get these features. Hence they act like passive viewers in the call.
+- **Presenter** (max 5): Can share video, audio, and screen
+- **Viewer** (up to 100 total): Passive consumers, no outgoing streams
+
-Using this feature developers can create experiences such as:
+## Overview
-1. All hands calls
-2. Keynote speeches
-3. Webinars
-4. Talk shows
-5. Online classes
-6. and many more...
+Presenter Mode enables broadcast-style calling experiences where presenters share content with passive viewers.
-### About this guide
+| Role | Capabilities | Max Count |
+| ---- | ------------ | --------- |
+| Presenter | Video, audio, screen sharing, mute controls, recording | 5 |
+| Viewer | Watch and listen only (no outgoing streams) | Up to 100 total |
-This guide demonstrates how to start a presentation into an React Native application. Before you begin, we strongly recommend you read the calling setup guide.
+Use cases: webinars, keynotes, all-hands meetings, online classes, talk shows.
-Before starting a call session you have to generate a call token using the generateToken() method of the CometChatCalls SDK as mentioned [here](/sdk/javascript/direct-call#generate-call-token).
+Before starting a presentation, generate a call token using `generateToken()` as described in [Call Session](/sdk/javascript/direct-call#generate-call-token).
### Start Presentation Session
-The most important class that will be used in the implementation is the `PresentationSettings` class. This class allows you to set the various parameters for the Presentation Mode. In order to set the various parameters of the `PresentationSettings` class, you need to use the `PresentationSettingsBuilder` class. Below are the various options available with the `PresentationSettings` class.
-
-You will need to set the User Type, There are 2 type of users in Presenter Mode, `Presenter` & `Participant` , You can set this `PresentationSettingsBuilder` by using the following method `setIsPresenter(true/false)`
+Configure the presentation using `PresentationSettingsBuilder`. Set the user type with `setIsPresenter(true)` for presenters or `setIsPresenter(false)` for viewers.
-A basic example of how to start a Presentation:
+Basic example:
@@ -58,9 +62,15 @@ CometChatCalls.joinPresentation(
-## **Listeners**
+## Listeners
+
+Add listeners in two ways:
+1. Use `.setCallEventListener()` in `PresentationSettingsBuilder`
+2. Use `CometChatCalls.addCallEventListener(name, listener)` for multiple listeners
-Listeners can be added in two ways the first one is to use `.setCallEventListener(listeners : OngoingCallListener)` method in `CallSettingsBuilder` or `PresenterSettingsBuilder` class. The second way is to use `CometChatCalls.addCallEventListener(name: string, callListener: OngoingCallListener)` by this you can add multiple listeners and remove the specific listener by their name `CometChatCalls.removeCallEventListener(name: string)`
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
@@ -100,7 +110,7 @@ useEffect(() => {
-The `CometChatCallsEventsListener` listener provides you with the below callback methods:
+### Events
| Callback Method | Description |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
@@ -117,14 +127,7 @@ The `CometChatCallsEventsListener` listener provides you with the below callback
## Settings
-The `PresentationSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `PresentationSettingsBuilder` class. This will eventually give you and object of the `PresentationSettings` class which you can pass to the `joinPresentation()` method to start the call.
-
-The **mandatory** parameters that are required to be present for any call/conference to work are:
-
-1. Context - context of the activity/application
-2. RelativeLayout - A RelativeLayout object in which the calling UI is loaded.
-
-The options available for customization of calls are:
+Configure the presentation experience using `PresentationSettingsBuilder`:
| Parameter | Description |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -142,6 +145,23 @@ The options available for customization of calls are:
| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are 1. CometChatCalls.AUDIO\_MODE.SPEAKER = "SPEAKER" 2. CometChatCalls.AUDIO\_MODE.EARPIECE = "EARPIECE" 3. CometChatCalls.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH" 4. CometChatCalls.AUDIO\_MODE.HEADPHONES = "HEADPHONES" |
| `setEventListener(new CometChatCallsEventsListener())` | The `CometChatCallsEventsListener` listener provides you callbacks |
-In case you wish to achieve a completely customised UI for the Calling experience, you can do so by embedding default android buttons to the screen as per your requirement and then use the below methods to achieve different functionalities for the embedded buttons.
+For custom UI, embed your own buttons and use the call control methods described in [Call Session Methods](/sdk/javascript/direct-call#methods).
+
+---
-For the use case where you wish to align your own custom buttons and not use the default layout provided by CometChat you can embed the buttons in your layout and use the below methods to perform the corresponding operations:
+## Next Steps
+
+
+
+ Start standard call sessions without presenter mode
+
+
+ Record call and presentation sessions
+
+
+ Add virtual backgrounds to video calls
+
+
+ Customize the video layout and containers
+
+
diff --git a/sdk/javascript/rate-limits.mdx b/sdk/javascript/rate-limits.mdx
index 17581b144..1d8a4a86c 100644
--- a/sdk/javascript/rate-limits.mdx
+++ b/sdk/javascript/rate-limits.mdx
@@ -1,34 +1,119 @@
---
title: "Rate Limits"
+description: "Understand CometChat REST API rate limits, response headers, and how to handle rate-limited requests in your JavaScript application."
---
+
+- Core Operations (login, create/delete user, create/join group): `10,000` requests/min cumulative
+- Standard Operations (all other): `20,000` requests/min cumulative
+- Rate-limited responses return HTTP `429` with `Retry-After` and `X-Rate-Limit-Reset` headers
+- Monitor usage via `X-Rate-Limit` and `X-Rate-Limit-Remaining` response headers
+
-### CometChat REST API Rate Limits
+CometChat applies rate limits to ensure fair usage and platform stability. Understanding these limits helps you build applications that handle high traffic gracefully.
-
+## Rate Limit Tiers
-The rate limits below are for general applications. Rate limits can be adjusted on a per need basis, depending on your use-case and plan. The rate limits are cumulative. For example: If the rate limit for core operations is 100 requests per minute, then you can either login a user, add user to a group, remove a user from a group, etc for total 100 requests per minute.
+| Operation Type | Limit | Examples |
+| --- | --- | --- |
+| Core Operations | 10,000 requests/min | Login, create/delete user, create/join group |
+| Standard Operations | 20,000 requests/min | All other operations |
+
+Rate limits are cumulative within each tier. For example, if you make 5,000 login requests and 5,000 create user requests in one minute, you've hit the 10,000 core operations limit.
-1. **Core Operations:** Core operations are rate limited to `10,000` requests per minute. Core operations include user login, create/delete user, create/join group cumulatively.
-2. **Standard Operations:** Standard operations are rate limited to `20,000` requests per minute. Standard operations include all other operations cumulatively.
-
-## What happens when rate limit is reached ?
-
-The request isn't processed and a response is sent containing a 429 response code. Along with the response code there will be couple of headers sent which specifies the time in seconds that you must wait before you can try request again.
-
-`Retry-After: 15`
+## Response Headers
+
+CometChat includes rate limit information in response headers:
+
+| Header | Description |
+| --- | --- |
+| `X-Rate-Limit` | Your current rate limit |
+| `X-Rate-Limit-Remaining` | Requests remaining in current window |
+| `Retry-After` | Seconds to wait before retrying (on 429) |
+| `X-Rate-Limit-Reset` | Unix timestamp when limit resets (on 429) |
+
+## Handling Rate Limits
+
+When you exceed the rate limit, CometChat returns HTTP `429 Too Many Requests`. Implement exponential backoff to handle this gracefully:
+
+
+
+```javascript
+async function callWithRetry(apiCall, maxRetries = 3) {
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
+ try {
+ return await apiCall();
+ } catch (error) {
+ if (error.code === "ERR_TOO_MANY_REQUESTS" && attempt < maxRetries - 1) {
+ const waitTime = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
+ console.log(`Rate limited. Retrying in ${waitTime / 1000}s...`);
+ await new Promise((resolve) => setTimeout(resolve, waitTime));
+ } else {
+ throw error;
+ }
+ }
+ }
+}
+
+// Usage
+const users = await callWithRetry(() =>
+ new CometChat.UsersRequestBuilder().setLimit(30).build().fetchNext()
+);
+```
+
+
+```typescript
+async function callWithRetry(
+ apiCall: () => Promise,
+ maxRetries: number = 3
+): Promise {
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
+ try {
+ return await apiCall();
+ } catch (error: any) {
+ if (error.code === "ERR_TOO_MANY_REQUESTS" && attempt < maxRetries - 1) {
+ const waitTime = Math.pow(2, attempt) * 1000;
+ console.log(`Rate limited. Retrying in ${waitTime / 1000}s...`);
+ await new Promise((resolve) => setTimeout(resolve, waitTime));
+ } else {
+ throw error;
+ }
+ }
+ }
+ throw new Error("Max retries exceeded");
+}
+
+// Usage
+const users: CometChat.User[] = await callWithRetry(() =>
+ new CometChat.UsersRequestBuilder().setLimit(30).build().fetchNext()
+);
+```
+
+
+
+## Tips for Staying Within Limits
+
+- **Batch operations** — Space out bulk operations over time instead of firing all at once
+- **Monitor headers** — Check `X-Rate-Limit-Remaining` to proactively slow down before hitting limits
+- **Avoid frequent login/logout** — Core operations share a lower limit; minimize login cycles
+- **Use pagination** — Fetch data in reasonable page sizes (30-50 items) rather than requesting everything at once
-`X-Rate-Limit-Reset: 1625143246`
-
-## Is there any endpoint that returns rate limit of all resources ?
-
-No, we don't provide a rate-limit endpoint.
+
+Rate limits can be adjusted based on your use case and plan. Contact CometChat support if you need higher limits.
+
-However, we do provide the following response headers that you can use to confirm the app's current rate limit and monitor the number of requests remaining in the current minute:
+---
-`X-Rate-Limit: 700`
+## Next Steps
-`X-Rate-Limit-Remaining: 699`
+
+
+ Install and configure the CometChat JavaScript SDK
+
+
+ Learn the core concepts behind CometChat
+
+
diff --git a/sdk/javascript/reactions.mdx b/sdk/javascript/reactions.mdx
index 8ac8f43fd..82e226f6e 100644
--- a/sdk/javascript/reactions.mdx
+++ b/sdk/javascript/reactions.mdx
@@ -1,8 +1,31 @@
---
title: "Reactions"
+sidebarTitle: "Reactions"
+description: "Add, remove, and fetch message reactions in real-time using the CometChat JavaScript SDK. Includes listener events and helper methods for updating UI."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Add a reaction
+await CometChat.addReaction(messageId, "😊");
+
+// Remove a reaction
+await CometChat.removeReaction(messageId, "😊");
+
+// Fetch reactions for a message
+const request = new CometChat.ReactionRequestBuilder()
+ .setMessageId(messageId).setLimit(10).build();
+const reactions = await request.fetchNext();
+
+// Listen for reaction events
+CometChat.addMessageListener("LISTENER_ID", {
+ onMessageReactionAdded: (reaction) => {},
+ onMessageReactionRemoved: (reaction) => {}
+});
+```
+
Enhance user engagement in your chat application with message reactions. Users can express their emotions using reactions to messages. This feature allows users to add or remove reactions, and to fetch all reactions on a message. You can also listen to reaction events in real-time. Let's see how to work with reactions in CometChat's SDK.
@@ -86,6 +109,14 @@ CometChat.removeReaction(messageId, emoji)
+Both `addReaction()` and `removeReaction()` return a [`BaseMessage`](/sdk/reference/messages#basemessage) object with the updated reactions. Access the reaction data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| reactions | `getReactions()` | [`ReactionCount[]`](/sdk/reference/auxiliary#reactioncount) | Array of reaction counts on the message |
+
## Fetch Reactions for a Message
To get all reactions for a specific message, first create a `ReactionRequest` using `ReactionRequestBuilder`. You can specify the number of reactions to fetch with setLimit with max limit 100. For this, you will require the ID of the message. This ID needs to be passed to the `setMessageId()` method of the builder class. The `setReaction()` will allow you to fetch details for specific reaction or emoji.
@@ -201,6 +232,10 @@ reactionRequest.fetchPrevious().then(
Keep the chat interactive with real-time updates for reactions. Register a listener for these events and make your UI responsive.
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+
```js
@@ -236,6 +271,16 @@ CometChat.addMessageListener(listenerID, {
+Each reaction listener callback receives a [`ReactionEvent`](/sdk/reference/auxiliary#reactionevent) object. Access the event data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| reaction | `getReaction()` | [`Reaction`](/sdk/reference/auxiliary#reaction) | The reaction object containing emoji, user, and timestamp |
+| receiverId | `getReceiverId()` | `string` | UID or GUID of the receiver |
+| receiverType | `getReceiverType()` | `string` | Type of receiver (`user` or `group`) |
+| conversationId | `getConversationId()` | `string` | ID of the conversation |
+| parentMessageId | `getParentMessageId()` | `string` | ID of the parent message (for threaded messages) |
+
## Removing a Reaction Listener
To stop listening for reaction events, remove the listener as follows:
@@ -284,7 +329,7 @@ message.getReactions()
## Check if Logged-in User has Reacted on Message
-To check if the logged-in user has reacted on a particular message or not, You can use the `getReactedByMe()` method on any `ReactionCount` object instance. This method will return a boolean value, true if the logged-in user has reacted on that message, otherwise false.
+To check if the logged-in user has reacted on a particular message or not, You can use the `getReactedByMe()` method on any [`ReactionCount`](/sdk/reference/auxiliary#reactioncount) object instance. This method will return a boolean value, true if the logged-in user has reacted on that message, otherwise false.
@@ -313,9 +358,9 @@ reaction.getReactedByMe(); //Return true is logged-in user reacted on that messa
When a user adds or removes a reaction, you will receive a real-time event. Once you receive the real time event you would want to update the message with the latest reaction information. To do so you can use the `updateMessageWithReactionInfo()` method.
-The `updateMessageWithReactionInfo()` method provides a seamless way to update the reactions on a message instance (`BaseMessage`) in real-time. This method ensures that when a reaction is added or removed from a message, the BaseMessage object's `getReactions()` property reflects this change immediately.
+The `updateMessageWithReactionInfo()` method provides a seamless way to update the reactions on a message instance ([`BaseMessage`](/sdk/reference/messages#basemessage)) in real-time. This method ensures that when a reaction is added or removed from a message, the `BaseMessage` object's `getReactions()` property reflects this change immediately.
-When you receive a real-time reaction event (`MessageReaction`), call the `updateMessageWithReactionInfo()` method, passing the BaseMessage instance (`message`), event data (`MessageReaction`) and reaction event action type (`CometChat.REACTION_ACTION.REACTION_ADDED` or `CometChat.REACTION_ACTION.REACTION_REMOVED`) that corresponds to the message being reacted to.
+When you receive a real-time reaction event ([`MessageReaction`](/sdk/reference/auxiliary#messagereaction)), call the `updateMessageWithReactionInfo()` method, passing the `BaseMessage` instance (`message`), event data (`MessageReaction`) and reaction event action type (`CometChat.REACTION_ACTION.REACTION_ADDED` or `CometChat.REACTION_ACTION.REACTION_REMOVED`) that corresponds to the message being reacted to.
@@ -361,3 +406,16 @@ action
After calling this method, the message instance's reactions are updated. You can then use message.getReactions() to get the latest reactions and refresh your UI accordingly.
+
+---
+
+## Next Steps
+
+
+
+ Send text, media, and custom messages to users and groups
+
+
+ Listen for incoming messages in real-time and fetch missed messages
+
+
diff --git a/sdk/javascript/receive-message.mdx b/sdk/javascript/receive-message.mdx
index a6f9a8925..c4ac562d4 100644
--- a/sdk/javascript/receive-message.mdx
+++ b/sdk/javascript/receive-message.mdx
@@ -1,19 +1,32 @@
---
-title: "Receive A Message"
+title: "Receive Messages"
+sidebarTitle: "Receive Messages"
+description: "Receive real-time messages, fetch missed and unread messages, retrieve message history, search messages, and get unread counts using the CometChat JavaScript SDK."
---
+
+| Field | Value |
+| --- | --- |
+| Key Classes | `CometChat.MessageListener`, `CometChat.MessagesRequestBuilder` |
+| Key Methods | `addMessageListener()`, `fetchPrevious()`, `fetchNext()`, `getUnreadMessageCount()` |
+| Listener Events | `onTextMessageReceived`, `onMediaMessageReceived`, `onCustomMessageReceived` |
+| Prerequisites | SDK initialized, user logged in |
+
+
Receiving messages with CometChat has two parts:
-1. Adding a listener to receive [real-time messages](/sdk/javascript/receive-message#real-time-messages) when your app is running
-2. Calling a method to retrieve [missed messages](/sdk/javascript/receive-message#missed-messages) when your app was not running
+1. Adding a listener to receive [real-time messages](#real-time-messages) when your app is running
+2. Calling a method to retrieve [missed messages](#missed-messages) when your app was not running
## Real-Time Messages
-*In other words, as a recipient, how do I receive messages when my app is running?*
+Register the `MessageListener` to receive incoming messages in real-time using `addMessageListener()`.
-To receive real-time incoming messages, you need to register the `MessageListener` wherever you wish to receive the incoming messages. You can use the `addMessageListener()` method to do so.
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
@@ -62,11 +75,11 @@ CometChat.addMessageListener(
-| Parameter | Description |
-| -------------- | --------------------------------------------- |
-| **listenerId** | An ID that uniquely identifies that listener. |
+| Parameter | Description |
+| --- | --- |
+| `listenerID` | An ID that uniquely identifies that listener |
-We recommend you remove the listener once you don't want to receive a message for particular listener.
+Remove the listener when you no longer need to receive messages:
@@ -90,22 +103,25 @@ CometChat.removeMessageListener(listenerID);
-
As a sender, you will not receive your own message in a real-time message event. However, if a user is logged-in using multiple devices, they will receive an event for their own message in other devices.
-
-## Missed Messages
-
-*In other words, as a recipient, how do I receive messages that I missed when my app was not running?*
+Each listener callback receives the specific message subclass — [`TextMessage`](/sdk/reference/messages#textmessage), [`MediaMessage`](/sdk/reference/messages#mediamessage), or [`CustomMessage`](/sdk/reference/messages#custommessage) — depending on the message type. Access the data using getter methods:
-For most use cases, you will need to add functionality to load missed messages. If you're building an on-demand or live streaming app, you may choose to skip this and fetch message history instead.
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| receiverId | `getReceiverId()` | `string` | UID or GUID of the receiver |
+| type | `getType()` | `string` | Message type (`text`, `image`, `custom`, etc.) |
+| sentAt | `getSentAt()` | `number` | Timestamp when the message was sent |
+| text | `getText()` | `string` | Text content (TextMessage only) |
-Using the same `MessagesRequest` class and the filters provided by the `MessagesRequestBuilder` class, you can fetch the message that were sent to the logged-in user but were not delivered to him as he was offline. For this, you will require the id of the last message received. You can either maintain it at your end or use the `getLastDeliveredMessageId()` method provided by the CometChat class. This id needs to be passed to the `setMessageId()` method of the builder class.
+## Missed Messages
-Now using the `fetchNext()` method, you can fetch all the messages that were sent to the user when he/she was offline.
+Fetch messages that were sent while your app was offline using `MessagesRequestBuilder` with `setMessageId()` and `fetchNext()`.
-Calling the `fetchNext()` method on the same object repeatedly allows you to fetch all the offline messages for the logged in user.
+Use `getLastDeliveredMessageId()` to get the ID of the last delivered message, then fetch all messages after that point. Call `fetchNext()` repeatedly on the same object to paginate through all missed messages.
### Fetch Missed Messages of a particular one-on-one conversation
@@ -116,7 +132,7 @@ let UID = "UID";
let limit = 30;
let latestId = await CometChat.getLastDeliveredMessageId();
-var messagesRequest = new CometChat.MessagesRequestBuilder()
+let messagesRequest = new CometChat.MessagesRequestBuilder()
.setUID(UID)
.setMessageId(latestId)
.setLimit(limit)
@@ -169,7 +185,7 @@ let GUID = "GUID";
let limit = 30;
let latestId = await CometChat.getLastDeliveredMessageId();
-var messagesRequest = new CometChat.MessagesRequestBuilder()
+let messagesRequest = new CometChat.MessagesRequestBuilder()
.setGUID(GUID)
.setMessageId(latestId)
.setLimit(limit)
@@ -213,11 +229,19 @@ messagesRequest.fetchNext().then(
-## Unread Messages
+The `fetchNext()` method returns an array of [`BaseMessage`](/sdk/reference/messages#basemessage) objects (which may be [`TextMessage`](/sdk/reference/messages#textmessage), [`MediaMessage`](/sdk/reference/messages#mediamessage), or other subclasses). Access the data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| type | `getType()` | `string` | Message type (`text`, `image`, `custom`, etc.) |
+| sentAt | `getSentAt()` | `number` | Timestamp when the message was sent |
+| conversationId | `getConversationId()` | `string` | ID of the conversation the message belongs to |
-*In other words, as a logged-in user, how do I fetch the messages I've not read?*
+## Unread Messages
-Using the `MessagesRequest` class described above, you can fetch the unread messages for the logged in user. In order to achieve this, you need to set the `unread` variable in the builder to true using the `setUnread()` method so that only the unread messages are fetched.
+Fetch unread messages by setting `setUnread(true)` on the builder.
### Fetch Unread Messages of a particular one-on-one conversation
@@ -320,19 +344,16 @@ messagesRequest.fetchPrevious().then(
-Base Message
-
-The list of messages received is in the form of objects of `BaseMessage` class. A BaseMessage can either be an object of the `TextMessage`, `MediaMessage`, `CustomMessage`, `Action` or `Call` class. You can use the `instanceOf` operator to check the type of object.
-
+The list of messages received is in the form of [`BaseMessage`](/sdk/reference/messages#basemessage) objects. A `BaseMessage` can either be an object of the [`TextMessage`](/sdk/reference/messages#textmessage), [`MediaMessage`](/sdk/reference/messages#mediamessage), [`CustomMessage`](/sdk/reference/messages#custommessage), `Action` or `Call` class. You can use the `instanceof` operator to check the type of object.
## Message History
-*In other words, as a logged-in user, how do I fetch the complete message history?*
+Fetch the complete conversation history using `MessagesRequestBuilder` with `fetchPrevious()`. Call `fetchPrevious()` repeatedly on the same object to paginate through the entire conversation — useful for implementing upward scrolling.
### Fetch Message History of a particular one-on-one conversation
-Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation between the logged in user and any particular user. For this use case, it is mandatory to set the UID parameter using the `setUID()` method of the builder. This UID is the unique id of the user for which the conversation needs to be fetched.
+Set the UID using `setUID()` to fetch the conversation with a specific user.
@@ -377,11 +398,9 @@ messagesRequest.fetchPrevious().then(
-Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation between the logged in user and the specified user. This can be implemented with upward scrolling to display the entire conversation.
-
### Fetch Message History of a particular group conversation
-Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation for any group provided you have joined the group. For this use case, it is mandatory to set the GUID parameter using the `setGUID()` method of the builder. This GUID is the unique identifier of the Group for which the messages are to be fetched.
+Set the GUID using `setGUID()` to fetch messages from a group you've joined.
@@ -429,20 +448,24 @@ messagesRequest.fetchPrevious().then(
-Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation for the group. This can be implemented with upward scrolling to display the entire conversation.
+The `fetchPrevious()` method returns an array of [`BaseMessage`](/sdk/reference/messages#basemessage) objects (which may be [`TextMessage`](/sdk/reference/messages#textmessage), [`MediaMessage`](/sdk/reference/messages#mediamessage), or other subclasses). Access the data using getter methods:
-## Search Messages
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| type | `getType()` | `string` | Message type (`text`, `image`, `custom`, etc.) |
+| sentAt | `getSentAt()` | `number` | Timestamp when the message was sent |
+| conversationId | `getConversationId()` | `string` | ID of the conversation the message belongs to |
-In other words, as a logged-in user, how do I search a message?
+## Search Messages
-In order to do this, you can use the `setSearchKeyword()` method. This method accepts string as input. When set, the SDK will fetch messages which match the `searchKeyword`.
+Use `setSearchKeyword()` to search for messages matching a keyword.
-
By default, the searchKey is searched only in message text. However, if you enable `Conversation & Advanced Search`, the searchKey will be searched in message text, file name, mentions & mime type of the file.
The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration)
-
| Feature | Basic Search | Advance Search |
@@ -558,15 +581,11 @@ messagesRequest.fetchPrevious().then(
## Unread Message Count
-*In other words, as a logged-in user, how do I find out the number of unread messages that I have?*
+Get the number of unread messages for users, groups, or all conversations.
### Fetch Unread Message Count of a particular one-on-one conversation
-*In other words, how do I find out the number of unread messages I have from a particular user?*
-
-In order to get the unread message count for a particular user, you can use the `getUnreadMessageCountForUser()`.
-
-This method has the below two variants:
+Use `getUnreadMessageCountForUser()` to get the unread count for a specific user.
@@ -586,7 +605,7 @@ CometChat.getUnreadMessageCountForUser(UID);
-If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true:
+To ignore messages from blocked users, set the boolean parameter to true:
@@ -642,15 +661,11 @@ CometChat.getUnreadMessageCountForUser(UID).then(
-It will return an object which will contain the UID as the key and the unread message count as the value.
+Returns an object with the UID as key and unread message count as value.
### Fetch Unread Message Count of a particular group conversation
-*In other words, how do I find out the number of unread messages I have in a single group?*
-
-In order to get the unread message count for a particular group, you can use the `getUnreadMessageCountForGroup()`.
-
-This method has the below two variants:
+Use `getUnreadMessageCountForGroup()` to get the unread count for a specific group.
@@ -670,7 +685,7 @@ CometChat.getUnreadMessageCountForGroup(GUID);
-If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true:
+To ignore messages from blocked users, set the boolean parameter to true:
@@ -726,15 +741,11 @@ CometChat.getUnreadMessageCountForGroup(GUID).then(
-It will return an object which will contain the GUID as the key and the unread message count as the value.
+Returns an object with the GUID as key and unread message count as value.
### Fetch Unread Message Count of all one-on-one & group conversations
-*In other words, how do I find out the number of unread messages for every one-on-one and group conversation?*
-
-In order to get all the unread message count combined i.e unread message counts for all the users and groups, you can use the `getUnreadMessageCount()` method.
-
-This method has two variants:
+Use `getUnreadMessageCount()` to get unread counts for all users and groups combined.
@@ -753,7 +764,7 @@ CometChat.getUnreadMessageCount();
-If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true:
+To ignore messages from blocked users, set the boolean parameter to true:
@@ -804,14 +815,13 @@ CometChat.getUnreadMessageCount().then(
-It returns an object having two keys:
-
-1. users - The value for this key holds another object that holds the UID as key and their corresponding unread message count as value.
-2. groups - The value for this key holds another object that holds the GUID as key and their corresponding unread message count as value.
+Returns an object with two keys:
+- `users` — Object with UIDs as keys and unread counts as values
+- `groups` — Object with GUIDs as keys and unread counts as values
### Fetch Unread Message Count of all one-on-one conversations
-In order to fetch the unread message counts for just the users, you can use the `getUnreadMessageCountForAllUsers()` method. This method just like others has two variants:
+Use `getUnreadMessageCountForAllUsers()` to get unread counts for all user conversations.
@@ -830,7 +840,7 @@ CometChat.getUnreadMessageCountForAllUsers();
-If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true:
+To ignore messages from blocked users, set the boolean parameter to true:
@@ -881,11 +891,11 @@ CometChat.getUnreadMessageCountForAllUsers().then(
-It returns an object which will contain the UID as the key and the unread message count as the value.
+Returns an object with UIDs as keys and unread counts as values.
### Fetch Unread Message Count of all group conversations
-In order to fetch the unread message counts for just the groups, you can use the `getUnreadMessageCountForAllGroups()` method. This method just like others has two variants:
+Use `getUnreadMessageCountForAllGroups()` to get unread counts for all group conversations.
@@ -904,7 +914,7 @@ CometChat.getUnreadMessageCountForAllGroups();
-If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true:
+To ignore messages from blocked users, set the boolean parameter to true:
@@ -955,4 +965,17 @@ CometChat.getUnreadMessageCountForAllGroups().then(
-It returns an object which will contain the GUID as the key and the unread message count as the value.
+Returns an object with GUIDs as keys and unread counts as values.
+
+---
+
+## Next Steps
+
+
+
+ Track when messages are delivered and read by recipients
+
+
+ Show real-time typing status in conversations
+
+
diff --git a/sdk/javascript/recording.mdx b/sdk/javascript/recording.mdx
index 214d56bcd..1f8b119be 100644
--- a/sdk/javascript/recording.mdx
+++ b/sdk/javascript/recording.mdx
@@ -1,18 +1,40 @@
---
title: "Recording (Beta)"
+sidebarTitle: "Recording"
+description: "Implement call recording for voice and video calls using the CometChat JavaScript SDK, including start/stop controls, listeners, and accessing recordings from the Dashboard."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Start recording
+CometChatCalls.startRecording();
+
+// Stop recording
+CometChatCalls.stopRecording();
+
+// Listen for recording events (in CallSettings)
+const callListener = new CometChatCalls.OngoingCallListener({
+ onRecordingStarted: (event) => console.log("Recording started", event.user),
+ onRecordingStopped: (event) => console.log("Recording stopped", event.user),
+});
+```
+
+**Recordings are available on the [CometChat Dashboard](https://app.cometchat.com) → Calls section.**
+
-This section will guide you to implement call recording feature for the voice and video calls.
+Record voice and video calls for playback, compliance, or archival purposes.
## Implementation
-Once you have decided to implement [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) calling and followed the steps to implement them. Just few additional listeners and methods will help you quickly implement call recording in your app.
+After setting up [Ringing](/sdk/javascript/default-call) or [Call Session](/sdk/javascript/direct-call), add recording listeners and methods to your call settings.
-You need to make changes in the CometChat.startCall method and add the required listeners for recording. Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call).
+Basic example:
-A basic example of how to make changes to implement recording for a direct call/ a default call:
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
@@ -67,18 +89,16 @@ CometChatCalls.startSession(callToken, callSettings, htmlElement);
-## Settings for call recording
+## Settings
-The `CallSettings`class allows you to customise the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startSession()` method to start the call.
-
-The options available for recording of calls are:
+Configure recording options using `CallSettingsBuilder`:
| Setting | Description |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `showRecordingButton(showRecordingButton: boolean)` | If set to `true` it displays the Recording button in the button Layout. if set to `false` it hides the Recording button in the button Layout. **Default value = false** |
| `startRecordingOnCallStart(startRecordingOnCallStart: boolean)` | If set to `true` call recording will start as soon as the call is started. if set to `false` call recording will not start as soon as the call is started. **Default value = false** |
-For the use case where you wish to align your own custom buttons and not use the default layout provided by CometChat, you can embed the buttons in your layout and use the below methods to perform the corresponding operations:
+For custom UI without the default layout, use these methods to control recording:
### Start Recording
@@ -122,9 +142,9 @@ CometChatCalls.stopRecording();
-## Downloading Recording
+## Downloading Recordings
-Currently, the call recordings are available on the [CometChat Dashboard](https://app.cometchat.com/signup) under the Calls Section. Recordings can be accessed after clicking on the three dots menu icon to expand the menu and then select "View Recordings". You can refer to the below screenshot. You can refer to the below screenshot.
+Call recordings are available on the [CometChat Dashboard](https://app.cometchat.com) under the Calls section. Click the three-dot menu and select "View Recordings".
@@ -137,3 +157,16 @@ Currently, the call recordings are available on the [CometChat Dashboard](https:
+
+---
+
+## Next Steps
+
+
+
+ Implement ringing call flows with accept/reject functionality
+
+
+ Retrieve and display call history for users and groups
+
+
diff --git a/sdk/javascript/resources-overview.mdx b/sdk/javascript/resources-overview.mdx
index ea0d211bf..d2610212a 100644
--- a/sdk/javascript/resources-overview.mdx
+++ b/sdk/javascript/resources-overview.mdx
@@ -1,12 +1,32 @@
---
title: "Resources"
sidebarTitle: "Overview"
+description: "Access CometChat JavaScript SDK resources including real-time listeners reference, migration guides, and rate limits."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+- [All Real-Time Listeners](/sdk/javascript/all-real-time-listeners) — Complete listener reference
+- [Upgrading from v3](/sdk/javascript/upgrading-from-v3) — Migration guide
+- [Rate Limits](/sdk/javascript/rate-limits) — API rate limit details
+
We have a number of resources that will help you while integrating CometChat in your app.
You can begin with the [all real-time listeners](/sdk/javascript/all-real-time-listeners) guide.
If you're upgrading from v2, we recommend reading our [Upgrading from v3](/sdk/javascript/upgrading-from-v3) guide.
+
+---
+
+## Next Steps
+
+
+
+ Complete reference for all CometChat event listeners
+
+
+ Step-by-step migration guide from SDK v3 to v4
+
+
\ No newline at end of file
diff --git a/sdk/javascript/retrieve-conversations.mdx b/sdk/javascript/retrieve-conversations.mdx
index a58ef59d1..f8be2187d 100644
--- a/sdk/javascript/retrieve-conversations.mdx
+++ b/sdk/javascript/retrieve-conversations.mdx
@@ -1,22 +1,38 @@
---
title: "Retrieve Conversations"
+sidebarTitle: "Retrieve Conversations"
+description: "Fetch, filter, tag, and search conversations using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Fetch conversations list
+const request = new CometChat.ConversationsRequestBuilder()
+ .setLimit(30).build();
+const conversations = await request.fetchNext();
-Conversations provide the last messages for every one-on-one and group conversation the logged-in user is a part of. This makes it easy for you to build a **Recent Chat** list.
+// Get a specific conversation
+const conversation = await CometChat.getConversation("UID", "user");
-## Retrieve List of Conversations
+// Tag a conversation
+await CometChat.tagConversation("UID", "user", ["archived"]);
-*In other words, as a logged-in user, how do I retrieve the latest conversations that I've been a part of?*
+// Convert message to conversation
+const conversation = await CometChat.CometChatHelper.getConversationFromMessage(message);
+```
+
-To fetch the list of conversations, you can use the `ConversationsRequest` class. To use this class i.e. to create an object of the `ConversationsRequest` class, you need to use the `ConversationsRequestBuilder` class. The `ConversationsRequestBuilder` class allows you to set the parameters based on which the conversations are to be fetched.
+Conversations provide the last message for every one-on-one and group conversation the logged-in user is part of. Use this to build a Recent Chats list.
+
+## Retrieve List of Conversations
-The `ConversationsRequestBuilder` class allows you to set the below parameters:
+Use `ConversationsRequestBuilder` to fetch conversations with various filters.
### Set Limit
-This method sets the limit i.e. the number of conversations that should be fetched in a single iteration.
+Set the number of conversations to fetch per request.
@@ -43,12 +59,7 @@ let limit: number = 30,
### Set Conversation Type
-This method can be used to fetch user or group conversations specifically. The `conversationType` variable can hold one of the below two values:
-
-* user - Only fetches user conversation.
-* group - Only fetches group conversations.
-
-If none is set, the list of conversations will include both user and group conversations.
+Filter by conversation type: `user` for one-on-one or `group` for group conversations. If not set, both types are returned.
@@ -77,9 +88,15 @@ let limit: number = 30,
+
+Default limit is 30, maximum is 50.
+
+
+When conversations are fetched successfully, the response includes an array of [`Conversation`](/sdk/reference/entities#conversation) objects filtered by the specified type.
+
### With User and Group Tags
-This method can be used to fetch the user/group tags in the `Conversation` Object. By default the value is `false`.
+Use `withUserAndGroupTags(true)` to include user/group tags in the response. Default is `false`.
@@ -106,9 +123,11 @@ let limit: number = 30,
+When conversations are fetched successfully, the response includes `tags` arrays on the `conversationWith` objects.
+
### Set User Tags
-This method fetches user conversations that have the specified tags.
+Fetch user conversations where the user has specific tags.
@@ -137,9 +156,11 @@ let limit: number = 30,
+When conversations are fetched successfully, the response includes only user conversations where the user has the specified tags.
+
### Set Group Tags
-This method fetches group conversations that have the specified tags.
+Fetch group conversations where the group has specific tags.
@@ -168,9 +189,11 @@ let limit: number = 30,
+When conversations are fetched successfully, the response includes only group conversations where the group has the specified tags.
+
### With Tags
-This method makes sure that the tags associated with the conversations are returned along with the other details of the conversations. The default value for this parameter is `false`
+Use `withTags(true)` to include conversation tags in the response. Default is `false`.
@@ -196,10 +219,9 @@ conversationRequest: CometChat.ConversationsRequest = new CometChat.Conversation
-
### Set Tags
-This method helps you fetch the conversations based on the specified tags.
+Fetch conversations that have specific tags.
@@ -227,10 +249,9 @@ let limit: number = 30,
-
### Include Blocked Users
-This method helps you fetch the conversations of users whom the logged-in user has blocked.
+Use `setIncludeBlockedUsers(true)` to include conversations with users you've blocked.
@@ -257,9 +278,11 @@ let limit: number = 30,
+When conversations are fetched successfully, the response includes conversations with blocked users. To also get blocked info details (`blockedByMe`, `blockedByMeAt`, `blockedAt`), set `withBlockedInfo` to `true`.
+
### With Blocked Info
-This method can be used to fetch the blocked information of the blocked user in the `ConversationWith` object.
+Use `setWithBlockedInfo(true)` to include blocked user information in the response.
@@ -285,10 +308,9 @@ let limit: number = 30,
-
### Search Conversations
-This method helps you search a conversation based on User or Group name.
+Use `setSearchKeyword()` to search conversations by user or group name.
@@ -321,9 +343,11 @@ let limit: number = 30,
+When conversations are fetched successfully, the response includes conversations where the user or group name matches the search keyword.
+
### Unread Conversations
-This method helps you fetch unread conversations.
+Use `setUnread(true)` to fetch only conversations with unread messages.
@@ -356,9 +380,11 @@ let limit: number = 30,
+When conversations are fetched successfully, the response includes only conversations with unread messages (`unreadMessageCount` > 0).
+
### Hide Agentic Conversations
-This method allows you to exclude agent conversations from the conversation list. When set to `true`, conversations with AI agents will be filtered out.
+Use `setHideAgentic(true)` to exclude AI agent conversations from the list.
@@ -384,10 +410,9 @@ let limit: number = 30,
-
### Only Agentic Conversations
-This method allows you to fetch only agent conversations. When set to `true`, only conversations with AI agents will be returned in the list.
+Use `setOnlyAgentic(true)` to fetch only AI agent conversations.
@@ -415,16 +440,14 @@ let limit: number = 30,
-
-The `setHideAgentic()` and `setOnlyAgentic()` methods are mutually exclusive. You should only use one of them in a single request builder instance.
-
+`setHideAgentic()` and `setOnlyAgentic()` are mutually exclusive — use only one per request.
-Finally, once all the parameters are set to the builder class, you need to call the `build()` method to get the object of the `ConversationsRequest` class.
+When conversations are fetched successfully, the response includes only AI agent conversations. Agent users have `role: "@agentic"`.
-Once you have the object of the `ConversationsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Conversation` objects containing X number of users depending on the limit set.
+### Fetch Conversations
-A Maximum of only 50 Conversations can be fetched at once.
+Call `build()` to create the request, then `fetchNext()` to retrieve conversations. Maximum 50 per request.
@@ -467,30 +490,43 @@ conversationsRequest.fetchNext().then(
-The `Conversation` Object consists of the following fields:
-
-| Field | Information |
-| ------------------ | ----------------------------------------------------------------- |
-| conversationId | ID of the conversation. |
-| conversationType | Type of conversation. (user/group) |
-| lastMessage | Last message the conversation. |
-| conversationWith | User or Group object containing the details of the user or group. |
-| unreadMessageCount | Unread message count for the conversation. |
+The [`Conversation`](/sdk/reference/entities#conversation) object contains:
+
+| Field | Description |
+| --- | --- |
+| conversationId | ID of the conversation |
+| conversationType | Type of conversation (`user`/`group`) |
+| lastMessage | Last message in the conversation |
+| conversationWith | User or Group object |
+| unreadMessageCount | Unread message count |
+| unreadMentionsCount | Count of unread mentions |
+| lastReadMessageId | ID of the last read message |
+| latestMessageId | ID of the latest message |
+| tags | Tags associated with the conversation (when using `withTags`) |
+
+The `fetchNext()` method returns an array of [`Conversation`](/sdk/reference/entities#conversation) objects. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| conversationId | `getConversationId()` | `string` | Unique conversation ID |
+| conversationType | `getConversationType()` | `string` | Type of conversation (`"user"` or `"group"`) |
+| lastMessage | `getLastMessage()` | [`BaseMessage`](/sdk/reference/messages#basemessage) | The last message in the conversation |
+| conversationWith | `getConversationWith()` | [`User`](/sdk/reference/entities#user) \| [`Group`](/sdk/reference/entities#group) | The user or group this conversation is with |
+| unreadMessageCount | `getUnreadMessageCount()` | `number` | Number of unread messages |
+| unreadMentionsCount | `getUnreadMentionsCount()` | `number` | Count of unread mentions |
+| lastReadMessageId | `getLastReadMessageId()` | `string` | ID of the last read message |
+| latestMessageId | `getLatestMessageId()` | `string` | ID of the latest message |
+| tags | `getTags()` | `string[]` | Tags associated with the conversation (when using `withTags`) |
## Tag Conversation
-*In other words, as a logged-in user, how do I tag a conversation?*
+Use `tagConversation()` to add tags to a conversation.
-To tag a specific conversation, you can use the `tagConversation()` method. The `tagConversation()` method accepts three parameters.
-
-1. `conversationWith`: UID/GUID of the user/group whose conversation you want to fetch.
-
-2. `conversationType`: The `conversationType` variable can hold one of the below two values:
-
- 1. user - Only fetches user conversation.
- 2. group - Only fetches group conversations.
-
-3. `tags`: The `tags` variable will be a list of tags you want to add to a conversation.
+| Parameter | Description |
+| --- | --- |
+| `conversationWith` | UID or GUID of the user/group |
+| `conversationType` | `user` or `group` |
+| `tags` | Array of tags to add |
@@ -530,23 +566,19 @@ CometChat.tagConversation(conversationWith, conversationType, tags).then(
-
-The tags for conversations are one-way. This means that if user A tags a conversation with user B, that tag will be applied to that conversation only for user A.
-
+Conversation tags are one-way. If user A tags a conversation with user B, that tag only applies for user A.
-## Retrieve Single Conversation
-
-*In other words, as a logged-in user, how do I retrieve a specific conversation?*
+When the conversation is tagged successfully, the response returns a [`Conversation`](/sdk/reference/entities#conversation) object with the `tags` field.
-To fetch a specific conversation, you can use the `getConversation` method. The `getConversation` method accepts two parameters.
-
-1. `conversationWith`: UID/GUID of the user/group whose conversation you want to fetch.
+## Retrieve Single Conversation
-2. `conversationType`: The `conversationType` variable can hold one of the below two values:
+Use `getConversation()` to fetch a specific conversation.
- 1. user - Only fetches user conversation.
- 2. group - Only fetches group conversations.
+| Parameter | Description |
+| --- | --- |
+| `conversationWith` | UID or GUID of the user/group |
+| `conversationType` | `user` or `group` |
@@ -582,9 +614,11 @@ CometChat.getConversation(conversationWith, conversationType).then(
+When the conversation is fetched successfully, the response returns a single [`Conversation`](/sdk/reference/entities#conversation) object.
+
## Convert Messages to Conversations
-As per our [receive messages](/sdk/javascript/receive-message) guide, for real-time messages, you will always receive `Message` objects and not `Conversation` objects. Thus, you will need a mechanism to convert the Message object to the `Conversation` object. You can use the `getConversationFromMessage(BaseMessage message)` of the `CometChatHelper` class.
+Use `CometChatHelper.getConversationFromMessage()` to convert a received message into a [`Conversation`](/sdk/reference/entities#conversation) object. Useful for updating your Recent Chats list when receiving real-time messages.
@@ -618,7 +652,17 @@ CometChat.CometChatHelper.getConversationFromMessage(message).then(
+When converting a message to a conversation, `unreadMessageCount` and `tags` won't be available. Manage unread counts in your client-side code.
+
+---
-While converting the `Message` object to the `Conversation` object, the `unreadMessageCount` & `tags` will not be available in the `Conversation` object. The unread message count needs to be managed in your client-side code.
+## Next Steps
-
+
+
+ Remove conversations from the logged-in user's list
+
+
+ Show real-time typing status in conversations
+
+
diff --git a/sdk/javascript/retrieve-group-members.mdx b/sdk/javascript/retrieve-group-members.mdx
index 3e21b909d..cf916ddff 100644
--- a/sdk/javascript/retrieve-group-members.mdx
+++ b/sdk/javascript/retrieve-group-members.mdx
@@ -1,20 +1,35 @@
---
title: "Retrieve Group Members"
+sidebarTitle: "Retrieve Members"
+description: "Fetch and filter group members by scope, status, and search keyword using the CometChat JavaScript SDK with pagination support."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Fetch group members
+const request = new CometChat.GroupMembersRequestBuilder("GUID")
+ .setLimit(30).build();
+const members = await request.fetchNext();
+
+// Filter by scope
+const request = new CometChat.GroupMembersRequestBuilder("GUID")
+ .setLimit(30).setScopes(["admin", "moderator"]).build();
+
+// Search members
+const request = new CometChat.GroupMembersRequestBuilder("GUID")
+ .setLimit(30).setSearchKeyword("john").build();
+```
+
## Retrieve the List of Group Members
-In order to fetch the list of groups members for a group, you can use the `GroupMembersRequest` class. To use this class i.e to create an object of the GroupMembersRequest class, you need to use the `GroupMembersRequestBuilder` class. The `GroupMembersRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched.
-
-The `GroupMembersRequestBuilder` class allows you to set the below parameters:
-
-The GUID of the group for which the members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class.
+Use `GroupMembersRequestBuilder` to fetch members of a [Group](/sdk/reference/entities#group). The GUID must be specified in the constructor.
### Set Limit
-This method sets the limit i.e. the number of members that should be fetched in a single iteration.
+Sets the number of members to fetch per request.
@@ -43,7 +58,7 @@ let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMemb
### Set Search Keyword
-This method allows you to set the search string based on which the group members are to be fetched.
+Filters members by a search string.
@@ -76,7 +91,7 @@ let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMemb
### Set Scopes
-This method allows you to fetch group members based on multiple scopes.
+Filters members by one or more scopes (`admin`, `moderator`, `participant`).
@@ -109,12 +124,14 @@ let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMemb
### Set Status
-The status based on which the group members are to be fetched. The status parameter can contain one of the below two values:
+Filters members by online status:
-* CometChat.USER_STATUS.ONLINE - will return the list of only online group members.
-* CometChat.USER_STATUS.OFFLINE - will return the list of only offline group members.
+| Value | Description |
+|-------|-------------|
+| `CometChat.USER_STATUS.ONLINE` | Only online members |
+| `CometChat.USER_STATUS.OFFLINE` | Only offline members |
-If this parameter is not set, will return all the group members regardless of their status.
+If not set, returns all members regardless of status.
@@ -143,9 +160,7 @@ let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMemb
-Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupMembersRequest` class.
-
-Once you have the object of the `GroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of members where n is the limit set in the builder class.
+Once configured, call `build()` to create the request, then `fetchNext()` to retrieve members.
@@ -187,3 +202,26 @@ groupMembersRequest.fetchNext().then(
+
+The `fetchNext()` method returns an array of [`GroupMember`](/sdk/reference/entities#groupmember) objects. `GroupMember` extends `User` and adds group-specific fields. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the member |
+| scope | `getScope()` | `string` | Scope in the group (`"admin"`, `"moderator"`, or `"participant"`) |
+| joinedAt | `getJoinedAt()` | `number` | Timestamp when the member joined the group |
+| guid | `getGuid()` | `string` | GUID of the group this member belongs to |
+
+---
+
+## Next Steps
+
+
+
+ Add users to a group programmatically
+
+
+ Remove or ban members from a group
+
+
diff --git a/sdk/javascript/retrieve-groups.mdx b/sdk/javascript/retrieve-groups.mdx
index 92a074c0d..d5bbce763 100644
--- a/sdk/javascript/retrieve-groups.mdx
+++ b/sdk/javascript/retrieve-groups.mdx
@@ -1,20 +1,37 @@
---
title: "Retrieve Groups"
+sidebarTitle: "Retrieve Groups"
+description: "Fetch, filter, and search groups using the CometChat JavaScript SDK. Includes pagination, tag-based filtering, joined-only groups, and online member counts."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Fetch groups list
+const request = new CometChat.GroupsRequestBuilder()
+ .setLimit(30).build();
+const groups = await request.fetchNext();
-## Retrieve List of Groups
+// Get specific group details
+const group = await CometChat.getGroup("GUID");
-*In other words, as a logged-in user, how do I retrieve the list of groups I've joined and groups that are available?*
+// Fetch only joined groups
+const request = new CometChat.GroupsRequestBuilder()
+ .setLimit(30).joinedOnly(true).build();
+
+// Get online member count
+const count = await CometChat.getOnlineGroupMemberCount(["GUID"]);
+```
+
-In order to fetch the list of groups, you can use the `GroupsRequest` class. To use this class i.e to create an object of the `GroupsRequest` class, you need to use the `GroupsRequestBuilder` class. The `GroupsRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched.
+## Retrieve List of Groups
-The `GroupsRequestBuilder` class allows you to set the below parameters:
+Use `GroupsRequestBuilder` to fetch groups with filtering, searching, and pagination.
### Set Limit
-This method sets the limit i.e. the number of groups that should be fetched in a single iteration.
+Sets the number of groups to fetch per request.
@@ -41,7 +58,7 @@ let groupsRequest = new CometChat.GroupsRequestBuilder()
### Set Search Keyword
-This method allows you to set the search string based on which the groups are to be fetched.
+Filters groups by a search string.
@@ -72,7 +89,7 @@ let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder(
### Joined Only
-This method when used, will ask the SDK to only return the groups that the user has joined or is a part of.
+When `true`, returns only groups the logged-in user has joined.
@@ -101,7 +118,7 @@ let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder(
### Set Tags
-This method accepts a list of tags based on which the list of groups is to be fetched. The list fetched will only contain the groups that have been tagged with the specified tags.
+Filters groups by specified tags.
@@ -132,7 +149,7 @@ let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder(
### With Tags
-This property when set to true will fetch tags data along with the list of groups.
+When `true`, includes tag data in the returned group objects.
@@ -159,11 +176,11 @@ let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder(
-Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupsRequest` class.
-
-Once you have the object of the `GroupsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Group` objects containing n number of groups where n is the limit set in the builder class.
+After configuring the builder, call `build()` to get the `GroupsRequest` object, then call `fetchNext()` to retrieve groups.
-The list of groups fetched will only have the public and password type groups. The private groups will only be available if the user is a member of the group.
+
+The list only includes public and password-protected groups. Private groups appear only if the user is a member.
+
@@ -204,16 +221,25 @@ groupsRequest.fetchNext().then(
-## Retrieve Particular Group Details
+The `fetchNext()` method returns an array of [`Group`](/sdk/reference/entities#group) objects. Access the response data using getter methods:
-*In other words, as a logged-in user, how do I retrieve information for a specific group?*
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| guid | `getGuid()` | `string` | Unique group ID |
+| name | `getName()` | `string` | Display name of the group |
+| type | `getType()` | `string` | Group type (`"public"`, `"private"`, or `"password"`) |
+| membersCount | `getMembersCount()` | `number` | Total number of members in the group |
+| owner | `getOwner()` | `string` | UID of the group owner |
+| hasJoined | `getHasJoined()` | `boolean` | Whether the logged-in user has joined this group |
-To get the information of a group, you can use the `getGroup()` method.
+## Retrieve Particular Group Details
+
+Use `getGroup()` to fetch a specific group's details by GUID.
```javascript
-var GUID = "GUID";
+const GUID = "GUID";
CometChat.getGroup(GUID).then(
group => {
console.log("Group details fetched successfully:", group);
@@ -227,7 +253,7 @@ group => {
```typescript
-var GUID: string = "GUID";
+const GUID: string = "GUID";
CometChat.getGroup(GUID).then(
(group: CometChat.Group) => {
console.log("Group details fetched successfully:", group);
@@ -241,15 +267,26 @@ CometChat.getGroup(GUID).then(
-| Parameter | Description |
-| --------- | ------------------------------------------------------------ |
-| `GUID` | The GUID of the group for whom the details are to be fetched |
+| Parameter | Description |
+| --------- | ----------- |
+| `GUID` | The GUID of the group to fetch |
+
+Returns a [`Group`](/sdk/reference/entities#group) object with the group's details.
-It returns `Group` object containing the details of the group.
+The method returns a [`Group`](/sdk/reference/entities#group) object. Access the response data using getter methods:
-## Get online group member count
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| guid | `getGuid()` | `string` | Unique group ID |
+| name | `getName()` | `string` | Display name of the group |
+| type | `getType()` | `string` | Group type (`"public"`, `"private"`, or `"password"`) |
+| membersCount | `getMembersCount()` | `number` | Total number of members in the group |
+| owner | `getOwner()` | `string` | UID of the group owner |
+| hasJoined | `getHasJoined()` | `boolean` | Whether the logged-in user has joined this group |
-To get the total count of online users in particular groups, you can use the `getOnlineGroupMemberCount()` method.
+## Get Online Group Member Count
+
+Use `getOnlineGroupMemberCount()` to get the number of online members in specified groups.
@@ -282,4 +319,17 @@ CometChat.getOnlineGroupMemberCount(guids).then(
-This method returns a JSON Object with the GUID as the key and the online member count for that group as the value.
+Returns an object with GUIDs as keys and online member counts as values.
+
+---
+
+## Next Steps
+
+
+
+ Create public, private, or password-protected groups
+
+
+ Fetch and filter members of a specific group
+
+
diff --git a/sdk/javascript/retrieve-users.mdx b/sdk/javascript/retrieve-users.mdx
index 943df6404..e7f27204a 100644
--- a/sdk/javascript/retrieve-users.mdx
+++ b/sdk/javascript/retrieve-users.mdx
@@ -1,12 +1,32 @@
---
title: "Retrieve Users"
+sidebarTitle: "Retrieve Users"
+description: "Fetch, filter, search, and sort users using the CometChat JavaScript SDK. Includes pagination, role-based filtering, tag support, and online user counts."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Fetch users list
+const request = new CometChat.UsersRequestBuilder()
+ .setLimit(30).build();
+const users = await request.fetchNext();
+
+// Get specific user details
+const user = await CometChat.getUser("UID");
+
+// Get logged-in user
+const me = await CometChat.getLoggedinUser();
+
+// Get online user count
+const count = await CometChat.getOnlineUserCount();
+```
+
## Retrieve Logged In User Details
-You can get the details of the logged-in user using the `getLoggedInUser()` method. This method can also be used to check if the user is logged in or not. If the method returns `Promise` with reject callback, it indicates that the user is not logged in and you need to log the user into CometChat SDK.
+Use `getLoggedInUser()` to get the current user's details. This method also verifies if a user is logged in — a rejected promise indicates no user is logged in.
@@ -37,17 +57,26 @@ CometChat.getLoggedinUser().then(
-This method will return a `User` object containing all the information related to the logged-in user.
+This method returns a [`User`](/sdk/reference/entities#user) object with the logged-in user's information.
-## Retrieve List of Users
+The method returns a [`User`](/sdk/reference/entities#user) object. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| avatar | `getAvatar()` | `string` | URL of the user's avatar image |
+| status | `getStatus()` | `string` | Online status of the user |
+| lastActiveAt | `getLastActiveAt()` | `number` | Timestamp when the user was last active |
+| role | `getRole()` | `string` | Role assigned to the user |
-In order to fetch the list of users, you can use the `UsersRequest` class. To use this class i.e to create an object of the `UsersRequest` class, you need to use the `UsersRequestBuilder` class. The `UsersRequestBuilder` class allows you to set the parameters based on which the users are to be fetched.
+## Retrieve List of Users
-The `UsersRequestBuilder` class allows you to set the below parameters:
+Use `UsersRequestBuilder` to fetch users with filtering, searching, and pagination.
### Set Limit
-This method sets the limit i.e. the number of users that should be fetched in a single iteration.
+Sets the number of users to fetch per request.
@@ -74,7 +103,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Set Search Keyword
-This method allows you to set the search string based on which the users are to be fetched.
+Filters users by a search string.
@@ -105,7 +134,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Search In
-This method allows you to define in which user property should the searchKeyword be searched. This method only works in combination with `setSearchKeyword()`. By default the keyword is searched in both UID & Name.
+Specifies which user properties to search. Works with `setSearchKeyword()`. By default, searches both UID and name.
@@ -140,12 +169,12 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Set Status
-The status based on which the users are to be fetched. The status parameter can contain one of the below two values:
+Filters users by online status:
-* CometChat.USER\_STATUS.ONLINE - will return the list of only online users.
-* CometChat.USER\_STATUS.OFFLINE - will return the list of only offline users.
+- `CometChat.USER_STATUS.ONLINE` — Only online users
+- `CometChat.USER_STATUS.OFFLINE` — Only offline users
-If this parameter is not set, will return all the available users.
+If not set, returns all users.
@@ -174,7 +203,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Hide Blocked Users
-This method is used to determine if the blocked users should be returned as a part of the user list. If set to true, the user list will not contain the users blocked by the logged in user.
+When `true`, excludes users blocked by the logged-in user from the results.
@@ -203,7 +232,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Set Roles
-This method allows you to fetch the users based on multiple roles.
+Filters users by specified roles.
@@ -234,7 +263,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Friends Only
-This property when set to true will return only the friends of the logged-in user.
+When `true`, returns only friends of the logged-in user.
@@ -263,7 +292,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Set Tags
-This method accepts a list of tags based on which the list of users is to be fetched. The list fetched will only contain the users that have been tagged with the specified tags.
+Filters users by specified tags.
@@ -294,7 +323,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### With Tags
-This property when set to true will fetch tags data along with the list of users.
+When `true`, includes tag data in the returned user objects.
@@ -323,7 +352,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Set UIDs
-This method accepts a list of UIDs based on which the list of users is fetched. A maximum of `25` users can be fetched.
+Fetches specific users by their UIDs. Maximum 25 users per request.
@@ -354,7 +383,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Sort By
-This method allows you to sort the User List by a specific property of User. By default the User List is sorted by `status => name => UID` . If `name` is pass to the `sortBy()` method the user list will be sorted by `name => UID`.
+Sorts the user list by a specific property. Default sort order: `status → name → UID`. Pass `"name"` to sort by `name → UID`.
@@ -386,7 +415,7 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
### Sort By Order
-This method allows you to sort the User List in a specific order. By default the user list is sorted in ascending order.
+Sets the sort order. Default is ascending (`"asc"`). Use `"desc"` for descending.
@@ -415,15 +444,13 @@ let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder()
-Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the UsersRequest class.
-
-Once you have the object of the UsersRequest class, you need to call the fetchNext() method. Calling this method will return a list of User objects containing n number of users where n is the limit set in the builder class.
+After configuring the builder, call `build()` to get the `UsersRequest` object, then call `fetchNext()` to retrieve users.
-
+
```javascript
-var limit = 30;
-var usersRequest = new CometChat.UsersRequestBuilder()
+const limit = 30;
+const usersRequest = new CometChat.UsersRequestBuilder()
.setLimit(limit)
.build();
@@ -458,9 +485,20 @@ usersRequest.fetchNext().then(
+The `fetchNext()` method returns an array of [`User`](/sdk/reference/entities#user) objects. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| avatar | `getAvatar()` | `string` | URL of the user's avatar image |
+| status | `getStatus()` | `string` | Online status of the user |
+| lastActiveAt | `getLastActiveAt()` | `number` | Timestamp when the user was last active |
+| role | `getRole()` | `string` | Role assigned to the user |
+
## Retrieve Particular User Details
-To get the information of a user, you can use the `getUser()` method.
+Use `getUser()` to fetch a specific user's details by UID.
@@ -493,17 +531,26 @@ CometChat.getUser(UID).then(
-The `getUser()` method takes the following parameters:
+| Parameter | Description |
+| --------- | ----------- |
+| UID | The UID of the user to fetch |
+
+Returns a [`User`](/sdk/reference/entities#user) object with the user's details.
-| Parameter | Description |
-| --------- | ---------------------------------------------------------- |
-| UID | The UID of the user for whom the details are to be fetched |
+The method returns a [`User`](/sdk/reference/entities#user) object. Access the response data using getter methods:
-It returns the `User` object containing the details of the user.
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| avatar | `getAvatar()` | `string` | URL of the user's avatar image |
+| status | `getStatus()` | `string` | Online status of the user |
+| lastActiveAt | `getLastActiveAt()` | `number` | Timestamp when the user was last active |
+| role | `getRole()` | `string` | Role assigned to the user |
-## Get online user count
+## Get Online User Count
-To get the total count of online users for your app, you can use the `getOnlineUserCount()` method.
+Use `getOnlineUserCount()` to get the total number of online users in your app.
@@ -534,4 +581,17 @@ CometChat.getOnlineUserCount().then(
-This method returns the total online user count for your app.
+Returns the total online user count as a number.
+
+---
+
+## Next Steps
+
+
+
+ Track and subscribe to user online/offline status
+
+
+ Block and unblock users from your application
+
+
diff --git a/sdk/javascript/send-message.mdx b/sdk/javascript/send-message.mdx
index ae9f8e125..0d8458111 100644
--- a/sdk/javascript/send-message.mdx
+++ b/sdk/javascript/send-message.mdx
@@ -1,81 +1,34 @@
---
-title: "Send A Message"
+title: "Send Messages"
+sidebarTitle: "Send Messages"
+description: "Send text, media, and custom messages to users and groups using the CometChat JavaScript SDK."
---
+
+| Field | Value |
+| --- | --- |
+| Key Classes | [`TextMessage`](/sdk/reference/messages#textmessage), [`MediaMessage`](/sdk/reference/messages#mediamessage), [`CustomMessage`](/sdk/reference/messages#custommessage) |
+| Key Methods | `sendMessage()`, `sendMediaMessage()`, `sendCustomMessage()` |
+| Receiver Types | `CometChat.RECEIVER_TYPE.USER`, `CometChat.RECEIVER_TYPE.GROUP` |
+| Message Types | `TEXT`, `IMAGE`, `VIDEO`, `AUDIO`, `FILE`, `CUSTOM` |
+| Prerequisites | SDK initialized, user logged in |
-Using CometChat, you can send three types of messages:
+
-1. [Text Message](/sdk/javascript/send-message#text-message) is the most common and standard message type.
-2. [Media Message](/sdk/javascript/send-message#media-message) for sending photos, videos and files.
-3. [Custom Message](/sdk/javascript/send-message#custom-message), for sending completely custom data using JSON structures.
-4. [Interactive Messages](/sdk/javascript/interactive-messages), for sending end-user interactive messages of type form, card and custom Interactive
+CometChat supports three types of messages:
-You can also send metadata along with a text, media or custom message. Think, for example, if you'd want to share the user's location with every message, you can use the metadata field
+| Type | Method | Use Case |
+| --- | --- | --- |
+| [Text](#text-message) | `sendMessage()` | Plain text messages |
+| [Media](#media-message) | `sendMediaMessage()` | Images, videos, audio, files |
+| [Custom](#custom-message) | `sendCustomMessage()` | Location, polls, or any JSON data |
-## Text Message
-
-*In other words, as a sender, how do I send a text message?*
-
-To send a text message to a single user or group, you need to use the `sendMessage()` method and pass a `TextMessage` object to it.
-
-### Add Metadata
-
-To send custom data along with a text message, you can use the `setMetadata` method and pass a `JSON Object` to it.
-
-
-
-```javascript
-let metadata = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-
-textMessage.setMetadata(metadata);
-```
-
-
-
-
-```typescript
-let metadata: Object = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-
-textMessage.setMetadata(metadata);
-```
-
-
-
-
+You can also send [Interactive Messages](/sdk/javascript/interactive-messages) for forms, cards, and custom UI elements.
-### Add Tags
-
-To add a tag to a message you can use the `setTags()` method of the TextMessage Class. The `setTags()` method accepts a list of tags.
-
-
-
-```javascript
-let tags = ["starredMessage"];
-
-textMessage.setTags(tags);
-```
-
-
-
-
-```typescript
-let tags: Array = ["starredMessage"];
-
-textMessage.setTags(tags);
-```
-
-
-
-
+## Text Message
-Once the text message object is ready, you need to use the `sendMessage()` method to send the text message to the recipient.
+Send a text message using `CometChat.sendMessage()` with a [`TextMessage`](/sdk/reference/messages#textmessage) object.
@@ -98,9 +51,7 @@ CometChat.sendMessage(textMessage).then(
}
);
```
-
-
```javascript
let receiverID = "GUID";
@@ -121,9 +72,7 @@ CometChat.sendMessage(textMessage).then(
}
);
```
-
-
```typescript
let receiverID: string = "UID",
@@ -144,9 +93,7 @@ CometChat.sendMessage(textMessage).then(
}
);
```
-
-
```typescript
let receiverID: string = "GUID",
@@ -167,162 +114,53 @@ CometChat.sendMessage(textMessage).then(
}
);
```
-
-
-
-
-
-### Set Quoted Message Id
-
-To set a quoted message ID for a message, use the `setQuotedMessageId()` method of the TextMessage class. This method accepts the ID of the message to be quoted.
-
-
-
-```javascript
-textMessage.setQuotedMessageId(10);
-```
-
-
-
-
-```typescript
-textMessage.setQuotedMessageId(10);
-```
-
-
-
-
-
-Once the text message object is ready, you need to use the `sendMessage()` method to send the text message to the recipient.
-
-
-
-```javascript
-let receiverID = "UID";
-let messageText = "Hello world!";
-let receiverType = CometChat.RECEIVER_TYPE.USER;
-let textMessage = new CometChat.TextMessage(
- receiverID,
- messageText,
- receiverType
-);
-
-CometChat.sendMessage(textMessage).then(
- (message) => {
- console.log("Message sent successfully:", message);
- },
- (error) => {
- console.log("Message sending failed with error:", error);
- }
-);
-```
-
-
-
+
```javascript
-let receiverID = "GUID";
-let messageText = "Hello world!";
-let receiverType = CometChat.RECEIVER_TYPE.GROUP;
-let textMessage = new CometChat.TextMessage(
- receiverID,
- messageText,
- receiverType
-);
-
-CometChat.sendMessage(textMessage).then(
- (message) => {
- console.log("Message sent successfully:", message);
- },
- (error) => {
- console.log("Message sending failed with error:", error);
- }
-);
-```
-
-
-
-
-```typescript
-let receiverID: string = "UID",
- messageText: string = "Hello world!",
- receiverType: string = CometChat.RECEIVER_TYPE.USER,
- textMessage: CometChat.TextMessage = new CometChat.TextMessage(
- receiverID,
- messageText,
- receiverType
- );
-
-CometChat.sendMessage(textMessage).then(
- (message: CometChat.TextMessage) => {
- console.log("Message sent successfully:", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("Message sending failed with error:", error);
- }
-);
-```
-
-
-
-
-```typescript
-let receiverID: string = "GUID",
- messageText: string = "Hello world!",
- receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
- textMessage: CometChat.TextMessage = new CometChat.TextMessage(
+try {
+ const receiverID = "UID";
+ const messageText = "Hello world!";
+ const receiverType = CometChat.RECEIVER_TYPE.USER;
+ const textMessage = new CometChat.TextMessage(
receiverID,
messageText,
receiverType
);
-CometChat.sendMessage(textMessage).then(
- (message: CometChat.TextMessage) => {
- console.log("Message sent successfully:", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("Message sending failed with error:", error);
- }
-);
+ const message = await CometChat.sendMessage(textMessage);
+ console.log("Message sent successfully:", message);
+} catch (error) {
+ console.log("Message sending failed with error:", error);
+}
```
-
-
-The `TextMessage` class constructor takes the following parameters:
-
-| Parameter | Description | |
-| ---------------- | -------------------------------------------------------------------------------------------- | -------- |
-| **receiverID** | `UID` of the user or `GUID` of the group receiving the message | Required |
-| **messageText** | The text message | Required |
-| **receiverType** | The type of the receiver - `CometChat.RECEIVER_TYPE.USER` or `CometChat.RECEIVER_TYPE.GROUP` | Required |
-
-When a text message is sent successfully, the response will include a `TextMessage` object which includes all information related to the sent message.
-
-## Media Message
+The [`TextMessage`](/sdk/reference/messages#textmessage) class constructor takes the following parameters:
-*In other words, as a sender, how do I send a media message like photos, videos & files?*
+| Parameter | Description | Required |
+| --- | --- | --- |
+| `receiverID` | UID of the user or GUID of the group receiving the message | Yes |
+| `messageText` | The text message content | Yes |
+| `receiverType` | `CometChat.RECEIVER_TYPE.USER` or `CometChat.RECEIVER_TYPE.GROUP` | Yes |
-To send a media message to any user or group, you need to use the `sendMediaMessage()` method and pass a `MediaMessage` object to it.
+On success, `sendMessage()` returns a [TextMessage](/sdk/reference/messages#textmessage) object.
### Add Metadata
-To send custom data along with a media message, you can use the `setMetadata` method and pass a `JSON Object` to it.
+Attach custom JSON data to the message:
-
+
```javascript
let metadata = {
latitude: "50.6192171633316",
longitude: "-72.68182268750002",
};
-mediaMessage.setMetadata(metadata);
+textMessage.setMetadata(metadata);
```
-
-
```typescript
let metadata: Object = {
@@ -330,99 +168,76 @@ let metadata: Object = {
longitude: "-72.68182268750002",
};
-mediaMessage.setMetadata(metadata);
+textMessage.setMetadata(metadata);
```
-
-
-### Add Caption(Text along with Media Message)
+### Add Tags
-To send a caption with a media message, you can use the `setCaption` method and pass text to it.
+Tag messages for easy filtering later:
-
+
```javascript
-let caption = "Random Caption";
+let tags = ["starredMessage"];
-mediaMessage.setCaption(caption);
+textMessage.setTags(tags);
```
-
-
```typescript
-let caption: string = "Random Caption";
+let tags: Array = ["starredMessage"];
-mediaMessage.setCaption(caption);
+textMessage.setTags(tags);
```
-
-
-### Add Tags
+### Quote a Message
-To add a tag to a message you can use the `setTags()` method of the MediaMessage Class. The `setTags()` method accepts a list of tags.
+Reply to a specific message by setting its ID:
-
+
```javascript
-let tags = ["starredMessage"];
-
-mediaMessage.setTags(tags);
+textMessage.setQuotedMessageId(10);
```
-
-
```typescript
-let tags: Array = ["starredMessage"];
-
-mediaMessage.setTags(tags);
+textMessage.setQuotedMessageId(10);
```
-
-
-There are 2 ways you can send Media Messages using the CometChat SDK:
+## Media Message
-1. **By providing the File:** You can directly share the file object while creating an object of the MediaMessage class. When the media message is sent using the `sendMediaMessage()` method, this file is then uploaded to CometChat servers and the URL of the file is sent in the success response of the `sendMediaMessage()` function.
+Send images, videos, audio, or files using `CometChat.sendMediaMessage()`.
-Getting file Object:
+There are two ways to send media messages:
+1. **Upload a file** — Pass a file object and CometChat uploads it automatically
+2. **Send a URL** — Provide a URL to media hosted on your server or cloud storage
-
-
-```html
-
-
-
-
-
-
-```
+### Upload a File
-
+Get the file from an input element and pass it to [`MediaMessage`](/sdk/reference/messages#mediamessage):
-
+```html
+
+```
```javascript
let receiverID = "UID";
-let messageType = CometChat.MESSAGE_TYPE.FILE;
+let messageType = CometChat.MESSAGE_TYPE.IMAGE;
let receiverType = CometChat.RECEIVER_TYPE.USER;
+let file = document.getElementById("img_file").files[0];
+
let mediaMessage = new CometChat.MediaMessage(
receiverID,
- "INPUT FILE OBJECT",
+ file,
messageType,
receiverType
);
@@ -436,17 +251,17 @@ CometChat.sendMediaMessage(mediaMessage).then(
}
);
```
-
-
```javascript
let receiverID = "GUID";
-let messageType = CometChat.MESSAGE_TYPE.FILE;
+let messageType = CometChat.MESSAGE_TYPE.IMAGE;
let receiverType = CometChat.RECEIVER_TYPE.GROUP;
+let file = document.getElementById("img_file").files[0];
+
let mediaMessage = new CometChat.MediaMessage(
receiverID,
- `INPUT FILE OBJECT`,
+ file,
messageType,
receiverType
);
@@ -460,20 +275,20 @@ CometChat.sendMediaMessage(mediaMessage).then(
}
);
```
-
-
```typescript
let receiverID: string = "UID",
- messageType: string = CometChat.MESSAGE_TYPE.FILE,
+ messageType: string = CometChat.MESSAGE_TYPE.IMAGE,
receiverType: string = CometChat.RECEIVER_TYPE.USER,
- mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
- receiverID,
- "INPUT FILE OBJECT",
- messageType,
- receiverType
- );
+ file: File = (document.getElementById("img_file") as HTMLInputElement).files![0];
+
+let mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
+ receiverID,
+ file,
+ messageType,
+ receiverType
+);
CometChat.sendMediaMessage(mediaMessage).then(
(message: CometChat.MediaMessage) => {
@@ -484,20 +299,20 @@ CometChat.sendMediaMessage(mediaMessage).then(
}
);
```
-
-
```typescript
let receiverID: string = "GUID",
- messageType: string = CometChat.MESSAGE_TYPE.FILE,
+ messageType: string = CometChat.MESSAGE_TYPE.IMAGE,
receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
- mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
- receiverID,
- "INPUT FILE OBJECT",
- messageType,
- receiverType
- );
+ file: File = (document.getElementById("img_file") as HTMLInputElement).files![0];
+
+let mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
+ receiverID,
+ file,
+ messageType,
+ receiverType
+);
CometChat.sendMediaMessage(mediaMessage).then(
(message: CometChat.MediaMessage) => {
@@ -508,173 +323,17 @@ CometChat.sendMediaMessage(mediaMessage).then(
}
);
```
-
-
-### Set Quoted Message Id
+### Send a URL
-To set a quoted message ID for a message, use the `setQuotedMessageId()` method of the MediaMessage class. This method accepts the ID of the message to be quoted.
+Send media hosted on your server or cloud storage using the [`Attachment`](/sdk/reference/auxiliary#attachment) class:
-
-```javascript
-mediaMessage.setQuotedMessageId(10);
-```
-
-
-
-
-```typescript
-mediaMessage.setQuotedMessageId(10);
-```
-
-
-
-
-
-There are 2 ways you can send Media Messages using the CometChat SDK:
-
-1. **By providing the File:** You can directly share the file object while creating an object of the MediaMessage class. When the media message is sent using the `sendMediaMessage()` method, this file is then uploaded to CometChat servers and the URL of the file is sent in the success response of the `sendMediaMessage()` function.
-
-Getting file Object:
-
-
-
-```html
-
-
-
-
-
-
-```
-
-
-
-
-
-
-
+
```javascript
let receiverID = "UID";
-let messageType = CometChat.MESSAGE_TYPE.FILE;
-let receiverType = CometChat.RECEIVER_TYPE.USER;
-let mediaMessage = new CometChat.MediaMessage(
- receiverID,
- "INPUT FILE OBJECT",
- messageType,
- receiverType
-);
-
-CometChat.sendMediaMessage(mediaMessage).then(
- (message) => {
- console.log("Media message sent successfully", message);
- },
- (error) => {
- console.log("Media message sending failed with error", error);
- }
-);
-```
-
-
-
-
-```javascript
-let receiverID = "GUID";
-let messageType = CometChat.MESSAGE_TYPE.FILE;
-let receiverType = CometChat.RECEIVER_TYPE.GROUP;
-let mediaMessage = new CometChat.MediaMessage(
- receiverID,
- `INPUT FILE OBJECT`,
- messageType,
- receiverType
-);
-
-CometChat.sendMediaMessage(mediaMessage).then(
- (message) => {
- console.log("Media message sent successfully", message);
- },
- (error) => {
- console.log("Media message sending failed with error", error);
- }
-);
-```
-
-
-
-
-```typescript
-let receiverID: string = "UID",
- messageType: string = CometChat.MESSAGE_TYPE.FILE,
- receiverType: string = CometChat.RECEIVER_TYPE.USER,
- mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
- receiverID,
- "INPUT FILE OBJECT",
- messageType,
- receiverType
- );
-
-CometChat.sendMediaMessage(mediaMessage).then(
- (message: CometChat.MediaMessage) => {
- console.log("Media message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("Media message sending failed with error", error);
- }
-);
-```
-
-
-
-
-```typescript
-let receiverID: string = "GUID",
- messageType: string = CometChat.MESSAGE_TYPE.FILE,
- receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
- mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
- receiverID,
- "INPUT FILE OBJECT",
- messageType,
- receiverType
- );
-
-CometChat.sendMediaMessage(mediaMessage).then(
- (message: CometChat.MediaMessage) => {
- console.log("Media message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("Media message sending failed with error", error);
- }
-);
-```
-
-
-
-
-
-The `MediaMessage` class constructor takes the following parameters:
-
-| Parameter | Description | |
-| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
-| **receiverId** | The `UID` or `GUID` of the recipient. | Required |
-| **file** | The file object to be sent | Required |
-| **messageType** | The type of the message that needs to be sent which in this case can be: 1.`CometChat.MESSAGE_TYPE.IMAGE` 2.`CometChat.MESSAGE_TYPE.VIDEO` 3.`CometChat.MESSAGE_TYPE.AUDIO` 4.`CometChat.MESSAGE_TYPE.FILE` | Required |
-| **receiverType** | The type of the receiver to whom the message is to be sent. `1. CometChat.RECEIVER_TYPE.USER` `2. CometChat.RECEIVER_TYPE.GROUP` | Required |
-
-2. **By providing the URL of the File:** The second way to send media messages using the CometChat SDK is to provide the SDK with the URL of any file that is hosted on your servers or any cloud storage. To achieve this you will have to make use of the Attachment class. For more information, you can refer to the below code snippet:
-
-
-
-```javascript
-let receiverID = "cometchat-uid-2";
let messageType = CometChat.MESSAGE_TYPE.IMAGE;
let receiverType = CometChat.RECEIVER_TYPE.USER;
let mediaMessage = new CometChat.MediaMessage(
@@ -692,24 +351,21 @@ let file = {
};
let attachment = new CometChat.Attachment(file);
-
mediaMessage.setAttachment(attachment);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage) => {
- console.log("message", mediaMessage);
+ (message) => {
+ console.log("Media message sent successfully", message);
},
(error) => {
- console.log("error in sending message", error);
+ console.log("Media message sending failed with error", error);
}
);
```
-
-
```javascript
-let receiverID = "cometchat-guid-1";
+let receiverID = "GUID";
let messageType = CometChat.MESSAGE_TYPE.IMAGE;
let receiverType = CometChat.RECEIVER_TYPE.GROUP;
let mediaMessage = new CometChat.MediaMessage(
@@ -727,24 +383,21 @@ let file = {
};
let attachment = new CometChat.Attachment(file);
-
mediaMessage.setAttachment(attachment);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage) => {
- console.log("message", mediaMessage);
+ (message) => {
+ console.log("Media message sent successfully", message);
},
(error) => {
- console.log("error in sending message", error);
+ console.log("Media message sending failed with error", error);
}
);
```
-
-
```typescript
-let receiverID: string = "cometchat-uid-2",
+let receiverID: string = "UID",
messageType: string = CometChat.MESSAGE_TYPE.IMAGE,
receiverType: string = CometChat.RECEIVER_TYPE.USER,
mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
@@ -762,24 +415,21 @@ let file: Object = {
};
let attachment: CometChat.Attachment = new CometChat.Attachment(file);
-
mediaMessage.setAttachment(attachment);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage: CometChat.MediaMessage) => {
- console.log("message", mediaMessage);
+ (message: CometChat.MediaMessage) => {
+ console.log("Media message sent successfully", message);
},
(error: CometChat.CometChatException) => {
- console.log("error in sending message", error);
+ console.log("Media message sending failed with error", error);
}
);
```
-
-
```typescript
-let receiverID: string = "cometchat-guid-1",
+let receiverID: string = "GUID",
messageType: string = CometChat.MESSAGE_TYPE.IMAGE,
receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
@@ -797,60 +447,72 @@ let file: Object = {
};
let attachment: CometChat.Attachment = new CometChat.Attachment(file);
-
mediaMessage.setAttachment(attachment);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage: CometChat.MediaMessage) => {
- console.log("message", mediaMessage);
+ (message: CometChat.MediaMessage) => {
+ console.log("Media message sent successfully", message);
},
(error: CometChat.CometChatException) => {
- console.log("error in sending message", error);
+ console.log("Media message sending failed with error", error);
}
);
```
-
-
-When a media message is sent successfully, the response will include a `MediaMessage` object which includes all information related to the sent message.
+The [`MediaMessage`](/sdk/reference/messages#mediamessage) class constructor takes the following parameters:
-## Multiple Attachments in a Media Message
+| Parameter | Description | Required |
+| --- | --- | --- |
+| `receiverID` | UID of the user or GUID of the group | Yes |
+| `file` | File object to upload, or empty string if using URL | Yes |
+| `messageType` | `CometChat.MESSAGE_TYPE.IMAGE`, `VIDEO`, `AUDIO`, or `FILE` | Yes |
+| `receiverType` | `CometChat.RECEIVER_TYPE.USER` or `GROUP` | Yes |
-Starting version 3.0.9 & above the SDK supports sending multiple attachments in a single media message. As in the case of a single attachment in a media message, there are two ways you can send Media Messages using the CometChat SDK:
+On success, `sendMediaMessage()` returns a [MediaMessage](/sdk/reference/messages#mediamessage) object.
-1. **By providing an array of files:** You can now share an array of files while creating an object of the MediaMessage class. When the media message is sent using the `sendMediaMessage()` method, the files are uploaded to the CometChat servers & the URL of the files is sent in the success response of the `sendMediaMessage()` method.
+### Add Caption
-Getting files:
+Add text along with the media:
-
-```html
-
-
-
-
-
-
+
+```javascript
+mediaMessage.setCaption("Check out this photo!");
+```
+
+
+```typescript
+mediaMessage.setCaption("Check out this photo!");
```
-
-
+### Add Metadata and Tags
+
+Same as text messages:
+
+```javascript
+mediaMessage.setMetadata({ location: "Paris" });
+mediaMessage.setTags(["vacation"]);
+mediaMessage.setQuotedMessageId(10);
+```
+
+## Multiple Attachments
+
+Send multiple files in a single media message.
+
+### Upload Multiple Files
+
```javascript
let receiverID = "UID";
let messageType = CometChat.MESSAGE_TYPE.FILE;
let receiverType = CometChat.RECEIVER_TYPE.USER;
+let files = document.getElementById("img_file").files; // FileList
+
let mediaMessage = new CometChat.MediaMessage(
receiverID,
files,
@@ -867,39 +529,39 @@ CometChat.sendMediaMessage(mediaMessage).then(
}
);
```
-
+
+```javascript
+let receiverID = "GUID";
+let messageType = CometChat.MESSAGE_TYPE.FILE;
+let receiverType = CometChat.RECEIVER_TYPE.GROUP;
+let files = document.getElementById("img_file").files;
-
-```typescript
-let receiverID: string = "UID",
- messageType: string = CometChat.MESSAGE_TYPE.FILE,
- receiverType: string = CometChat.RECEIVER_TYPE.USER,
- mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
- receiverID,
- files,
- messageType,
- receiverType
- );
+let mediaMessage = new CometChat.MediaMessage(
+ receiverID,
+ files,
+ messageType,
+ receiverType
+);
CometChat.sendMediaMessage(mediaMessage).then(
- (message: CometChat.MediaMessage) => {
+ (message) => {
console.log("Media message sent successfully", message);
},
- (error: CometChat.CometChatException) => {
+ (error) => {
console.log("Media message sending failed with error", error);
}
);
```
-
+
+```typescript
+let receiverID: string = "UID",
+ messageType: string = CometChat.MESSAGE_TYPE.FILE,
+ receiverType: string = CometChat.RECEIVER_TYPE.USER,
+ files: FileList = (document.getElementById("img_file") as HTMLInputElement).files!;
-
-```javascript
-let receiverID = "GUID";
-let messageType = CometChat.MESSAGE_TYPE.FILE;
-let receiverType = CometChat.RECEIVER_TYPE.GROUP;
-let mediaMessage = new CometChat.MediaMessage(
+let mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
receiverID,
files,
messageType,
@@ -907,28 +569,28 @@ let mediaMessage = new CometChat.MediaMessage(
);
CometChat.sendMediaMessage(mediaMessage).then(
- (message) => {
+ (message: CometChat.MediaMessage) => {
console.log("Media message sent successfully", message);
},
- (error) => {
+ (error: CometChat.CometChatException) => {
console.log("Media message sending failed with error", error);
}
);
```
-
-
```typescript
let receiverID: string = "GUID",
messageType: string = CometChat.MESSAGE_TYPE.FILE,
receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
- mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
- receiverID,
- files,
- messageType,
- receiverType
- );
+ files: FileList = (document.getElementById("img_file") as HTMLInputElement).files!;
+
+let mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
+ receiverID,
+ files,
+ messageType,
+ receiverType
+);
CometChat.sendMediaMessage(mediaMessage).then(
(message: CometChat.MediaMessage) => {
@@ -939,26 +601,15 @@ CometChat.sendMediaMessage(mediaMessage).then(
}
);
```
-
-
-The `MediaMessage` class constructor takes the following parameters:
-
-| Parameter | Description |
-| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **receiverId** | The `UID` or `GUID` of the recipient. |
-| **files** | An array of files. |
-| **messageType** | The type of the message that needs to be sent which in this case can be: 1. `CometChat.MESSAGE_TYPE.IMAGE` 2. `CometChat.MESSAGE_TYPE.VIDEO` 3. `CometChat.MESSAGE_TYPE.AUDIO` 4. `CometChat.MESSAGE_TYPE.FILE` |
-| **receiverType** | The type of the receiver to whom the message is to be sent. `1. CometChat.RECEIVER_TYPE.USER` `2. CometChat.RECEIVER_TYPE.GROUP` |
-
-2. **By providing the URL of the multiple files:** The second way to send multiple attachments in a single media message using the CometChat SDK is to provide the SDK with the URL of multiple files that are hosted on your servers or any cloud storage. To achieve this you will have to make use of the Attachment class. For more information, you can refer to the below code snippet:
+### Send Multiple URLs
```javascript
-let receiverID = "cometchat-uid-2";
+let receiverID = "UID";
let messageType = CometChat.MESSAGE_TYPE.IMAGE;
let receiverType = CometChat.RECEIVER_TYPE.USER;
let mediaMessage = new CometChat.MediaMessage(
@@ -989,108 +640,102 @@ attachments.push(new CometChat.Attachment(attachment2));
mediaMessage.setAttachments(attachments);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage) => {
- console.log("message", mediaMessage);
+ (message) => {
+ console.log("Media message sent successfully", message);
},
(error) => {
- console.log("error in sending message", error);
+ console.log("Media message sending failed with error", error);
}
);
```
-
+
+```javascript
+let receiverID = "GUID";
+let messageType = CometChat.MESSAGE_TYPE.IMAGE;
+let receiverType = CometChat.RECEIVER_TYPE.GROUP;
+let mediaMessage = new CometChat.MediaMessage(
+ receiverID,
+ "",
+ messageType,
+ receiverType
+);
-
-```typescript
-let receiverID: string = "cometchat-uid-2",
- messageType: string = CometChat.MESSAGE_TYPE.IMAGE,
- receiverType: string = CometChat.RECEIVER_TYPE.USER,
- mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
- receiverID,
- "",
- messageType,
- receiverType
- );
-
-let attachment1: Object = {
+let attachment1 = {
name: "mario",
extension: "png",
mimeType: "image/png",
url: "https://pngimg.com/uploads/mario/mario_PNG125.png",
};
-let attachment2: Object = {
+let attachment2 = {
name: "jaguar",
extension: "png",
mimeType: "image/png",
url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png",
};
-let attachments: Array = [];
+let attachments = [];
attachments.push(new CometChat.Attachment(attachment1));
attachments.push(new CometChat.Attachment(attachment2));
mediaMessage.setAttachments(attachments);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage: CometChat.MediaMessage) => {
- console.log("message", mediaMessage);
- },
- (error: CometChat.CometChatException) => {
- console.log("error in sending message", error);
+ (message) => {
+ console.log("Media message sent successfully", message);
+ },
+ (error) => {
+ console.log("Media message sending failed with error", error);
}
);
```
-
+
+```typescript
+let receiverID: string = "UID",
+ messageType: string = CometChat.MESSAGE_TYPE.IMAGE,
+ receiverType: string = CometChat.RECEIVER_TYPE.USER,
+ mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
+ receiverID,
+ "",
+ messageType,
+ receiverType
+ );
-
-```javascript
-let receiverID = "cometchat-guid-1";
-let messageType = CometChat.MESSAGE_TYPE.IMAGE;
-let receiverType = CometChat.RECEIVER_TYPE.GROUP;
-let mediaMessage = new CometChat.MediaMessage(
- receiverID,
- "",
- messageType,
- receiverType
-);
-
-let attachment1 = {
+let attachment1: Object = {
name: "mario",
extension: "png",
mimeType: "image/png",
url: "https://pngimg.com/uploads/mario/mario_PNG125.png",
};
-let attachment2 = {
+let attachment2: Object = {
name: "jaguar",
extension: "png",
mimeType: "image/png",
url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png",
};
-let attachments = [];
+let attachments: Array = [];
attachments.push(new CometChat.Attachment(attachment1));
attachments.push(new CometChat.Attachment(attachment2));
mediaMessage.setAttachments(attachments);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage) => {
- console.log("message", mediaMessage);
+ (message: CometChat.MediaMessage) => {
+ console.log("Media message sent successfully", message);
},
- (error) => {
- console.log("error in sending message", error);
+ (error: CometChat.CometChatException) => {
+ console.log("Media message sending failed with error", error);
}
);
```
-
-
```typescript
-let receiverID: string = "cometchat-guid-1",
+let receiverID: string = "GUID",
messageType: string = CometChat.MESSAGE_TYPE.IMAGE,
receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(
@@ -1107,7 +752,7 @@ let attachment1: Object = {
url: "https://pngimg.com/uploads/mario/mario_PNG125.png",
};
-let attachment1: Object = {
+let attachment2: Object = {
name: "jaguar",
extension: "png",
mimeType: "image/png",
@@ -1121,97 +766,20 @@ attachments.push(new CometChat.Attachment(attachment2));
mediaMessage.setAttachments(attachments);
CometChat.sendMediaMessage(mediaMessage).then(
- (mediaMessage: CometChat.MediaMessage) => {
- console.log("message", mediaMessage);
+ (message: CometChat.MediaMessage) => {
+ console.log("Media message sent successfully", message);
},
(error: CometChat.CometChatException) => {
- console.log("error in sending message", error);
+ console.log("Media message sending failed with error", error);
}
);
```
-
-
-When a media message is sent successfully, the response will include a `MediaMessage` object which includes all information related to the sent message.
-
-You can use the `setMetadata()`, `setCaption()` & `setTags()` methods to add metadata, caption and tags respectively in exactly the same way as it is done while sending a single file or attachment in a Media Message.
-
## Custom Message
-*In other words, as a sender, how do I send a custom message like location coordinates?*
-
-CometChat allows you to send custom messages which are neither text nor media messages.
-
-In order to send a custom message, you need to use the `sendCustomMessage()` method.
-
-The `sendCustomMessage()` method takes an object of the `CustomMessage` which can be obtained using the below constructor.
-
-
-
-```js
-let customMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
-```
-
-
-
-
-```typescript
-let customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
-```
-
-
-
-
-
-The above constructor, helps you create a custom message with the message type set to whatever is passed to the constructor and the category set to `custom`.
-
-The parameters involved are:
-
-1. `receiverId` - The unique ID of the user or group to which the message is to be sent.
-2. `receiverType` - Type of the receiver i.e user or group
-3. `customType` - custom message type that you need to set
-4. `customData` - The data to be passed as the message in the form of a JSON Object.
-
-You can also use the subType field of the `CustomMessage` class to set a specific type for the custom message. This can be achieved using the `setSubtype()` method.
-
-### Add Tags
-
-To add a tag to a message you can use the `setTags()` method of the CustomMessage Class. The `setTags()` method accepts a list of tags.
-
-
-
-```javascript
-let tags = ["starredMessage"];
-
-customMessage.setTags(tags);
-```
-
-
-
-
-```typescript
-let tags: Array = ["starredMessage"];
-
-customMessage.setTags(tags);
-```
-
-
-
-
-
-Once the object of `CustomMessage` class is ready you can send the custom message using the `sendCustomMessage()` method.
+Send structured data that doesn't fit text or media categories — like location coordinates, polls, or game moves.
@@ -1223,34 +791,7 @@ let customData = {
};
let customType = "location";
let receiverType = CometChat.RECEIVER_TYPE.USER;
-let customMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
-CometChat.sendCustomMessage(customMessage).then(
- (message) => {
- console.log("custom message sent successfully", message);
- },
- (error) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
-
-
-
-
-```javascript
-let receiverID = "GUID";
-let customData = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-let customType = "location";
-let receiverType = CometChat.RECEIVER_TYPE.GROUP;
let customMessage = new CometChat.CustomMessage(
receiverID,
receiverType,
@@ -1260,126 +801,14 @@ let customMessage = new CometChat.CustomMessage(
CometChat.sendCustomMessage(customMessage).then(
(message) => {
- console.log("custom message sent successfully", message);
+ console.log("Custom message sent successfully", message);
},
(error) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
-
-
-
-
-```typescript
-let receiverID: string = "UID",
- customData: Object = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
- },
- customType: string = "location",
- receiverType: string = CometChat.RECEIVER_TYPE.USER,
- customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
- );
-
-CometChat.sendCustomMessage(customMessage).then(
- (message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
-
-
-
-
-```typescript
-let receiverID: string = "GUID",
- customData: Object = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
- },
- customType: string = "location",
- receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
- customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
- );
-
-CometChat.sendCustomMessage(customMessage).then(
- (message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
+ console.log("Custom message sending failed with error", error);
}
);
```
-
-
-
-
-
-### Set Quoted Message Id
-
-To set a quoted message ID for a message, use the `setQuotedMessageId()` method of the CustomMessage class. This method accepts the ID of the message to be quoted.
-
-
-
-```javascript
-customMessage.setQuotedMessageId(10);
-```
-
-
-
-
-```typescript
-customMessage.setQuotedMessageId(10);
-```
-
-
-
-
-Once the object of `CustomMessage` class is ready you can send the custom message using the `sendCustomMessage()` method.
-
-
-
-```javascript
-let receiverID = "UID";
-let customData = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-let customType = "location";
-let receiverType = CometChat.RECEIVER_TYPE.USER;
-let customMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
-
-CometChat.sendCustomMessage(customMessage).then(
- (message) => {
- console.log("custom message sent successfully", message);
- },
- (error) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
-
-
-
```javascript
let receiverID = "GUID";
@@ -1389,6 +818,7 @@ let customData = {
};
let customType = "location";
let receiverType = CometChat.RECEIVER_TYPE.GROUP;
+
let customMessage = new CometChat.CustomMessage(
receiverID,
receiverType,
@@ -1398,16 +828,14 @@ let customMessage = new CometChat.CustomMessage(
CometChat.sendCustomMessage(customMessage).then(
(message) => {
- console.log("custom message sent successfully", message);
+ console.log("Custom message sent successfully", message);
},
(error) => {
- console.log("custom message sending failed with error", error);
+ console.log("Custom message sending failed with error", error);
}
);
```
-
-
```typescript
let receiverID: string = "UID",
@@ -1426,16 +854,14 @@ let receiverID: string = "UID",
CometChat.sendCustomMessage(customMessage).then(
(message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
+ console.log("Custom message sent successfully", message);
},
(error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
+ console.log("Custom message sending failed with error", error);
}
);
```
-
-
```typescript
let receiverID: string = "GUID",
@@ -1454,274 +880,82 @@ let receiverID: string = "GUID",
CometChat.sendCustomMessage(customMessage).then(
(message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
+ console.log("Custom message sent successfully", message);
},
(error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
+ console.log("Custom message sending failed with error", error);
}
);
```
-
-
-The above sample explains how custom messages can be used to share the location with a user. The same can be achieved for groups.
+The [`CustomMessage`](/sdk/reference/messages#custommessage) class constructor takes the following parameters:
-On success, you will receive an object of the `CustomMessage` class.
+| Parameter | Description | Required |
+| --- | --- | --- |
+| `receiverID` | UID of the user or GUID of the group | Yes |
+| `receiverType` | `CometChat.RECEIVER_TYPE.USER` or `GROUP` | Yes |
+| `customType` | Your custom type string (e.g., `"location"`, `"poll"`) | Yes |
+| `customData` | JSON object with your custom data | Yes |
-### Update Conversation
+On success, `sendCustomMessage()` returns a [CustomMessage](/sdk/reference/messages#custommessage) object.
-*How can I decide whether the custom message should update the last message of a conversation?*
-
-By default, a custom message will update the last message of a conversation. If you wish to not update the last message of the conversation when a custom message is sent, please use shouldUpdateConversation(value: boolean) method of the Custom Message.
+### Add Tags
-
-
```javascript
-let receiverID = "UID";
-let customData = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-let customType = "location";
-let receiverType = CometChat.RECEIVER_TYPE.USER;
-let customMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
-
-customMessage.shouldUpdateConversation(false);
-CometChat.sendCustomMessage(customMessage).then(
- (message) => {
- console.log("custom message sent successfully", message);
- },
- (error) => {
- console.log("custom message sending failed with error", error);
- }
-);
+customMessage.setTags(["starredMessage"]);
```
-
+### Quote a Message
-
```javascript
-let receiverID = "GUID";
-let customData = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-let customType = "location";
-let receiverType = CometChat.RECEIVER_TYPE.GROUP;
-let customMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
-
-customMessage.shouldUpdateConversation(false);
-CometChat.sendCustomMessage(customMessage).then(
- (message) => {
- console.log("custom message sent successfully", message);
- },
- (error) => {
- console.log("custom message sending failed with error", error);
- }
-);
+customMessage.setQuotedMessageId(10);
```
-
+### Control Conversation Update
-
-```typescript
-let receiverID: string = "UID",
- customData: Object = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
- },
- customType: string = "location",
- receiverType: string = CometChat.RECEIVER_TYPE.USER,
- customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
- );
+By default, custom messages update the conversation's last message. To prevent this:
+```javascript
customMessage.shouldUpdateConversation(false);
-CometChat.sendCustomMessage(customMessage).then(
- (message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
- }
-);
```
-
+{/* ### Control Push Notifications
-
-```typescript
-let receiverID: string = "GUID",
- customData: Object = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
- },
- customType: string = "location",
- receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
- customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
- );
+By default, custom messages don't trigger push notifications. To enable them:
-customMessage.shouldUpdateConversation(false);
-CometChat.sendCustomMessage(customMessage).then(
- (message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
-
-
-
-
-
-### Custom Notification Body
-
-*How can i customise the notification body of custom message?*
-
-To add a custom notification body for `Push, Email & SMS` notification of a custom message you can use the `setConversationText(text: string)` method of Custom Message class.
-
-
-
```javascript
-let receiverID = "UID";
-let customData = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-let customType = "location";
-let receiverType = CometChat.RECEIVER_TYPE.USER;
-let customMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
+customMessage.shouldSendNotification(true);
+``` */}
-customMessage.setConversationText("Custom notification body");
-CometChat.sendCustomMessage(customMessage).then(
- (message) => {
- console.log("custom message sent successfully", message);
- },
- (error) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
+### Custom Notification Text
-
+Set custom text for push, email, and SMS notifications:
-
```javascript
-let receiverID = "GUID";
-let customData = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
-};
-let customType = "location";
-let receiverType = CometChat.RECEIVER_TYPE.GROUP;
-let customMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
-);
-
-customMessage.setConversationText("Custom notificatoin body");
-CometChat.sendCustomMessage(customMessage).then(
- (message) => {
- console.log("custom message sent successfully", message);
- },
- (error) => {
- console.log("custom message sending failed with error", error);
- }
-);
+customMessage.setConversationText("Shared a location");
```
-
-
-
-```typescript
-let receiverID: string = "UID",
- customData: Object = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
- },
- customType: string = "location",
- receiverType: string = CometChat.RECEIVER_TYPE.USER,
- customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
- );
-
-customMessage.setConversationText("Custom notification body");
-CometChat.sendCustomMessage(customMessage).then(
- (message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
-
-
-
-
-```typescript
-let receiverID: string = "GUID",
- customData: Object = {
- latitude: "50.6192171633316",
- longitude: "-72.68182268750002",
- },
- customType: string = "location",
- receiverType: string = CometChat.RECEIVER_TYPE.GROUP,
- customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(
- receiverID,
- receiverType,
- customType,
- customData
- );
-
-customMessage.setConversationText("Custom notification body");
-CometChat.sendCustomMessage(customMessage).then(
- (message: CometChat.CustomMessage) => {
- console.log("custom message sent successfully", message);
- },
- (error: CometChat.CometChatException) => {
- console.log("custom message sending failed with error", error);
- }
-);
-```
-
-
-
-
-
+You can also send interactive messages with forms, cards, and buttons. See [Interactive Messages](/sdk/javascript/interactive-messages) for details.
+
-It is also possible to send interactive messages from CometChat, to know more [click here](/sdk/javascript/interactive-messages)
+---
-
+## Next Steps
+
+
+
+ Listen for incoming messages in real-time
+
+
+ Edit previously sent messages
+
+
+ Delete sent messages
+
+
+ Send forms, cards, and custom UI elements
+
+
diff --git a/sdk/javascript/session-timeout.mdx b/sdk/javascript/session-timeout.mdx
index 23470881f..357ba57e2 100644
--- a/sdk/javascript/session-timeout.mdx
+++ b/sdk/javascript/session-timeout.mdx
@@ -1,34 +1,45 @@
---
-title: "Session Timeout Flow"
+title: "Session Timeout"
+sidebarTitle: "Session Timeout"
+description: "Handle idle session timeouts in CometChat calls, including automatic termination, user prompts, and the onSessionTimeout event."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+- Default idle timeout: 180 seconds (3 minutes) alone in a session
+- Warning dialog appears at 120 seconds with stay/leave options
+- Auto-terminates after 60 more seconds if no action taken
+- Listen for `onSessionTimeout` event to handle auto-termination
+- Customize timeout with `setIdleTimeoutPeriod(seconds)` in CallSettings (v4.1.0+)
+
-Available since v4.1.0
+*Available since v4.1.0*
## Overview
-CometChat Calls SDK provides a mechanism to handle session timeouts for idle participants. By default, if a participant is alone in a call session for 180 seconds (3 minutes), the following sequence is triggered:
+The Calls SDK automatically handles idle session timeouts to prevent abandoned calls from consuming resources.
-1. After 120 seconds of being alone in the session, the participant will see a dialog box
+**Default behavior** (participant alone in session for 180 seconds):
-2. This dialog provides options to either:
+1. At 120 seconds: Warning dialog appears with "Stay" or "Leave" options
+2. At 180 seconds: Call auto-terminates if no action taken
- * Stay in the call
- * Leave immediately
-
-3. If no action is taken within the next 60 seconds, the call will automatically end
-
-This feature helps manage inactive call sessions and prevents unnecessary resource usage. The idle timeout period ensures that participants don't accidentally remain in abandoned call sessions.
+Customize the timeout period using `setIdleTimeoutPeriod(seconds)` in `CallSettingsBuilder`.
### Session Timeout Flow
-
-
-
+The `onSessionTimeout` event fires when the call auto-terminates due to inactivity.
-
+---
-The `onSessionTimeout` event is triggered when the call automatically terminates due to session timeout, as illustrated in the diagram above.
+## Next Steps
-
+
+
+ Implement ringing call flows with accept/reject functionality
+
+
+ Implement calling without the Chat SDK
+
+
diff --git a/sdk/javascript/setup-sdk.mdx b/sdk/javascript/setup-sdk.mdx
index e9bdce872..b9a70607b 100644
--- a/sdk/javascript/setup-sdk.mdx
+++ b/sdk/javascript/setup-sdk.mdx
@@ -1,134 +1,92 @@
---
title: "Setup"
sidebarTitle: "Overview"
+description: "Install, configure, and initialize the CometChat JavaScript SDK in your application."
---
-
+This section covers everything you need to get the CometChat JavaScript SDK running in your application.
+
+## Prerequisites
+
+| Requirement | Version |
+|-------------|---------|
+| npm | 8.x or above |
+| Node.js | 16 or above |
+
+You'll also need your credentials from the [CometChat Dashboard](https://app.cometchat.com):
+- App ID
+- Region
+- Auth Key (for development)
+
+## Setup Steps
+
+
+
+ Add the CometChat SDK to your project via npm or CDN. See [Installation](/sdk/javascript/installation).
+
+
+ Configure and initialize the SDK with your App ID and Region. See [Initialization](/sdk/javascript/initialization).
+
+
+ Log in users to start sending and receiving messages. See [Authentication](/sdk/javascript/authentication-overview).
+
+
+
+## Framework Guides
+
+Using an SSR framework? The SDK requires browser APIs and needs client-side initialization:
+
+
+
+ Dynamic imports with useEffect
+
+
+ Client-side mounted hook
+
+
+ Direct SDK usage
+
+
-Migrating app version from v3 to v4 ?
-
-Skip the create new app step. Your existing v3 app can be migrated to v4.
-
-Follow steps mentioned in **Add the CometChat dependency** section below to upgrade to latest version of v4
-
+Migrating from V3 to V4? Your existing app can be migrated — no need to create a new one. See [Upgrading from V3](/sdk/javascript/upgrading-from-v3).
-## Get your Application Keys
-
-[Signup for CometChat](https://app.cometchat.com) and then:
-
-1. Create a new app
-2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region**
-
-## Add the CometChat Dependency
-
-### NPM
+## Quick Reference
-
-
-```js
+```bash
+# Install
npm install @cometchat/chat-sdk-javascript
```
-
-
-
-
-Then, import the `CometChat` object wherever you want to use CometChat.
-
-
-
-```js
+```javascript
import { CometChat } from "@cometchat/chat-sdk-javascript";
-```
-
-
-
-
-
-### HTML (via CDN)
-
-Include the CometChat JavaScript library in your HTML code.
-
-
-```
-
-```
-
-
-
-
-
-## Initialize CometChat
-
-The `init()` method initialises the settings required for CometChat. The `init()` method takes the below parameters:
-
-1. appID - You CometChat App ID
-2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method.
-
-The `AppSettings` class allows you to configure two settings:
-
-* **Region**: The region where you app was created.
-* [Presence Subscription](/sdk/javascript/user-presence)**:** Represents the subscription type for user presence (real-time online/offline status)
-* **autoEstablishSocketConnection(boolean value)**: This property takes a boolean value which when set to `true` informs the SDK to manage the web-socket connection internally. If set to `false` , it informs the SDK that the web-socket connection will be managed manually. The default value for this parameter is true. For more information on this, please check the [Managing Web-Socket connections manually](/sdk/javascript/managing-web-sockets-connections-manually) section. The default value for this property is **true.**
-* **overrideAdminHost(adminHost: string)**: This method takes the admin URL as input and uses this admin URL instead of the default admin URL. This can be used in case of dedicated deployment of CometChat.
-* **overrideClientHost(clientHost: string)**: This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat.
-
-You need to call `init()` before calling any other method from CometChat. We suggest you call the `init()` method on app startup, preferably in the `index.js` file.
-
-
-
-```js
-let appID = "APP_ID";
-let region = "APP_REGION";
-let appSetting = new CometChat.AppSettingsBuilder()
+// Initialize
+const appSettings = new CometChat.AppSettingsBuilder()
+ .setRegion("REGION")
.subscribePresenceForAllUsers()
- .setRegion(region)
- .autoEstablishSocketConnection(true)
.build();
-CometChat.init(appID, appSetting).then(
- () => {
- console.log("Initialization completed successfully");
- },
- (error) => {
- console.log("Initialization failed with error:", error);
- }
-);
-```
-
-
-
-```typescript
-let appID: string = "APP_ID",
- region: string = "APP_REGION",
- appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder()
- .subscribePresenceForAllUsers()
- .setRegion(region)
- .autoEstablishSocketConnection(true)
- .build();
-CometChat.init(appID, appSetting).then(
- (initialized: boolean) => {
- console.log("Initialization completed successfully", initialized);
- },
- (error: CometChat.CometChatException) => {
- console.log("Initialization failed with error:", error);
- }
-);
-```
-
-
+await CometChat.init("APP_ID", appSettings);
-
-
-Make sure you replace the `APP_ID` with your CometChat **App ID** and `APP_REGION` with your **App Region** in the above code.
+// Login
+await CometChat.login("UID", "AUTH_KEY");
+```
-| Parameter | Description |
-| ---------- | ----------------------------------- |
-| appID | CometChat App ID |
-| appSetting | An object of the AppSettings class. |
+## Pages in This Section
+
+
+
+ Add the SDK via npm or CDN
+
+
+ Configure and initialize the SDK
+
+
+ Next.js, Nuxt, and Ionic setup
+
+
+ Log in users with Auth Key or Token
+
+
diff --git a/sdk/javascript/ssr-compatibility.mdx b/sdk/javascript/ssr-compatibility.mdx
new file mode 100644
index 000000000..a4b362c12
--- /dev/null
+++ b/sdk/javascript/ssr-compatibility.mdx
@@ -0,0 +1,279 @@
+---
+title: "SSR Compatibility"
+description: "Set up the CometChat JavaScript SDK with Next.js, NuxtJS, Ionic, and other server-side rendering frameworks."
+---
+
+The CometChat SDK requires browser APIs (`window`, `WebSocket`) and cannot run on the server. For SSR frameworks, initialize the SDK only on the client side.
+
+## Next.js
+
+Import the SDK dynamically in `useEffect` (functional components) or `componentDidMount` (class components).
+
+
+
+```javascript
+import React from "react";
+import Chat from "./Chat";
+
+export default function Home() {
+ let [libraryImported, setLibraryImported] = React.useState(false);
+
+ React.useEffect(() => {
+ window.CometChat = require("@cometchat/chat-sdk-javascript").CometChat;
+ setLibraryImported(true);
+ }, []);
+
+ return libraryImported ? :
+
+
+
+```
+
+
+
+
+```javascript
+module.exports = {
+ APP_ID: "APP_ID",
+ REGION: "REGION",
+ AUTH_KEY: "AUTH_KEY",
+};
+```
+
+
+
+
+
+## Ionic/Cordova
+
+For Ionic and Cordova applications, use the JavaScript SDK directly. Import and initialize in your root component:
+
+```typescript
+import { Component, OnInit } from '@angular/core';
+import { CometChat } from '@cometchat/chat-sdk-javascript';
+
+@Component({
+ selector: 'app-root',
+ templateUrl: 'app.component.html',
+})
+export class AppComponent implements OnInit {
+
+ ngOnInit() {
+ this.initCometChat();
+ }
+
+ initCometChat() {
+ const appID = 'APP_ID';
+ const region = 'APP_REGION';
+
+ const appSetting = new CometChat.AppSettingsBuilder()
+ .subscribePresenceForAllUsers()
+ .setRegion(region)
+ .autoEstablishSocketConnection(true)
+ .build();
+
+ CometChat.init(appID, appSetting).then(
+ () => {
+ console.log('CometChat initialized successfully');
+ },
+ (error) => {
+ console.log('CometChat initialization failed:', error);
+ }
+ );
+ }
+}
+```
+
+
+The dedicated Ionic Cordova SDK has been deprecated. For new Ionic/Cordova applications, use the JavaScript SDK as shown above. Existing users can refer to the [legacy documentation](/sdk/ionic-legacy/overview).
+
+
+---
+
+## Next Steps
+
+
+
+ Log in users with Auth Key or Auth Token
+
+
+ Send your first message
+
+
diff --git a/sdk/javascript/standalone-calling.mdx b/sdk/javascript/standalone-calling.mdx
index 09df82d0e..54db56dca 100644
--- a/sdk/javascript/standalone-calling.mdx
+++ b/sdk/javascript/standalone-calling.mdx
@@ -1,7 +1,28 @@
---
title: "Standalone Calling"
+sidebarTitle: "Standalone Calling"
+description: "Implement video and audio calling using only the CometChat Calls SDK without the Chat SDK. Covers authentication, token generation, session management, and call controls."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+
+```javascript
+// Generate call token (requires user auth token from REST API)
+const callToken = await CometChatCalls.generateToken(sessionId, userAuthToken);
+
+// Start call session
+const callSettings = new CometChatCalls.CallSettingsBuilder()
+ .enableDefaultLayout(true)
+ .setIsAudioOnlyCall(false)
+ .setCallListener(callListener)
+ .build();
+CometChatCalls.startSession(callToken.token, callSettings, htmlElement);
+
+// End session
+CometChatCalls.endSession();
+```
+
## Overview
This section demonstrates how to implement calling functionality using only the CometChat Calls SDK, without requiring the Chat SDK. This is ideal for applications that need video/audio calling capabilities without the full chat infrastructure.
@@ -228,6 +249,10 @@ Configure the call experience using the following `CallSettingsBuilder` methods:
The `OngoingCallListener` provides real-time callbacks for call session events, including participant changes, call state updates, and error conditions.
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
+
You can register listeners in two ways:
1. **Via CallSettingsBuilder:** Use `.setCallListener(listener)` when building call settings
@@ -647,3 +672,16 @@ CometChatCalls.endSession();
```
+
+---
+
+## Next Steps
+
+
+
+ Implement ringing call flows using the Chat SDK
+
+
+ Add call recording to your voice and video calls
+
+
diff --git a/sdk/javascript/threaded-messages.mdx b/sdk/javascript/threaded-messages.mdx
index e2d29a55a..e3d2bcf27 100644
--- a/sdk/javascript/threaded-messages.mdx
+++ b/sdk/javascript/threaded-messages.mdx
@@ -1,24 +1,34 @@
---
title: "Threaded Messages"
+sidebarTitle: "Threaded Messages"
+description: "Send, receive, and fetch threaded messages using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Send message in a thread
+const msg = new CometChat.TextMessage("UID", "Reply", CometChat.RECEIVER_TYPE.USER);
+msg.setParentMessageId(100);
+await CometChat.sendMessage(msg);
+
+// Fetch thread messages
+const request = new CometChat.MessagesRequestBuilder()
+ .setParentMessageId(100).setLimit(30).build();
+const messages = await request.fetchPrevious();
+
+// Exclude thread replies from main conversation
+const request = new CometChat.MessagesRequestBuilder()
+ .setUID("UID").setLimit(30).hideReplies(true).build();
+```
+
-Messages that are started from a particular message are called Threaded messages or simply threads. Each Thread is attached to a message which is the Parent message for that thread.
+Threaded messages (or threads) are messages started from a particular parent message. Each thread is attached to a parent message.
## Send Message in a Thread
-As mentioned in the [Send a Message](/sdk/javascript/send-message) section. You can either send a message to a User or a Group based on the `receiverType` and the UID/GUID specified for the message. A message can belong to either of the below types:
-
-1. Text Message
-2. Media Message
-3. Custom Message.
-
-Any of the above messages can be sent in a thread. As mentioned, a thread is identified based on the Parent message. So while sending a message the `parentMessageId` must be set for the message to indicate that the message to be sent needs to be a part of the thread with the specified `parentMessageId`.
-
-This can be achieved using the `setParentMessageId()` method provided by the object of the `TextMessage`, `MediaMessage` and `CustomMessage` class. The id specified in the `setParentMessageId()` method maps the message sent to the particular thread.
-
-**Example to Send a Text Message in a thread in a user conversation.**
+Any message type (Text, Media, or Custom) can be sent in a thread. Set the `parentMessageId` using `setParentMessageId()` to indicate which thread the message belongs to.
@@ -59,21 +69,17 @@ CometChat.sendMessage(textMessage).then(
-The above snippet shows how a message with the text "Hello" can be sent in the thread with `parentMessageId` 100.
-
-Similarly, using the `setParentMessageId()` method, Media and Custom Messages can be sent in threads too.
+The above snippet sends "Hello" in the thread with `parentMessageId` 100. Media and Custom messages can also be sent in threads using `setParentMessageId()`.
### Receiving Real-Time Messages
-The procedure to receive real-time messages is exactly the same as mentioned in the [Receive Messages](/sdk/javascript/receive-message). This can be achieved using the `MessageListener` class provided by the SDK.
-
-To add a MessageListener, you can use the `addMessageListener()` method of the SDK. The only thing that needs to be checked is if the received message belongs to the active thread. This can be done using the `parentMessageId` field of the message object.
+Use `MessageListener` to receive real-time thread messages. Check if the received message belongs to the active thread using `getParentMessageId()`.
```javascript
-var listenerID = "UNIQUE_LISTENER_ID";
-var activeThreadId = 100;
+const listenerID = "UNIQUE_LISTENER_ID";
+const activeThreadId = 100;
CometChat.addMessageListener(
listenerID,
@@ -101,8 +107,8 @@ new CometChat.MessageListener({
```typescript
-var listenerID: string = "UNIQUE_LISTENER_ID",
- activeThreadId: number = 100;
+const listenerID: string = "UNIQUE_LISTENER_ID";
+const activeThreadId: number = 100;
CometChat.addMessageListener(
listenerID,
@@ -132,9 +138,7 @@ CometChat.addMessageListener(
### Fetch all the messages for any particular thread.
-You can fetch all the messages belonging to a particular thread by using the `MessagesRequest` class. In order to get an object of the `MessagesRequest` class, you need to use the `MessagesRequestBuilder` class. and use the `setParentMessageId()` method of the `MessagesRequestBuilder` to inform the SDK that you only need the messages belonging to the thread with the specified parentMessageId.
-
-Once you have the object of the `MessagesRequest` class, you need to call the `fetchPrevious()` method to get the latest messages in the thread. In one integration, a maximum of 100 messages can be fetched. If you wish to fetch the next set of messages, you need to call the `fetchPrevious()` method again on the same object.
+Use `MessagesRequestBuilder` with `setParentMessageId()` to fetch messages belonging to a specific thread. Call `fetchPrevious()` to get messages (max 100 per request).
@@ -179,9 +183,20 @@ messagesRequest.fetchPrevious().then(
+The `fetchPrevious()` method returns an array of [`BaseMessage`](/sdk/reference/messages#basemessage) objects representing thread replies. Access the data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the message |
+| type | `getType()` | `string` | Message type (`text`, `image`, `custom`, etc.) |
+| sentAt | `getSentAt()` | `number` | Timestamp when the message was sent |
+| parentMessageId | `getParentMessageId()` | `number` | ID of the parent message this reply belongs to |
+| replyCount | `getReplyCount()` | `number` | Number of replies on the parent message |
+
## Avoid Threaded Messages in User/Group Conversations
-While fetching messages for normal user/group conversations using the `MessagesRequest`, the threaded messages by default will be a part of the list of messages received. In order to exclude the threaded messages from the list of user/group messages, you need to use the `hideReplies()` method of the `MessagesRequestBuilder` class. This method takes a boolean argument which when set to true excludes the messages belonging to threads from the list of messages.
+Use `hideReplies(true)` to exclude threaded messages when fetching messages for a conversation.
@@ -270,4 +285,17 @@ messagesRequest.fetchPrevious().then(
-The above snippet will return messages between the logged in user and `cometchat-uid-1` excluding all the threaded messages belonging to the same conversation.
+The above snippet returns messages excluding threaded replies.
+
+---
+
+## Next Steps
+
+
+
+ Send text, media, and custom messages to users and groups
+
+
+ Listen for incoming messages in real-time and fetch missed messages
+
+
diff --git a/sdk/javascript/transfer-group-ownership.mdx b/sdk/javascript/transfer-group-ownership.mdx
index 1de52a892..1fa9199cb 100644
--- a/sdk/javascript/transfer-group-ownership.mdx
+++ b/sdk/javascript/transfer-group-ownership.mdx
@@ -1,14 +1,23 @@
---
title: "Transfer Group Ownership"
+sidebarTitle: "Transfer Ownership"
+description: "Transfer ownership of a CometChat group to another member using the JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Transfer group ownership
+await CometChat.transferGroupOwnership("GUID", "NEW_OWNER_UID");
+```
-*In other words, as a logged-in user, how do I transfer the ownership of any group if I am the owner of the group?*
+**Note:** Only the current group owner can transfer ownership. The owner must transfer ownership before leaving the group.
+
-In order to transfer the ownership of any group, the first condition is that you must be the owner of the group. In case you are the owner of the group, you can use the `transferGroupOwnership()` method provided by the `CometChat` class.
+Only the owner of a [Group](/sdk/reference/entities#group) can transfer ownership. Since owners cannot leave their group, you must transfer ownership first if you want to leave.
-This will be helpful as the owner is not allowed to leave the group. In case, you as the owner would like to leave the group, you will have to use this method and transfer your ownership first to any other member of the group and only then you will be allowed to leave the group.
+Use `transferGroupOwnership()` to transfer ownership to another member.
@@ -42,3 +51,18 @@ CometChat.transferGroupOwnership(GUID, UID).then(
+
+On success, the method resolves with a success message string confirming the operation.
+
+---
+
+## Next Steps
+
+
+
+ Leave a group after transferring ownership
+
+
+ Promote or demote group members
+
+
diff --git a/sdk/javascript/transient-messages.mdx b/sdk/javascript/transient-messages.mdx
index 9f44b2267..f80d95bbe 100644
--- a/sdk/javascript/transient-messages.mdx
+++ b/sdk/javascript/transient-messages.mdx
@@ -1,8 +1,23 @@
---
title: "Transient Messages"
+sidebarTitle: "Transient Messages"
+description: "Send and receive ephemeral real-time messages that are not stored on the server using the CometChat JavaScript SDK. Ideal for live reactions and temporary indicators."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Send transient message to user
+const msg = new CometChat.TransientMessage("UID", CometChat.RECEIVER_TYPE.USER, { LIVE_REACTION: "heart" });
+CometChat.sendTransientMessage(msg);
+
+// Listen for transient messages
+CometChat.addMessageListener("LISTENER_ID", new CometChat.MessageListener({
+ onTransientMessageReceived: (msg) => console.log("Transient:", msg)
+}));
+```
+
Transient messages are messages that are sent in real-time only and are not saved or tracked anywhere. The receiver of the message will only receive the message if he is online and these messages cannot be retrieved later.
@@ -63,7 +78,9 @@ CometChat.sendTransientMessage(transientMessage);
## Real-time Transient Messages
-*In other words, as a recipient, how do I know when someone sends a transient message?*
+
+Always remove listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
+
You will receive the transient message in the `onTransientMessageReceived()` method of the registered `MessageListener` class.
@@ -102,7 +119,7 @@ CometChat.addMessageListener(
-The `TransientMessage` class consists of the below parameters:
+The [`TransientMessage`](/sdk/reference/auxiliary#transientmessage) class consists of the below parameters:
| Parameter | Information |
| ---------------- | -------------------------------------------------------------------------------------------------------- |
@@ -110,3 +127,25 @@ The `TransientMessage` class consists of the below parameters:
| **receiverId** | Unique Id of the receiver. This can be the Id of the group or the user the transient message is sent to. |
| **receiverType** | The type of the receiver - `CometChat.RECEIVER_TYPE.USER` or `CometChat.RECEIVER_TYPE.GROUP` |
| **data** | A JSONObject to provide data. |
+
+The listener callback receives a [`TransientMessage`](/sdk/reference/auxiliary#transientmessage) object. Access the data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | The user who sent the transient message |
+| receiverId | `getReceiverId()` | `string` | UID or GUID of the receiver |
+| receiverType | `getReceiverType()` | `string` | Type of receiver (`user` or `group`) |
+| data | `getData()` | `Object` | Custom JSON data payload |
+
+---
+
+## Next Steps
+
+
+
+ Show real-time typing status in conversations
+
+
+ Send text, media, and custom messages
+
+
diff --git a/sdk/javascript/troubleshooting.mdx b/sdk/javascript/troubleshooting.mdx
new file mode 100644
index 000000000..ce02a53ff
--- /dev/null
+++ b/sdk/javascript/troubleshooting.mdx
@@ -0,0 +1,184 @@
+---
+title: "Troubleshooting"
+sidebarTitle: "Troubleshooting"
+description: "Common failure modes and fixes for the CometChat JavaScript SDK."
+---
+
+Find solutions to common issues when building with the CometChat JavaScript SDK.
+
+## Quick Reference
+
+| Issue | Fix |
+|-------|-----|
+| `init()` fails | Verify App ID and Region from [Dashboard](https://app.cometchat.com) |
+| Login fails with "UID not found" | Create user via Dashboard or REST API first |
+| SDK methods fail | Ensure `init()` completes before calling other methods |
+| No real-time events | Check WebSocket connection, verify listeners registered |
+| SSR errors | Use dynamic imports or `useEffect` for client-side only |
+
+---
+
+## Initialization & Authentication
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| `init()` fails with "App ID not found" | Invalid App ID or Region | Verify credentials in [Dashboard](https://app.cometchat.com) → API & Auth Keys |
+| `init()` fails silently | Missing credentials | Double-check App ID and Region are strings, not undefined |
+| "CometChat not initialized" | `init()` not awaited | Ensure `init()` resolves before calling other methods |
+| Login fails with "UID not found" | User doesn't exist | Create user via [Dashboard](https://app.cometchat.com) or [REST API](https://api-explorer.cometchat.com/reference/creates-user) |
+| Login fails with "Auth Key is not valid" | Wrong Auth Key | Verify Auth Key in Dashboard. Don't confuse with REST API Key |
+| `getLoggedinUser()` returns null | Session cleared or `init()` not called | Call `init()` on every app load before checking session |
+| Auth Token expired | Token lifetime exceeded | Generate new token via [REST API](https://api-explorer.cometchat.com/reference/create-authtoken) |
+| User appears offline after login | Presence not configured | Use `subscribePresenceForAllUsers()` in `AppSettingsBuilder` |
+
+---
+
+## Messaging
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| `sendMessage()` fails | Not logged in or invalid receiver | Ensure `login()` completes. Verify receiver UID/GUID exists |
+| Messages sent but not received | Listener not registered | Register `addMessageListener()` with `onTextMessageReceived` |
+| Duplicate messages | Multiple listeners | Use unique listener IDs. Remove old listeners first |
+| Wrong conversation | Wrong receiver type | Use `RECEIVER_TYPE.USER` for 1:1, `RECEIVER_TYPE.GROUP` for groups |
+| Media upload fails | File too large or unsupported | Check limits. Supported: PNG, JPG, GIF, MP4, MP3, WAV |
+| Metadata not appearing | Set after send | Call `setMetadata()` before the send method |
+| Pagination not working | New request object | Reuse the same `MessagesRequest` for `fetchPrevious()`/`fetchNext()` |
+| Thread replies in main chat | Missing filter | Add `.hideReplies(true)` to `MessagesRequestBuilder` |
+| Deleted messages showing | Missing filter | Add `.hideDeletedMessages(true)` |
+
+---
+
+## Groups
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| Cannot join group | Invalid GUID | Verify GUID. Create group first if needed |
+| Cannot send to group | Not a member | Join group first with `joinGroup()` |
+| Cannot kick/ban members | Insufficient scope | Only admins and moderators can kick/ban |
+| Can't join private group | Requires invite | Private groups require admin to add you |
+| Owner can't leave | Ownership not transferred | Call `transferGroupOwnership()` first |
+| Password join fails | Wrong password | Pass correct password as second parameter |
+| `fetchNext()` returns same results | New request object | Reuse the same `GroupsRequest` instance |
+| Scope filter returns nothing | Invalid strings | Use `"admin"`, `"moderator"`, `"participant"` |
+| Status filter not working | Wrong constant | Use `CometChat.USER_STATUS.ONLINE`/`OFFLINE` |
+| Cannot demote admin | Not owner | Only group owner can demote admins |
+| Kicked user can still see group | Kick vs ban | Use `banGroupMember()` to prevent rejoining |
+
+---
+
+## Calling
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| Calls SDK not found | Not installed | Run `npm install @cometchat/calls-sdk-javascript` |
+| No audio/video | Permissions denied | Check browser permissions for camera/microphone |
+| Call not connecting | Session ID mismatch | Verify both participants use same session ID |
+| One-way audio | Firewall blocking WebRTC | Check network config. Corporate networks may block WebRTC |
+| Incoming call not showing | Listener not registered | Register `addCallListener()` at app root level |
+| Black screen after joining | Element not visible | Ensure HTML element has proper dimensions |
+| CSS changes not applying | Specificity issue | Try adding `!important` |
+| Styles only work in one mode | Mode-specific classes | Test in `DEFAULT`, `TILE`, and `SPOTLIGHT` modes |
+
+---
+
+## WebSocket & Connection
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| Real-time events not received | WebSocket disconnected | Check `getConnectionStatus()`. Reconnect if needed |
+| WebSocket fails | Firewall blocking | Check network config. Corporate firewalls may block WebSocket |
+| Connection drops frequently | Network instability | Use `addConnectionListener()` to monitor and reconnect |
+| Stuck in "connecting" | Network or config issue | Verify network, `appId`, and `region` |
+| No events after login | Auto-connect disabled | Call `CometChat.connect()` manually if `autoEstablishSocketConnection(false)` |
+| `connect()` doesn't work | Not logged in | Ensure user is logged in first |
+
+---
+
+## Listeners
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| Events not firing | Registered before init | Register after `init()` and `login()` complete |
+| Duplicate events | Multiple listeners | Remove old listeners before adding new ones |
+| Missing events after navigation | Listeners removed | Re-register when new component mounts |
+| Receipt events not triggering | Receipts not sent | Call `markAsDelivered()`/`markAsRead()` explicitly |
+
+---
+
+## Typing, Receipts & Reactions
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| Typing indicator stuck | `endTyping()` not called | Call on send, blur, or after 3-5s timeout |
+| Double-tick not showing | `markAsDelivered()` not called | Call on message fetch and real-time receive |
+| Group receipts missing | Feature not enabled | Enable "Enhanced Messaging Status" in Dashboard |
+| Reaction not appearing | UI not synced | Call `updateMessageWithReactionInfo()` on events |
+| Duplicate reactions | No check before adding | Use `getReactedByMe()` first |
+
+---
+
+## AI Features
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| AI features not appearing | Not enabled | Enable in [Dashboard](https://app.cometchat.com) → AI Features |
+| AI Agents not responding | Not configured | Configure Agent in Dashboard. Agents only respond to text |
+| `onAIAssistantEventReceived` not firing | Listener not registered | Register `AIAssistantListener` after login |
+| Moderation always PENDING | Rules not configured | Configure rules in Dashboard → Moderation → Rules |
+| Agentic messages not arriving | Wrong listener | Use `MessageListener` with `onAIAssistantMessageReceived` |
+
+---
+
+## SSR / Framework-Specific
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| "window is not defined" | SDK accessed during SSR | Use dynamic imports or `useEffect` |
+| Next.js SSR error | Server render | Use `await import('@cometchat/chat-sdk-javascript')` |
+| Nuxt "document is not defined" | Server render | Import in `mounted()` lifecycle hook |
+| React Native errors | Wrong SDK | Use `@cometchat/chat-sdk-react-native` |
+
+---
+
+## Upgrading from V3
+
+| Symptom | Cause | Fix |
+|---------|-------|-----|
+| "Module not found" | Old import paths | Replace `@cometchat-pro/chat` with `@cometchat/chat-sdk-javascript` |
+| Calls SDK not working | Wrong package | Use `@cometchat/calls-sdk-javascript` |
+| Both versions installed | Package conflict | Remove v3 package completely |
+
+---
+
+## Error Codes
+
+| Code | Description | Resolution |
+|------|-------------|------------|
+| `ERR_UID_NOT_FOUND` | User doesn't exist | Create user via Dashboard or REST API |
+| `ERR_AUTH_KEY_NOT_FOUND` | Invalid Auth Key | Verify in Dashboard |
+| `ERR_APP_NOT_FOUND` | Invalid App ID or Region | Check Dashboard |
+| `ERR_NOT_LOGGED_IN` | No active session | Call `login()` first |
+| `ERR_GUID_NOT_FOUND` | Group doesn't exist | Create group or verify GUID |
+| `ERR_NOT_A_MEMBER` | Not a group member | Join group first |
+| `ERR_BLOCKED` | User is blocked | Unblock via Dashboard or SDK |
+| `ERR_RATE_LIMIT_EXCEEDED` | Too many requests | See [Rate Limits](/articles/rate-limits) |
+
+---
+
+## Next Steps
+
+
+
+ Installation and initialization guide
+
+
+ Recommended patterns and practices
+
+
+ AI Agents, Moderation, and Copilot
+
+
+ Open a support ticket
+
+
diff --git a/sdk/javascript/typing-indicators.mdx b/sdk/javascript/typing-indicators.mdx
index 0174f5727..1fb3a0cb4 100644
--- a/sdk/javascript/typing-indicators.mdx
+++ b/sdk/javascript/typing-indicators.mdx
@@ -1,16 +1,33 @@
---
title: "Typing Indicators"
+sidebarTitle: "Typing Indicators"
+description: "Send and receive real-time typing indicators using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Start typing indicator
+const typing = new CometChat.TypingIndicator("UID", CometChat.RECEIVER_TYPE.USER);
+CometChat.startTyping(typing);
+
+// Stop typing indicator
+CometChat.endTyping(typing);
+
+// Listen for typing events
+CometChat.addMessageListener("LISTENER_ID", new CometChat.MessageListener({
+ onTypingStarted: (indicator) => console.log("Typing started:", indicator),
+ onTypingEnded: (indicator) => console.log("Typing ended:", indicator)
+}));
+```
+
## Send a Typing Indicator
-*In other words, as a sender, how do I let the recipient(s) know that I'm typing?*
-
### Start Typing
-You can use the `startTyping()` method to inform the receiver that the logged in user has started typing. The receiver will receive this information in the `onTypingStarted()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class.
+Use `startTyping()` with a [`TypingIndicator`](/sdk/reference/auxiliary#typingindicator) object to notify the receiver that you're typing.
@@ -61,7 +78,7 @@ CometChat.startTyping(typingNotification);
### Stop Typing
-You can use the `endTyping()` method to inform the receiver that the logged in user has stopped typing. The receiver will receive this information in the `onTypingEnded()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class.
+Use `endTyping()` to notify the receiver that you've stopped typing.
@@ -111,17 +128,12 @@ CometChat.endTyping(typingNotification);
-Custom Data
-
-You can use the `metadata` field of the `TypingIndicator` class to pass additional data along with the typing indicators. The metadata field is a JSONObject and can be set using the `setMetadata()` method of the `TypingIndicator` class. This data will be received at the receiver end and can be obtained using the `getMetadata()` method.
-
+Use `setMetadata()` on `TypingIndicator` to pass additional custom data. Retrieve it with `getMetadata()` on the receiver side.
## Real-time Typing Indicators
-*In other words, as a recipient, how do I know when someone is typing?*
-
-You will receive the typing indicators in the `onTypingStarted()` and the `onTypingEnded()` method of the registered `MessageListener` class.
+Use `onTypingStarted` and `onTypingEnded` in `MessageListener` to receive typing events.
@@ -164,11 +176,33 @@ CometChat.addMessageListener(
-The `TypingIndicator` class consists of the below parameters:
+The [`TypingIndicator`](/sdk/reference/auxiliary#typingindicator) object contains:
+
+| Parameter | Description |
+| --- | --- |
+| sender | User object of the person typing |
+| receiverId | UID or GUID of the receiver |
+| receiverType | `CometChat.RECEIVER_TYPE.USER` or `GROUP` |
+| metadata | Additional custom data |
+
+The `onTypingStarted` and `onTypingEnded` listener callbacks receive a [`TypingIndicator`](/sdk/reference/auxiliary#typingindicator) object. Access the data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| receiverId | `getReceiverId()` | `string` | UID or GUID of the typing indicator recipient |
+| receiverType | `getReceiverType()` | `string` | Type of receiver (`"user"` or `"group"`) |
+| sender | `getSender()` | `User` | The user who is typing |
+| metadata | `getMetadata()` | `Object` | Additional custom data sent with the indicator |
+
+---
+
+## Next Steps
-| Parameter | Information |
-| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **sender** | An object of the `User` class holding all the information. related to the sender of the typing indicator. |
-| **receiverId** | Unique Id of the receiver. This can be the Id of the group or the user the typing indicator is sent to. |
-| **receiverType** | This parameter indicates if the typing indicator is to be sent to a user or a group. The possible values are: 1. `CometChat.RECEIVER_TYPE.USER` 2. `CometChat.RECEIVER_TYPE.GROUP` |
-| **metadata** | A JSONObject to provider additional data. |
+
+
+ Track when messages are delivered and read
+
+
+ Send ephemeral real-time messages like live reactions
+
+
diff --git a/sdk/javascript/update-group.mdx b/sdk/javascript/update-group.mdx
index c8717d61c..16124425c 100644
--- a/sdk/javascript/update-group.mdx
+++ b/sdk/javascript/update-group.mdx
@@ -1,22 +1,30 @@
---
title: "Update A Group"
+sidebarTitle: "Update Group"
+description: "Update group details such as name, type, icon, and description using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Update group details
+const group = new CometChat.Group("GUID", "New Name", CometChat.GROUP_TYPE.PUBLIC);
+const updated = await CometChat.updateGroup(group);
+```
+
## Update Group
-*In other words, as a group owner, how can I update the group details?*
-
-You can update the existing details of the group using the `updateGroup()` method.
+Use `updateGroup()` to modify group details. Pass a `Group` object with the updated values.
```javascript
-var GUID = "GUID";
-var groupName = "Hello Group";
-var groupType = CometChat.GROUP_TYPE.PUBLIC;
-var group = new CometChat.Group(GUID, groupName, groupType);
+const GUID = "GUID";
+const groupName = "Hello Group";
+const groupType = CometChat.GROUP_TYPE.PUBLIC;
+const group = new CometChat.Group(GUID, groupName, groupType);
CometChat.updateGroup(group).then(
group => {
@@ -31,11 +39,11 @@ group => {
```typescript
-var GUID: string = "GUID";
-var groupName: string = "Hello Group!";
-var groupType: string = CometChat.GROUP_TYPE.PUBLIC;
+const GUID: string = "GUID";
+const groupName: string = "Hello Group!";
+const groupType: string = CometChat.GROUP_TYPE.PUBLIC;
-var group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType);
+const group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType);
CometChat.updateGroup(group).then(
(group: CometChat.Group) => {
@@ -50,12 +58,35 @@ CometChat.updateGroup(group).then(
-This method takes an instance of the `Group` class as a parameter which should contain the data that you wish to update.
+| Parameter | Description |
+| --------- | ----------- |
+| `group` | An instance of `Group` class with updated values |
+
+On success, returns a [`Group`](/sdk/reference/entities#group) object with the updated details.
-| Parameter | Description |
-| --------- | ---------------------------- |
-| `group` | an instance of class `Group` |
+The method returns a [`Group`](/sdk/reference/entities#group) object. Access the response data using getter methods:
-After a successful update of the group, you will receive an instance of `Group` class containing update information of the group.
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| guid | `getGuid()` | `string` | Unique group ID |
+| name | `getName()` | `string` | Display name of the group |
+| type | `getType()` | `string` | Group type (`"public"`, `"private"`, or `"password"`) |
+| description | `getDescription()` | `string` | Description of the group |
+| icon | `getIcon()` | `string` | URL of the group icon |
+| owner | `getOwner()` | `string` | UID of the group owner |
+| updatedAt | `getUpdatedAt()` | `number` | Timestamp when the group was last updated |
For more information on the `Group` class, please check [here](/sdk/javascript/create-group#create-a-group).
+
+---
+
+## Next Steps
+
+
+
+ Permanently delete a group
+
+
+ Fetch and filter groups with pagination
+
+
diff --git a/sdk/javascript/upgrading-from-v3.mdx b/sdk/javascript/upgrading-from-v3.mdx
index 00cf6868a..51d7e1b01 100644
--- a/sdk/javascript/upgrading-from-v3.mdx
+++ b/sdk/javascript/upgrading-from-v3.mdx
@@ -1,9 +1,17 @@
---
title: "Upgrading From V3"
+description: "Migrate your CometChat JavaScript SDK integration from v3 to v4 with updated dependencies and import statements."
---
+{/* TL;DR for Agents and Quick Reference */}
+
-
+Key changes from v3 to v4:
+- Chat SDK: `npm i @cometchat/chat-sdk-javascript`
+- Calls SDK: `npm i @cometchat/calls-sdk-javascript`
+- Import: `import { CometChat } from '@cometchat/chat-sdk-javascript'`
+- Import Calls: `import { CometChatCalls } from '@cometchat/calls-sdk-javascript'`
+
## Upgrading From v3
Upgrading from v3.x to v4 is fairly simple. Below are the major changes that are released as a part of CometChat v4:
@@ -63,3 +71,16 @@ import {CometChatCalls} from '@cometchat/calls-sdk-javascript';
+
+---
+
+## Next Steps
+
+
+
+ Install and configure the CometChat JavaScript SDK
+
+
+ Learn the core concepts behind CometChat v4
+
+
diff --git a/sdk/javascript/user-management.mdx b/sdk/javascript/user-management.mdx
index 76ac2b585..a5625c047 100644
--- a/sdk/javascript/user-management.mdx
+++ b/sdk/javascript/user-management.mdx
@@ -1,183 +1,206 @@
---
title: "User Management"
+sidebarTitle: "User Management"
+description: "Create, update, and manage CometChat users programmatically using the JavaScript SDK. Includes user creation, profile updates, and the User class reference."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Create a user
+const user = new CometChat.User("user1");
+user.setName("Kevin");
+await CometChat.createUser(user, "AUTH_KEY");
-When a user logs into your app, you need to programmatically login the user into CometChat. But before you log in the user to CometChat, you need to create the user.
+// Update a user
+user.setName("Kevin Fernandez");
+await CometChat.updateUser(user, "AUTH_KEY");
-Summing up-
+// Update logged-in user (no auth key needed)
+await CometChat.updateCurrentUserDetails(user);
+```
-**When a user registers in your app**
+**Note:** User creation/deletion should ideally happen on your backend via the [REST API](https://api-explorer.cometchat.com).
+
-1. You add the user details in your database
-2. You create a user in CometChat
+Users must exist in CometChat before they can log in. Typically:
-**When a user logs into your app**
+1. User registers in your app → Create user in CometChat
+2. User logs into your app → [Log user into CometChat](/sdk/javascript/authentication-overview)
-1. You log in the user to your app
-2. You [log in the user in CometChat](/sdk/javascript/authentication-overview) (programmatically)
+## Creating a User
-## Creating a user
+User creation should ideally happen on your backend via the [REST API](https://api-explorer.cometchat.com/reference/creates-user).
-Ideally, user creation should take place at your backend. You can refer our Rest API to learn more about [creating a user](https://api-explorer.cometchat.com/reference/creates-user) and use the appropriate code sample based on your backend language.
+
+**Security:** Never expose your `Auth Key` in client-side production code. User creation and updates using `Auth Key` should ideally happen on your backend server. Use client-side creation only for prototyping or development.
+
-However, if you wish to create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful.
+For client-side creation (development only), use `createUser()`:
-```js
+```javascript
let authKey = "AUTH_KEY";
-var uid = "user1";
-var name = "Kevin";
+let uid = "user1";
+let name = "Kevin";
-var user = new CometChat.User(uid);
+let user = new CometChat.User(uid);
user.setName(name);
CometChat.createUser(user, authKey).then(
user => {
- console.log("user created", user);
+ console.log("user created", user);
}, error => {
- console.log("error", error);
+ console.log("error", error);
}
)
```
-
-
```typescript
let authKey: string = "AUTH_KEY";
-var uid: string = "user1";
-var name: string = "Kevin";
+let uid: string = "user1";
+let name: string = "Kevin";
-var user: CometChat.User = new CometChat.User(uid);
+let user: CometChat.User = new CometChat.User(uid);
user.setName(name);
CometChat.createUser(user, authKey).then(
(user: CometChat.User) => {
- console.log("user created", user);
+ console.log("user created", user);
}, (error: CometChat.CometChatException) => {
- console.log("error", error);
+ console.log("error", error);
}
);
```
-
-
+The method returns a [`User`](/sdk/reference/entities#user) object. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| avatar | `getAvatar()` | `string` | URL of the user's avatar image |
+| role | `getRole()` | `string` | Role assigned to the user |
+| status | `getStatus()` | `string` | Online status of the user |
+
UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.
-## Updating a user
+## Updating a User
-Updating a user similar to creating a user should ideally be achieved at your backend using the Restful APIs. For more information, you can check the [update a user](https://api-explorer.cometchat.com/reference/update-user) section. However, this can be achieved on the fly as well as using the `updateUser()` method. This method takes a `User` object and the `Auth Key` as inputs and returns the updated `User` object on the successful execution of the request.
+Like creation, user updates should ideally happen on your backend via the [REST API](https://api-explorer.cometchat.com/reference/update-user).
+
+For client-side updates (development only), use `updateUser()`:
-```js
+```javascript
let authKey = "AUTH_KEY";
let uid = "user1";
let name = "Kevin Fernandez";
-var user = new CometChat.User(uid);
+let user = new CometChat.User(uid);
user.setName(name);
CometChat.updateUser(user, authKey).then(
user => {
- console.log("user updated", user);
+ console.log("user updated", user);
}, error => {
- console.log("error", error);
+ console.log("error", error);
}
-)
+)
```
-
-
```typescript
let authKey: string = "AUTH_KEY";
-var uid: string = "user1";
-var name: string = "Kevin Fernandez";
+let uid: string = "user1";
+let name: string = "Kevin Fernandez";
-var user: CometChat.User = new CometChat.User(uid);
+let user: CometChat.User = new CometChat.User(uid);
user.setName(name);
CometChat.updateUser(user, authKey).then(
(user: CometChat.User) => {
- console.log("user updated", user);
+ console.log("user updated", user);
}, (error: CometChat.CometChatException) => {
- console.log("error", error);
+ console.log("error", error);
}
-)
+)
```
-
-
-Please make sure the `User` object provided to the `updateUser()` method has the `UID` of the user to be updated set.
+Ensure the `User` object has the correct `UID` set.
+
+The method returns a [`User`](/sdk/reference/entities#user) object. Access the response data using getter methods:
+
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| avatar | `getAvatar()` | `string` | URL of the user's avatar image |
+| role | `getRole()` | `string` | Role assigned to the user |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the user |
-## Updating logged-in user
+## Updating Logged-in User
-Updating a logged-in user is similar to updating a user. The only difference being this method does not require an AuthKey. This method takes a `User` object as input and returns the updated `User` object on the successful execution of the request.
+Use `updateCurrentUserDetails()` to update the current user without an Auth Key. Note: You cannot update the user's role with this method.
-```js
+```javascript
let uid = "user1";
let name = "Kevin Fernandez";
-var user = new CometChat.User(uid);
+let user = new CometChat.User(uid);
user.setName(name);
CometChat.updateCurrentUserDetails(user).then(
user => {
- console.log("user updated", user);
+ console.log("user updated", user);
}, error => {
- console.log("error", error);
+ console.log("error", error);
}
)
```
-
-
```typescript
-var uid: string = "user1";
-var name: string = "Kevin Fernandez";
+let uid: string = "user1";
+let name: string = "Kevin Fernandez";
-var user: CometChat.User = new CometChat.User(uid);
+let user: CometChat.User = new CometChat.User(uid);
user.setName(name);
CometChat.updateCurrentUserDetails(user).then(
(user: CometChat.User) => {
- console.log("user updated", user);
+ console.log("user updated", user);
}, (error: CometChat.CometChatException) => {
- console.log("error", error);
+ console.log("error", error);
}
);
```
-
-
-By using the `updateCurrentUserDetails()` method one can only update the logged-in user irrespective of the UID passed. Also, it is not possible to update the role of a logged-in user.
-
-## Deleting a user
+## Deleting a User
-Deleting a user can only be achieved via the Restful APIs. For more information please check the [delete a user](https://api-explorer.cometchat.com/reference/delete-user) section.
+User deletion is only available via the [REST API](https://api-explorer.cometchat.com/reference/delete-user).
## User Class
@@ -195,3 +218,20 @@ Deleting a user can only be achieved via the Restful APIs. For more information
| hasBlockedMe | No | A boolean that determines if the user has blocked the logged in user |
| blockedByMe | No | A boolean that determines if the logged in user has blocked the user |
| tags | Yes | A list of tags to identify specific users |
+
+## Next Steps
+
+
+
+ Fetch and filter user lists with pagination.
+
+
+ Monitor real-time online/offline status.
+
+
+ Block and unblock users.
+
+
+ Log users into CometChat.
+
+
diff --git a/sdk/javascript/user-presence.mdx b/sdk/javascript/user-presence.mdx
index 503bc0d6f..0b62bf35c 100644
--- a/sdk/javascript/user-presence.mdx
+++ b/sdk/javascript/user-presence.mdx
@@ -1,50 +1,67 @@
---
title: "User Presence"
-sidebarTitle: "Overview"
+sidebarTitle: "User Presence"
+description: "Track real-time user online/offline status and configure presence subscriptions using the CometChat JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+```javascript
+// Subscribe to presence during init
+const appSettings = new CometChat.AppSettingsBuilder()
+ .subscribePresenceForAllUsers() // or .subscribePresenceForRoles([]) / .subscribePresenceForFriends()
+ .setRegion("REGION").build();
-User Presence helps us understand if a user is available to chat or not.
+// Listen for presence changes
+CometChat.addUserListener("LISTENER_ID", new CometChat.UserListener({
+ onUserOnline: (user) => console.log("Online:", user),
+ onUserOffline: (user) => console.log("Offline:", user)
+}));
-## Real-time Presence
+// Remove listener
+CometChat.removeUserListener("LISTENER_ID");
+```
+
-*In other words, as a logged-in user, how do I know if a user is online or offline?*
+Track whether users are online or offline in real-time.
-Based on the settings provided in the AppSettings class while initialising the SDK using the `init()` method, the logged-in user will receive the presence for the other users in the app.
+## Real-time Presence
-In the `AppSettings` class, you can set the type of Presence you wish to receive for that particular session of the app.
+Configure presence subscription in `AppSettings` during SDK initialization. The `AppSettingsBuilder` provides three subscription options:
-For presence subscription, the AppSettingsBuilder provides 3 methods :
+| Method | Description |
+| ------ | ----------- |
+| `subscribePresenceForAllUsers()` | Receive presence updates for all users |
+| `subscribePresenceForRoles(roles)` | Receive presence updates only for users with specified roles |
+| `subscribePresenceForFriends()` | Receive presence updates only for friends |
-* `subscribePresenceForAllUsers()` - this will inform the logged-in user when any user in the app comes online or goes offline
-* `subscribePresenceForRoles(Array roles)` - This will inform the logged-in user, only when the users with the specified roles come online or go offline.
-* `subscribePresenceForFriends()` - This will inform the logged-in user, only when either of his friends come online or go offline.
+If none of these methods are called, no presence events will be delivered.
-If none of the above methods are used, no presence will be sent to the logged-in user.
+
+You must configure presence subscription in `AppSettings` during `CometChat.init()` before any presence events will be delivered. See [Setup SDK](/sdk/javascript/setup-sdk) for details.
+
-You need to register the `UserListener` using the `addUserListener()` method where ever you wish to receive these events in.
+Register a `UserListener` to receive presence events:
-
-```
+
+```javascript
let listenerID = "UNIQUE_LISTENER_ID";
CometChat.addUserListener(
-listenerID,
-new CometChat.UserListener({
- onUserOnline: onlineUser => {
- console.log("On User Online:", { onlineUser });
- },
- onUserOffline: offlineUser => {
- console.log("On User Offline:", { offlineUser });
- }
-})
-);
+ listenerID,
+ new CometChat.UserListener({
+ onUserOnline: onlineUser => {
+ console.log("On User Online:", { onlineUser });
+ },
+ onUserOffline: offlineUser => {
+ console.log("On User Offline:", { offlineUser });
+ }
+ })
+);
```
-
-
```typescript
let listenerID: string = "UNIQUE_LISTENER_ID";
@@ -52,58 +69,80 @@ let listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.addUserListener(
listenerID,
new CometChat.UserListener({
- onUserOnline: (onlineUser: CometChat.User) => {
- console.log("On User Online:", { onlineUser });
- },
- onUserOffline: (offlineUser: CometChat.User) => {
- console.log("On User Offline:", { offlineUser });
- }
+ onUserOnline: (onlineUser: CometChat.User) => {
+ console.log("On User Online:", { onlineUser });
+ },
+ onUserOffline: (offlineUser: CometChat.User) => {
+ console.log("On User Offline:", { offlineUser });
+ }
})
);
```
-
-
-| Parameter | Description |
-| ------------ | --------------------------------------------- |
-| `listenerID` | An ID that uniquely identifies that listener. |
+| Parameter | Description |
+| --------- | ----------- |
+| `listenerID` | Unique identifier for the listener |
-You will receive an object of the `User` class in the listener methods.
+Each callback receives a [`User`](/sdk/reference/entities#user) object with presence information.
-We recommend you remove the listener once the activity or view is not in use.
+The listener callbacks provide a [`User`](/sdk/reference/entities#user) object with presence fields populated. Access the response data using getter methods:
-We suggest adding this method when not in use.
+| Field | Getter | Return Type | Description |
+|-------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| status | `getStatus()` | `string` | Online status of the user (`"online"` or `"offline"`) |
+| lastActiveAt | `getLastActiveAt()` | `number` | Timestamp when the user was last active |
+
+Remove the listener when no longer needed:
-
-```
+
+```javascript
let listenerID = "UNIQUE_LISTENER_ID";
CometChat.removeUserListener(listenerID);
```
-
-
```typescript
let listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.removeUserListener(listenerID);
```
-
-
-## User List Presence
-
-*In other words, as a logged-in user, when I retrieve the user list, how do I know if a user is online/offline?*
-
-When you fetch the list of users, in the [User](/sdk/javascript/user-management#user-class) object, you will receive 2 fields
+
+Always remove your `UserListener` when the component or view unmounts to prevent memory leaks and duplicate event handling.
-1. `status` - This will hold either of the two values :
+```javascript
+CometChat.removeUserListener("LISTENER_ID");
+```
+
-* online - This indicates that the user is currently online and available to chat.
-* offline - This indicates that the user is currently offline and is not available to chat.
+## User List Presence
-2. `lastActiveAt` - in case the user is offline, this field holds the timestamp of the time when the user was last online. This can be used to display the Last seen of the user if need be.
+When fetching users via `UsersRequest`, each [`User`](/sdk/reference/entities#user) object includes presence fields:
+
+| Field | Description |
+| ----- | ----------- |
+| `status` | `"online"` or `"offline"` |
+| `lastActiveAt` | Timestamp of last activity (useful for "Last seen" display) |
+
+## Next Steps
+
+
+
+ Fetch user lists with filtering and pagination.
+
+
+ Create and update users programmatically.
+
+
+ Monitor SDK connection to CometChat servers.
+
+
+ Overview of all available real-time listeners.
+
+
diff --git a/sdk/javascript/users-overview.mdx b/sdk/javascript/users-overview.mdx
index 2193624f4..83062c071 100644
--- a/sdk/javascript/users-overview.mdx
+++ b/sdk/javascript/users-overview.mdx
@@ -1,10 +1,33 @@
---
title: "Users"
sidebarTitle: "Overview"
+description: "Overview of CometChat user functionality including user management, retrieval, and presence tracking in the JavaScript SDK."
---
+{/* TL;DR for Agents and Quick Reference */}
+
+- [User Management](/sdk/javascript/user-management) — Create and update users
+- [Retrieve Users](/sdk/javascript/retrieve-users) — Fetch and filter user lists
+- [User Presence](/sdk/javascript/user-presence) — Track online/offline status
+- [Block Users](/sdk/javascript/block-users) — Block and unblock users
+
-The primary aim for our Users functionality is to allow you to quickly retrieve and add users to CometChat.
+Sync your users to CometChat with [user management](/sdk/javascript/user-management), then [retrieve users](/sdk/javascript/retrieve-users) to display them in your app.
-You can begin with [user management](/sdk/javascript/user-management) to sync your users to CometChat. Once that is done, you can [retrieve users](/sdk/javascript/retrieve-users) and display them in your app.
+## Next Steps
+
+
+
+ Create, update, and delete users in CometChat.
+
+
+ Fetch user lists with filtering, sorting, and pagination.
+
+
+ Monitor real-time online/offline status of users.
+
+
+ Block and unblock users to control communication.
+
+
diff --git a/sdk/javascript/video-view-customisation.mdx b/sdk/javascript/video-view-customisation.mdx
index 5e3880224..84e242291 100644
--- a/sdk/javascript/video-view-customisation.mdx
+++ b/sdk/javascript/video-view-customisation.mdx
@@ -1,5 +1,6 @@
---
title: "Video View Customisation"
+sidebarTitle: "Video View Customisation"
description: "Customize the main video container in CometChat calls — aspect ratio, full screen button, name label, and network label positioning."
---
@@ -12,17 +13,15 @@ description: "Customize the main video container in CometChat calls — aspect r
- **Requires:** [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) setup
-This section will guide you to customise the main video container.
+Customize the main video container layout, including aspect ratio, button positions, and label visibility.
## Implementation
-Once you have decided to implement [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) calling and followed the steps to implement them. Just few additional methods will help you quickly customize the main video container.
-
-Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call).
+After setting up [Ringing](/sdk/javascript/default-call) or [Call Session](/sdk/javascript/direct-call), configure video view options in your call settings.
## Main Video Container Setting
-The `MainVideoContainerSetting` Class is the required in case you want to customise the main video view. You need to pass the Object of the `MainVideoContainerSetting` Class in the `setMainVideoContainerSetting()` method of the `CallSettingsBuilder`.
+The `MainVideoContainerSetting` class customizes the main video view. Pass a `MainVideoContainerSetting` instance to `setMainVideoContainerSetting()` in `CallSettingsBuilder`.
| Setting | Description |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -56,27 +55,6 @@ videoSettings.setNetworkLabelParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT
-
-
-
-| Practice | Details |
-| --- | --- |
-| Aspect ratio choice | Use `ASPECT_RATIO_CONTAIN` to show the full video without cropping; use `ASPECT_RATIO_COVER` for a full-bleed look that may crop edges |
-| Label positioning | Avoid placing the name label and network label in the same corner to prevent overlap |
-| Full screen button | Keep the full screen button visible for better UX; only hide it if your app provides its own full screen toggle |
-
-
-
-
-| Symptom | Cause | Fix |
-| --- | --- | --- |
-| Video settings not applied | `setMainVideoContainerSetting()` not called on `CallSettingsBuilder` | Pass the `MainVideoContainerSetting` object to `CallSettingsBuilder.setMainVideoContainerSetting()` before calling `startCall()` |
-| Labels overlapping | Multiple labels positioned in the same corner | Assign different position constants to each label |
-| Full screen button missing | Visibility set to `false` | Set the second parameter of `setFullScreenButtonParams()` to `true` |
-
-
-
-
## Next Steps
diff --git a/sdk/javascript/virtual-background.mdx b/sdk/javascript/virtual-background.mdx
index 0879041c1..f3f7a2a74 100644
--- a/sdk/javascript/virtual-background.mdx
+++ b/sdk/javascript/virtual-background.mdx
@@ -1,5 +1,6 @@
---
title: "Virtual Background"
+sidebarTitle: "Virtual Background"
description: "Implement virtual background features in CometChat video calls — background blur, custom images, and enforced backgrounds using the JavaScript SDK."
---
@@ -12,30 +13,22 @@ description: "Implement virtual background features in CometChat video calls —
- **Requires:** [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) setup
-This section will guide you to implement virtual background feature in video calls.
+Apply blur or custom image backgrounds during video calls.
## Implementation
-Once you have decided to implement [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) calling and followed the steps to implement them. Just few additional methods will help you quickly implement virtual background.
-
-Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call).
+After setting up [Ringing](/sdk/javascript/default-call) or [Call Session](/sdk/javascript/direct-call), configure virtual background options in your call settings.
## Settings
-The `CallSettings`class allows you to customise the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startCall()` method to start the call.
-
-The **mandatory** parameters that are required to be present for any call/conference to work are:
-
-1. sessionId - The unique session Id for the call/conference session.
-
-The options available for virtual background are:
+Configure virtual background using `CallSettingsBuilder`:
| Setting | Description |
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `showVirtualBackgroundSetting(showVBSettings: boolean)` | This method shows/hides the virtual background settings in the menu bar. **Default value = true** |
| `setVirtualBackground(virtualBackground: CometChat.VirtualBackground)` | This method will set the virtual background setting. This methods takes an Object of Virtual Background Class. |
-For the use case where you wish to align your own custom buttons and not use the default layout provided by CometChat, you can embed the buttons in your layout and use the below methods to perform the corresponding operations:
+For custom UI without the default layout, use these methods to control virtual background:
### Open Virtual Background Setting
@@ -100,7 +93,7 @@ callController.setBackgroundImage(imageURL);
## Virtual Background Settings
-The `VirtualBackground` Class is the required in case you want to change how the end user can use virtual background features in a video call. You need to pass the Object of the `VirtualBackground` Class in the `setVirtualBackground()` method of the `CallSettingsBuilder`.
+The `VirtualBackground` class controls how users interact with virtual background features. Pass a `VirtualBackground` instance to `setVirtualBackground()` in `CallSettingsBuilder`.
| Setting | Description |
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -111,30 +104,6 @@ The `VirtualBackground` Class is the required in case you want to change how the
| `enforceBackgroundBlur(enforceBackgroundBlur: number)` | This method starts the call with background blurred. To blur the background you need to pass an integer value between 1-99 which decides the blur level. **Default = 0** |
| `enforceBackgroundImage(enforceBackgroundImage: string)` | This methods starts the call with the provided background image. |
-
-
-
-| Practice | Details |
-| --- | --- |
-| Blur level range | Use values between 1-99 for `enforceBackgroundBlur()`. Higher values produce stronger blur. A value of 0 disables blur |
-| Image hosting | Host background images on a CDN for fast loading. Large images may cause lag when applied |
-| Enforce vs allow | Use `enforceBackgroundBlur()` or `enforceBackgroundImage()` when you want a mandatory background (e.g., for privacy). Use `allowBackgroundBlur()` and `allowUserImages()` to let users choose |
-| Custom buttons | Use `CallController` methods (`setBackgroundBlur`, `setBackgroundImage`, `openVirtualBackground`) when building a custom UI instead of the default CometChat menu |
-
-
-
-
-| Symptom | Cause | Fix |
-| --- | --- | --- |
-| Virtual background option not visible | `showVirtualBackgroundSetting(false)` was set | Set `showVirtualBackgroundSetting(true)` in `CallSettingsBuilder` |
-| Background blur not applied on call start | `enforceBackgroundBlur()` not set or set to 0 | Pass a value between 1-99 to `enforceBackgroundBlur()` |
-| Custom images not appearing | `setImages()` not called or empty array passed | Pass a non-empty array of valid image URLs to `setImages()` |
-| `CallController.getInstance()` returns null | Called before the call has started | Only use `CallController` methods after `startCall()` has been invoked |
-| User can't upload their own images | `allowUserImages(false)` was set | Set `allowUserImages(true)` in the `VirtualBackground` configuration |
-
-
-
-
## Next Steps
diff --git a/sdk/reference/auxiliary.mdx b/sdk/reference/auxiliary.mdx
new file mode 100644
index 000000000..da80ef3c5
--- /dev/null
+++ b/sdk/reference/auxiliary.mdx
@@ -0,0 +1,104 @@
+---
+title: "Auxiliary"
+sidebarTitle: "Auxiliary"
+description: "Class reference for auxiliary objects returned by CometChat SDK methods. Covers MessageReceipt, ReactionCount, ReactionEvent, TypingIndicator, TransientMessage, and Attachment."
+---
+
+This page documents the auxiliary classes used across all CometChat SDKs. These objects are returned by listener callbacks and specific SDK methods.
+
+All properties are accessed via getter methods.
+
+---
+
+## MessageReceipt
+
+`MessageReceipt` represents a delivery or read receipt for a message. It is received via the `onMessagesDelivered` and `onMessagesRead` listener callbacks.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| messageId | `getMessageId()` | `string` | ID of the message this receipt is for |
+| sender | `getSender()` | `User` | The user who triggered the receipt |
+| receiver | `getReceiver()` | `string` | UID or GUID of the receiver |
+| receiverType | `getReceiverType()` | `string` | Receiver type (`"user"` or `"group"`) |
+| receiptType | `getReceiptType()` | `string` | Type of receipt (`"read"`, `"delivery"`, `"readByAll"`, or `"deliveredToAll"`) |
+| timestamp | `getTimestamp()` | `string` | Timestamp of the receipt |
+| readAt | `getReadAt()` | `number` | Timestamp when the message was read (epoch seconds) |
+| deliveredAt | `getDeliveredAt()` | `number` | Timestamp when the message was delivered (epoch seconds) |
+
+---
+
+## ReactionCount
+
+`ReactionCount` represents the count of a specific reaction on a message. It is available via `getReactions()` on a `BaseMessage` object.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| reaction | `getReaction()` | `string` | The reaction emoji (e.g., `"😀"`, `"👍"`) |
+| count | `getCount()` | `number` | Number of users who reacted with this reaction |
+| reactedByMe | `getReactedByMe()` | `boolean` | Whether the logged-in user reacted with this reaction |
+
+---
+
+## ReactionEvent
+
+`ReactionEvent` represents a real-time reaction event. It is received via the `onMessageReactionAdded` and `onMessageReactionRemoved` listener callbacks.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| reaction | `getReaction()` | `Reaction` | The reaction details object |
+| receiverId | `getReceiverId()` | `string` | UID or GUID of the receiver |
+| receiverType | `getReceiverType()` | `string` | Receiver type (`"user"` or `"group"`) |
+| conversationId | `getConversationId()` | `string` | ID of the conversation |
+| parentMessageId | `getParentMessageId()` | `string` | ID of the parent message (if the reacted message is in a thread) |
+
+---
+
+## TypingIndicator
+
+`TypingIndicator` represents a typing event. It is received via the `onTypingStarted` and `onTypingEnded` listener callbacks.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| receiverId | `getReceiverId()` | `string` | UID or GUID of the receiver |
+| receiverType | `getReceiverType()` | `string` | Receiver type (`"user"` or `"group"`) |
+| sender | `getSender()` | `User` | The user who is typing |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the typing indicator |
+
+---
+
+## TransientMessage
+
+`TransientMessage` represents a transient (non-persistent) message. It is received via the `onTransientMessageReceived` listener callback. Transient messages are not stored on the server.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| receiverId | `getReceiverId()` | `string` | UID or GUID of the receiver |
+| receiverType | `getReceiverType()` | `string` | Receiver type (`"user"` or `"group"`) |
+| sender | `getSender()` | `User` | The user who sent the transient message |
+| data | `getData()` | `any` | Custom data payload of the transient message |
+
+---
+
+## Attachment
+
+`Attachment` represents a file attachment on a `MediaMessage`. It is available via `getAttachment()` or `getAttachments()` on a `MediaMessage` object.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| name | `getName()` | `string` | Name of the file |
+| extension | `getExtension()` | `string` | File extension (e.g., `"png"`, `"pdf"`) |
+| mimeType | `getMimeType()` | `string` | MIME type of the file (e.g., `"image/png"`) |
+| size | `getSize()` | `number` | Size of the file in bytes |
+| url | `getUrl()` | `string` | URL to download the file |
diff --git a/sdk/reference/entities.mdx b/sdk/reference/entities.mdx
new file mode 100644
index 000000000..2d5588aa8
--- /dev/null
+++ b/sdk/reference/entities.mdx
@@ -0,0 +1,109 @@
+---
+title: "Entities"
+sidebarTitle: "Entities"
+description: "Class reference for entity objects returned by CometChat SDK methods. Covers User, Group, Conversation, and GroupMember."
+---
+
+This page documents the entity classes used across all CometChat SDKs. All entity objects share the same structure regardless of platform.
+
+All properties are accessed via getter methods.
+
+---
+
+## User
+
+`User` represents a CometChat user. It is returned by methods like `CometChat.login()`, `CometChat.getUser()`, and user list requests.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| uid | `getUid()` | `string` | Unique user ID |
+| name | `getName()` | `string` | Display name of the user |
+| avatar | `getAvatar()` | `string` | URL of the user's avatar image |
+| link | `getLink()` | `string` | URL link associated with the user |
+| role | `getRole()` | `string` | Role assigned to the user |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the user |
+| status | `getStatus()` | `string` | Online status of the user (`"online"` or `"offline"`) |
+| statusMessage | `getStatusMessage()` | `string` | Custom status message set by the user |
+| lastActiveAt | `getLastActiveAt()` | `number` | Timestamp when the user was last active (epoch seconds) |
+| tags | `getTags()` | `string[]` | Tags associated with the user |
+| deactivatedAt | `getDeactivatedAt()` | `number` | Timestamp when the user was deactivated (epoch seconds) |
+
+### Conditional Properties
+
+These properties may or may not be populated depending on the method or request configuration used.
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| hasBlockedMe | `getHasBlockedMe()` | `boolean` | Whether this user has blocked the logged-in user |
+| blockedByMe | `getBlockedByMe()` | `boolean` | Whether the logged-in user has blocked this user |
+| authToken | `getAuthToken()` | `string` | Auth token of the user (only available after login) |
+
+---
+
+## Group
+
+`Group` represents a CometChat group. It is returned by methods like `CometChat.createGroup()`, `CometChat.getGroup()`, and group list requests.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| guid | `getGuid()` | `string` | Unique group ID |
+| name | `getName()` | `string` | Display name of the group |
+| type | `getType()` | `string` | Group type (`"public"`, `"private"`, or `"password"`) |
+| icon | `getIcon()` | `string` | URL of the group icon |
+| description | `getDescription()` | `string` | Description of the group |
+| owner | `getOwner()` | `string` | UID of the group owner |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the group |
+| createdAt | `getCreatedAt()` | `number` | Timestamp when the group was created (epoch seconds) |
+| updatedAt | `getUpdatedAt()` | `number` | Timestamp when the group was last updated (epoch seconds) |
+| hasJoined | `getHasJoined()` | `boolean` | Whether the logged-in user has joined this group |
+| scope | `getScope()` | `string` | Scope of the logged-in user in the group (`"admin"`, `"moderator"`, or `"participant"`) |
+| joinedAt | `getJoinedAt()` | `string` | Timestamp when the logged-in user joined the group |
+| membersCount | `getMembersCount()` | `number` | Total number of members in the group |
+| tags | `getTags()` | `string[]` | Tags associated with the group |
+
+### Conditional Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| password | `getPassword()` | `string` | Group password (only for password-protected groups, only available during creation) |
+| isBanned | `isBannedFromGroup()` | `boolean` | Whether the logged-in user is banned from the group |
+
+---
+
+## Conversation
+
+`Conversation` represents a chat conversation. It is returned by `CometChat.getConversation()` and conversation list requests.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| conversationId | `getConversationId()` | `string` | Unique conversation ID |
+| conversationType | `getConversationType()` | `string` | Type of conversation (`"user"` or `"group"`) |
+| lastMessage | `getLastMessage()` | `BaseMessage` | The last message in the conversation |
+| conversationWith | `getConversationWith()` | `User` \| `Group` | The user or group this conversation is with |
+| unreadMessageCount | `getUnreadMessageCount()` | `number` | Number of unread messages in the conversation |
+| unreadMentionsCount | `getUnreadMentionsCount()` | `number` | Number of unread mentions in the conversation |
+| lastReadMessageId | `getLastReadMessageId()` | `string` | ID of the last message read by the logged-in user |
+| latestMessageId | `getLatestMessageId()` | `string` | ID of the latest message in the conversation |
+| tags | `getTags()` | `string[]` | Tags associated with the conversation |
+
+---
+
+## GroupMember
+
+`GroupMember` extends [User](#user) and represents a member of a CometChat group. It is returned by group member list requests.
+
+It inherits all properties from `User` and adds the following.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| scope | `getScope()` | `string` | Scope of the member in the group (`"admin"`, `"moderator"`, or `"participant"`) |
+| joinedAt | `getJoinedAt()` | `number` | Timestamp when the member joined the group (epoch seconds) |
+| guid | `getGuid()` | `string` | GUID of the group this member belongs to |
diff --git a/sdk/reference/messages.mdx b/sdk/reference/messages.mdx
new file mode 100644
index 000000000..93626688f
--- /dev/null
+++ b/sdk/reference/messages.mdx
@@ -0,0 +1,218 @@
+---
+title: "Messages"
+sidebarTitle: "Messages"
+description: "Class reference for message objects returned by CometChat SDK methods. Covers BaseMessage and its subclasses like TextMessage."
+---
+
+This page documents the message classes used across all CometChat SDKs. All message objects share the same structure regardless of platform.
+
+All properties are accessed via getter methods.
+
+## Class Hierarchy
+
+```
+BaseMessage
+├── TextMessage
+├── MediaMessage
+├── CustomMessage
+├── InteractiveMessage
+└── Action
+```
+
+---
+
+## BaseMessage
+
+`BaseMessage` is the base class for all message types. Every message object — whether it's a text message, media message, or custom message — extends this class.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| id | `getId()` | `number` | Unique message ID |
+| conversationId | `getConversationId()` | `string` | ID of the conversation this message belongs to |
+| parentMessageId | `getParentMessageId()` | `number` | ID of the parent message (for threaded messages) |
+| muid | `getMuid()` | `string` | Client-generated unique message ID |
+| sender | `getSender()` | `User` | Sender of the message |
+| receiver | `getReceiver()` | `User` \| `Group` | Receiver of the message |
+| receiverId | `getReceiverId()` | `string` | UID/GUID of the receiver |
+| type | `getType()` | `string` | Message type (e.g., `"text"`, `"image"`, `"file"`, `"custom"`) |
+| receiverType | `getReceiverType()` | `string` | Receiver type (`"user"` or `"group"`) |
+| category | `getCategory()` | `MessageCategory` | Message category (e.g., `"message"`, `"action"`, `"call"`, `"custom"`) |
+| sentAt | `getSentAt()` | `number` | Timestamp when the message was sent (epoch seconds) |
+| deliveredAt | `getDeliveredAt()` | `number` | Timestamp when the message was delivered |
+| readAt | `getReadAt()` | `number` | Timestamp when the message was read |
+| deliveredToMeAt | `getDeliveredToMeAt()` | `number` | Timestamp when the message was delivered to the logged-in user |
+| readByMeAt | `getReadByMeAt()` | `number` | Timestamp when the message was read by the logged-in user |
+| editedAt | `getEditedAt()` | `number` | Timestamp when the message was edited |
+| editedBy | `getEditedBy()` | `string` | UID of the user who edited the message |
+| deletedAt | `getDeletedAt()` | `number` | Timestamp when the message was deleted |
+| deletedBy | `getDeletedBy()` | `string` | UID of the user who deleted the message |
+| replyCount | `getReplyCount()` | `number` | Number of replies to this message |
+| unreadRepliesCount | `getUnreadRepliesCount()` | `number` | Number of unread replies |
+| data | `getData()` | `Object` | Raw data payload of the message |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the message |
+| rawMessage | `getRawMessage()` | `Object` | Raw JSON of the message as received from the server |
+
+### Conditional Properties
+
+These properties may or may not be populated depending on the method or request configuration used to fetch the message.
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| reactions | `getReactions()` | `ReactionCount[]` | Array of reaction counts on the message |
+| mentionedUsers | `getMentionedUsers()` | `User[]` | Array of users mentioned in the message |
+| hasMentionedMe | `hasMentionedMe()` | `boolean` | Whether the logged-in user was mentioned in the message |
+| quotedMessageId | `getQuotedMessageId()` | `number` | ID of the quoted message (if this is a reply) |
+| quotedMessage | `getQuotedMessage()` | `BaseMessage` | The quoted message object (if this is a reply) |
+
+---
+
+## TextMessage
+
+`TextMessage` extends [BaseMessage](#basemessage) and represents a text-based chat message.
+
+It inherits all properties from `BaseMessage` and adds the following.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| text | `getText()` | `string` | The text content of the message |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the message (includes extension data like data masking, link preview, etc.) |
+| data | `getData()` | `Object` | Raw data payload including `text`, `resource`, `metadata`, `moderation`, and `entities` |
+| moderationStatus | `getModerationStatus()` | `ModerationStatus` | Moderation status of the message. Returns `"unmoderated"` if not moderated. |
+
+### Conditional Properties
+
+These properties may or may not be populated depending on the method or request configuration used to fetch the message.
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| tags | `getTags()` | `string[]` | Tags associated with the message |
+
+---
+
+## MediaMessage
+
+`MediaMessage` extends [BaseMessage](#basemessage) and represents a message with media attachments such as images, videos, audio files, or documents.
+
+It inherits all properties from `BaseMessage` and adds the following.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| caption | `getCaption()` | `string` | Caption text for the media message |
+| attachment | `getAttachment()` | `Attachment` | The primary attachment of the media message |
+| attachments | `getAttachments()` | `Attachment[]` | All attachments of the media message |
+| url | `getURL()` | `string` | URL of the media file |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the message |
+| data | `getData()` | `Object` | Raw data payload of the message |
+| moderationStatus | `getModerationStatus()` | `ModerationStatus` | Moderation status of the message. Returns `"unmoderated"` if not moderated. |
+
+### Conditional Properties
+
+These properties may or may not be populated depending on the method or request configuration used to fetch the message.
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| tags | `getTags()` | `string[]` | Tags associated with the message |
+
+---
+
+## CustomMessage
+
+`CustomMessage` extends [BaseMessage](#basemessage) and represents a developer-defined message with a custom data payload.
+
+It inherits all properties from `BaseMessage` and adds the following.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| customData | `getCustomData()` | `Object` | The custom data payload set by the developer |
+| subType | `getSubType()` | `string` | Sub type of the custom message |
+| conversationText | `getConversationText()` | `string` | Preview text displayed in the conversation list |
+| updateConversation | `willUpdateConversation()` | `boolean` | Whether this message updates the conversation's last message |
+| sendNotification | `willSendNotification()` | `boolean` | Whether a push notification is sent for this message |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the message |
+| data | `getData()` | `Object` | Raw data payload of the message |
+
+### Conditional Properties
+
+These properties may or may not be populated depending on the method or request configuration used to fetch the message.
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| tags | `getTags()` | `string[]` | Tags associated with the message |
+
+---
+
+## InteractiveMessage
+
+`InteractiveMessage` extends [BaseMessage](#basemessage) and represents a message with interactive UI elements such as forms, cards, or buttons.
+
+It inherits all properties from `BaseMessage` and adds the following.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| interactiveData | `getInteractiveData()` | `Object` | The interactive element data (form fields, buttons, etc.) |
+| interactionGoal | `getInteractionGoal()` | `InteractionGoal` | The goal that defines when the interaction is considered complete |
+| interactions | `getInteractions()` | `Interaction[]` | Array of interactions that have occurred on this message |
+| allowSenderInteraction | `getIsSenderInteractionAllowed()` | `boolean` | Whether the sender is allowed to interact with the message |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the message |
+| data | `getData()` | `Object` | Raw data payload of the message |
+
+### Conditional Properties
+
+These properties may or may not be populated depending on the method or request configuration used to fetch the message.
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| tags | `getTags()` | `string[]` | Tags associated with the message |
+
+---
+
+## Action
+
+`Action` extends [BaseMessage](#basemessage) and represents a system-generated action message such as a member joining, leaving, or being banned from a group.
+
+It inherits all properties from `BaseMessage` and adds the following.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| action | `getAction()` | `string` | The action being performed (e.g., `"joined"`, `"left"`, `"kicked"`, `"banned"`) |
+| message | `getMessage()` | `string` | The default human-readable action message |
+| actionBy | `getActionBy()` | `User` \| `Group` \| `BaseMessage` | The entity that performed the action |
+| actionOn | `getActionOn()` | `User` \| `Group` \| `BaseMessage` | The entity on which the action was performed |
+| actionFor | `getActionFor()` | `User` \| `Group` \| `BaseMessage` | The entity for whom the action was performed |
+| oldScope | `getOldScope()` | `string` | Previous scope of the member (for scope change actions) |
+| newScope | `getNewScope()` | `string` | New scope of the member (for scope change actions) |
+| rawData | `getRawData()` | `Object` | Raw JSON data of the action message |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the action message |
+
+---
+
+## Call
+
+`Call` extends [BaseMessage](#basemessage) and represents a voice or video call message.
+
+It inherits all properties from `BaseMessage` and adds the following.
+
+### Properties
+
+| Property | Getter | Return Type | Description |
+|----------|--------|-------------|-------------|
+| sessionId | `getSessionId()` | `string` | Unique session ID of the call |
+| callInitiator | `getCallInitiator()` | `User` | The user who initiated the call |
+| callReceiver | `getCallReceiver()` | `User` \| `Group` | The user or group receiving the call |
+| action | `getAction()` | `string` | The call action (e.g., `"initiated"`, `"ongoing"`, `"ended"`, `"cancelled"`, `"rejected"`) |
+| initiatedAt | `getInitiatedAt()` | `number` | Timestamp when the call was initiated |
+| joinedAt | `getJoinedAt()` | `number` | Timestamp when the call was joined |
+| rawData | `getRawData()` | `Object` | Raw JSON data of the call message |
+| metadata | `getMetadata()` | `Object` | Custom metadata attached to the call message |