Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sdk/javascript/ai-agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
description: "Handle CometChat AI Agent events, tool calls, and agent messages in JavaScript apps."
---

<Accordion title="AI Integration Quick Reference">

| Field | Value |
| --- | --- |
| Package | `@cometchat/chat-sdk-javascript` |
| Import | `import { CometChat } from "@cometchat/chat-sdk-javascript";` |
| Key methods | `CometChat.addAIAssistantListener(listenerId, ...)` · `CometChat.removeAIAssistantListener(listenerId)` · `CometChat.addMessageListener(listenerId, ...)` · `CometChat.removeMessageListener(listenerId)` |
| Key classes | `CometChat.AIAssistantBaseEvent` · `CometChat.AIAssistantMessage` · `CometChat.AIToolResultMessage` · `CometChat.AIToolArgumentMessage` · `CometChat.AIToolCall` |
| Primary output | Real-time run events are delivered as `CometChat.AIAssistantBaseEvent` objects to the `onAIAssistantEventReceived` callback; after the run completes, persisted `AIAssistantMessage` / `AIToolResultMessage` / `AIToolArgumentMessage` objects arrive on the `MessageListener` |
| Listeners registered | `AIAssistantListener` via `addAIAssistantListener` / `removeAIAssistantListener` (callback `onAIAssistantEventReceived`); `CometChat.MessageListener` via `addMessageListener` / `removeMessageListener` (callbacks `onAIAssistantMessageReceived`, `onAIToolResultReceived`, `onAIToolArgumentsReceived`) |
| Prerequisites | SDK initialized via [`CometChat.init()`](/sdk/javascript/setup-sdk) and a logged-in user via [`CometChat.login()`](/sdk/javascript/authentication-overview) |
| Constraints | Agents only respond to text messages. `Run Start` and `Run Finished` events are always emitted; Tool Call events only appear when tools are invoked |
| Related | [AI Moderation](/sdk/javascript/ai-moderation) · [AI User Copilot](/sdk/javascript/ai-user-copilot-overview) · [Card Messages](/sdk/javascript/card-messages) · [Send a Message](/sdk/javascript/send-message) |
| Full reference | [`AIAssistantBaseEvent`](/sdk/reference/messages#aiassistantbaseevent) · [`AIAssistantMessage`](/sdk/reference/messages#aiassistantmessage) · [`AIToolResultMessage`](/sdk/reference/messages#aitoolresultmessage) · [`AIToolArgumentMessage`](/sdk/reference/messages#aitoolargumentmessage) |

</Accordion>

## 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).
Expand All @@ -14,7 +31,7 @@
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`

Check warning on line 34 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L34

Did you really mean 'Agentic'?

### Real-time Events

Expand Down Expand Up @@ -67,7 +84,7 @@
<Tabs>
<Tab title="TypeScript">
```ts
const listnerId: string = "unique_listener_id";

Check warning on line 87 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L87

Did you really mean 'listnerId'?

Check warning on line 87 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L87

Did you really mean 'unique_listener_id'?

// Adding the AIAssistantListener
CometChat.addAIAssistantListener(listnerId, {
Expand All @@ -84,7 +101,7 @@

<Tab title="JavaScript">
```ts
const listnerId: string = "unique_listener_id";

Check warning on line 104 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L104

Did you really mean 'listnerId'?

Check warning on line 104 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L104

Did you really mean 'unique_listener_id'?

// Adding the AIAssistantListener
CometChat.addAIAssistantListener(listnerId, {
Expand Down Expand Up @@ -113,7 +130,7 @@
- Text Message End: The agent reply is complete.
- Run Finished: The run is finalized; persisted messages will follow.

### Agentic Messages

Check warning on line 133 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L133

Did you really mean 'Agentic'?

After the run completes, these messages arrive via `MessageListener`:

Expand All @@ -123,7 +140,7 @@
| `AIToolResultMessage` | The final output of a tool call |
| `AIToolArgumentMessage` | The arguments passed to a tool |

Each message type extends [`BaseMessage`](/sdk/reference/messages#basemessage) and has a typed data accessor:

Check warning on line 143 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L143

Did you really mean 'accessor'?

| Message Type | Data Getter | Data Properties |
| ----------------------- | ------------------------------ | ------------------------------------------------------------- |
Expand Down Expand Up @@ -198,7 +215,7 @@

<Warning>
Always remove listeners when they're no longer needed (e.g., on component
unmount or page navigation). Failing to remove listeners can cause memory

Check warning on line 218 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L218

Did you really mean 'unmount'?
leaks and duplicate event handling.
</Warning>

Expand All @@ -208,7 +225,7 @@

<CardGroup cols={2}>
<Card title="AI Chatbots" icon="robot" href="https://assets.cometchat.io/legacy-docs/ai-chatbots/ai-bots/overview.html">
Set up AI-powered chatbots for automated conversations

Check warning on line 228 in sdk/javascript/ai-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/ai-agents.mdx#L228

Did you really mean 'chatbots'?
</Card>
<Card
title="AI Moderation"
Expand Down
17 changes: 17 additions & 0 deletions sdk/javascript/all-real-time-listeners.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
description: "Use CometChat real-time listeners for user presence, groups, messages, calls, AI assistant events, and ongoing calls."
---

<Accordion title="AI Integration Quick Reference">

| Field | Value |
| --- | --- |
| Package | `@cometchat/chat-sdk-javascript` |
| Import | `import { CometChat } from "@cometchat/chat-sdk-javascript";` |
| Key methods | `CometChat.addUserListener(id, new CometChat.UserListener({...}))` · `CometChat.addGroupListener(id, new CometChat.GroupListener({...}))` · `CometChat.addMessageListener(id, new CometChat.MessageListener({...}))` · `CometChat.addCallListener(id, new CometChat.CallListener({...}))` · `CometChat.addAIAssistantListener(id, new CometChat.AIAssistantListener({...}))` · `CometChat.addLoginListener(id, new CometChat.LoginListener({...}))` · `CometChat.addConnectionListener(id, new CometChat.ConnectionListener({...}))` |
| Key classes | `CometChat.UserListener` · `CometChat.GroupListener` · `CometChat.MessageListener` · `CometChat.CallListener` · `CometChat.AIAssistantListener` · `CometChat.LoginListener` · `CometChat.ConnectionListener` |
| Primary output | Each listener fires typed callbacks — e.g. `onUserOnline(user)`, `onGroupMemberJoined(action, user, group)`, `onTextMessageReceived(message)`, `onMessagesDelivered(receipt)`, `onIncomingCallReceived(call)`, `onAIAssistantEventReceived(event)`, `loginSuccess(user)`, `onConnected()` |
| Listeners registered | `UserListener` (`onUserOnline` · `onUserOffline`); `GroupListener` (`onGroupMemberJoined` · `onGroupMemberLeft` · `onGroupMemberKicked` · `onGroupMemberBanned` · `onGroupMemberUnbanned` · `onGroupMemberScopeChanged` · `onMemberAddedToGroup`); `MessageListener` (`onTextMessageReceived` · `onMediaMessageReceived` · `onCustomMessageReceived` · `onTypingStarted` · `onTypingEnded` · `onMessagesDelivered` · `onMessagesRead` · `onMessageEdited` · `onMessageDeleted` · `onMessageReactionAdded` · `onCardMessageReceived` · `onAIAssistantMessageReceived`); `CallListener` (`onIncomingCallReceived` · `onOutgoingCallAccepted` · `onOutgoingCallRejected` · `onIncomingCallCancelled` · `onCallEndedMessageReceived`); `AIAssistantListener` (`onAIAssistantEventReceived`); `LoginListener` (`loginSuccess` · `loginFailure` · `logoutSuccess` · `logoutFailure`); `ConnectionListener` (`onConnected` · `inConnecting` · `onDisconnected` · `onFeatureThrottled`). Remove each with the matching `remove*Listener(id)` |
| Prerequisites | SDK initialized via [`CometChat.init()`](/sdk/javascript/setup-sdk) and a logged-in user via [`CometChat.login()`](/sdk/javascript/authentication-overview) |
| Constraints | Listener IDs must be unique per listener; use the same ID to remove it. Always call the matching `remove*Listener(id)` on unmount to avoid memory leaks and duplicate handling. `OngoingCallListener` belongs to the **Calls SDK** (not the Chat SDK) and is used via `CometChatCalls.addCallEventListener()` |

Check warning on line 17 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L17

Did you really mean 'unmount'?
| Related | [Receive a Message](/sdk/javascript/receive-message) · [Delivery & Read Receipts](/sdk/javascript/delivery-read-receipts) · [Typing Indicators](/sdk/javascript/typing-indicators) · [User Presence](/sdk/javascript/user-presence) |
| Full reference | [`User`](/sdk/reference/entities#user) · [`MessageReceipt`](/sdk/reference/auxiliary#messagereceipt) · [`AIAssistantBaseEvent`](/sdk/reference/messages#aiassistantbaseevent) · [`CometChatException`](/sdk/reference/auxiliary#cometchatexception) |

</Accordion>

CometChat provides 4 listeners viz.

1. [User Listener](/sdk/javascript/all-real-time-listeners#user-listener)
Expand Down Expand Up @@ -34,9 +51,9 @@
/* when someuser/friend comes online, user will be received here */
console.log("On User Online:", { onlineUser });
},
onUserOffline: (offlineUser: CometChat.User) => {

Check warning on line 54 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L54

Did you really mean 'offlineUser'?
/* when someuser/friend went offline, user will be received here */
console.log("On User Offline:", { offlineUser });

Check warning on line 56 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L56

Did you really mean 'offlineUser'?
},
})
);
Expand Down Expand Up @@ -91,13 +108,13 @@

| Method | Information |
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| **onGroupMemberJoined(action: CometChat.Action, joinedUser: CometChat.User, joinedGroup: CometChat.Group)** | This method is triggered when a user joins any group. All the members present in the group will receive this event. |

Check warning on line 111 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L111

Did you really mean 'joinedUser'?

Check warning on line 111 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L111

Did you really mean 'joinedGroup'?
| **onGroupMemberLeft(action: CometChat.Action, leftUser: CometChat.User, leftGroup: CometChat.Group)** | This method is triggered when a user who was a member of any group leaves the group. All the members of the group receive this event. |

Check warning on line 112 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L112

Did you really mean 'leftUser'?

Check warning on line 112 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L112

Did you really mean 'leftGroup'?
| **onGroupMemberKicked(action: CometChat.Action, kickedUser: CometChat.User, kickedBy: CometChat.User, kickedFrom: CometChat.Group)** | This method is triggered when a user is kicked from a group. All the members including the user receive this event |

Check warning on line 113 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L113

Did you really mean 'kickedUser'?

Check warning on line 113 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L113

Did you really mean 'kickedBy'?

Check warning on line 113 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L113

Did you really mean 'kickedFrom'?
| **onGroupMemberBanned(action: CometChat.Action, bannedUser: CometChat.User, bannedBy: CometChat.User, bannedFrom: CometChat.Group)** | This method is triggered when a user is banned from a group. All the members including the user receive this event |

Check warning on line 114 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L114

Did you really mean 'bannedUser'?

Check warning on line 114 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L114

Did you really mean 'bannedBy'?

Check warning on line 114 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L114

Did you really mean 'bannedFrom'?
| **onGroupMemberUnbanned(action: CometChat.Action, unbannedUser: CometChat.User, unbannedBy: CometChat.User, unbannedFrom: CometChat.Group)** | This method is triggered when a user is banned from a group. All the members of the group receive this event. |

Check warning on line 115 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L115

Did you really mean 'unbannedUser'?

Check warning on line 115 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L115

Did you really mean 'unbannedBy'?

Check warning on line 115 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L115

Did you really mean 'unbannedFrom'?
| **onGroupMemberScopeChanged(action: CometChat.Action, changedUser: CometChat.User, newScope: string, oldScope: string, changedGroup: CometChat.Group)** | This method is triggered when the scope of any Group Member has been changed. All the members that are a part of that group receive this event |

Check warning on line 116 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L116

Did you really mean 'changedUser'?

Check warning on line 116 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L116

Did you really mean 'newScope'?

Check warning on line 116 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L116

Did you really mean 'oldScope'?

Check warning on line 116 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L116

Did you really mean 'changedGroup'?
| **onMemberAddedToGroup(action: CometChat.Action, userAdded: CometChat.User, addedBy: CometChat.User, addedTo: CometChat.Group)** | This method is triggered when a user is added to any group. All the members including the user himself receive this event. |

Check warning on line 117 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L117

Did you really mean 'userAdded'?

Check warning on line 117 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L117

Did you really mean 'addedBy'?

Check warning on line 117 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L117

Did you really mean 'addedTo'?

To add the `GroupListener`:

Expand All @@ -116,76 +133,76 @@
},
onGroupMemberLeft: (
message: CometChat.Action,
leftUser: CometChat.User,

Check warning on line 136 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L136

Did you really mean 'leftUser'?
leftGroup: CometChat.Group

Check warning on line 137 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L137

Did you really mean 'leftGroup'?
) => {
console.log("onGroupMemberLeft", { message, leftUser, leftGroup });

Check warning on line 139 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L139

Did you really mean 'leftUser'?

Check warning on line 139 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L139

Did you really mean 'leftGroup'?
},
onGroupMemberKicked: (
message: CometChat.Action,
kickedUser: CometChat.User,

Check warning on line 143 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L143

Did you really mean 'kickedUser'?
kickedBy: CometChat.User,

Check warning on line 144 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L144

Did you really mean 'kickedBy'?
kickedFrom: CometChat.Group

Check warning on line 145 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L145

Did you really mean 'kickedFrom'?
) => {
console.log("onGroupMemberKicked", {
message,
kickedUser,

Check warning on line 149 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L149

Did you really mean 'kickedUser'?
kickedBy,

Check warning on line 150 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L150

Did you really mean 'kickedBy'?
kickedFrom,

Check warning on line 151 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L151

Did you really mean 'kickedFrom'?
});
},
onGroupMemberBanned: (
message: CometChat.Action,
bannedUser: CometChat.User,

Check warning on line 156 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L156

Did you really mean 'bannedUser'?
bannedBy: CometChat.User,

Check warning on line 157 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L157

Did you really mean 'bannedBy'?
bannedFrom: CometChat.Group

Check warning on line 158 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L158

Did you really mean 'bannedFrom'?
) => {
console.log("onGroupMemberBanned", {
message,
bannedUser,

Check warning on line 162 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L162

Did you really mean 'bannedUser'?
bannedBy,

Check warning on line 163 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L163

Did you really mean 'bannedBy'?
bannedFrom,

Check warning on line 164 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L164

Did you really mean 'bannedFrom'?
});
},
onGroupMemberUnbanned: (
message: CometChat.Action,
unbannedUser: CometChat.User,

Check warning on line 169 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L169

Did you really mean 'unbannedUser'?
unbannedBy: CometChat.User,

Check warning on line 170 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L170

Did you really mean 'unbannedBy'?
unbannedFrom: CometChat.Group

Check warning on line 171 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L171

Did you really mean 'unbannedFrom'?
) => {
console.log("onGroupMemberUnbanned", {
message,
unbannedUser,

Check warning on line 175 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L175

Did you really mean 'unbannedUser'?
unbannedBy,

Check warning on line 176 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L176

Did you really mean 'unbannedBy'?
unbannedFrom,

Check warning on line 177 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L177

Did you really mean 'unbannedFrom'?
});
},
onGroupMemberScopeChanged: (
message: CometChat.Action,
changedUser: CometChat.User,

Check warning on line 182 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L182

Did you really mean 'changedUser'?
newScope: string,

Check warning on line 183 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L183

Did you really mean 'newScope'?
oldScope: string,

Check warning on line 184 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L184

Did you really mean 'oldScope'?
changedGroup: CometChat.Group

Check warning on line 185 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L185

Did you really mean 'changedGroup'?
) => {
console.log("onGroupMemberScopeChanged", {
message,
changedUser,

Check warning on line 189 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L189

Did you really mean 'changedUser'?
newScope,

Check warning on line 190 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L190

Did you really mean 'newScope'?
oldScope,

Check warning on line 191 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L191

Did you really mean 'oldScope'?
changedGroup,

Check warning on line 192 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L192

Did you really mean 'changedGroup'?
});
},
onMemberAddedToGroup: (
message: CometChat.Action,
userAdded: CometChat.User,

Check warning on line 197 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L197

Did you really mean 'userAdded'?
addedby: CometChat.User,

Check warning on line 198 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L198

Did you really mean 'addedby'?
addedTo: CometChat.Group

Check warning on line 199 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L199

Did you really mean 'addedTo'?
) => {
console.log("onMemberAddedToGroup", {
message,
userAdded,

Check warning on line 203 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L203

Did you really mean 'userAdded'?
addedby,

Check warning on line 204 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L204

Did you really mean 'addedby'?
addedTo,

Check warning on line 205 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L205

Did you really mean 'addedTo'?
});
},
})
Expand Down Expand Up @@ -323,23 +340,23 @@
onTextMessageReceived: (textMessage: CometChat.TextMessage) => {
console.log("Text message received successfully", textMessage);
},
onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => {

Check warning on line 343 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L343

Did you really mean 'mediaMessage'?
console.log("Media message received successfully", mediaMessage);

Check warning on line 344 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L344

Did you really mean 'mediaMessage'?
},
onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => {

Check warning on line 346 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L346

Did you really mean 'customMessage'?
console.log("Custom message received successfully", customMessage);

Check warning on line 347 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L347

Did you really mean 'customMessage'?
},
onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => {

Check warning on line 349 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L349

Did you really mean 'messageReceipt'?
console.log("Message Delivered", messageReceipt);

Check warning on line 350 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L350

Did you really mean 'messageReceipt'?
},
onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => {

Check warning on line 352 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L352

Did you really mean 'messageReceipt'?
console.log("Message Read", messageReceipt);

Check warning on line 353 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L353

Did you really mean 'messageReceipt'?
},
onTypingStarted: (typingIndicator: CometChat.TypingIndicator) => {

Check warning on line 355 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L355

Did you really mean 'typingIndicator'?
console.log("Typing Started", typingIndicator);

Check warning on line 356 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L356

Did you really mean 'typingIndicator'?
},
onTypingEnded: (typingIndicator: CometChat.TypingIndicator) => {
console.log("Typing Ended", typingIndicator);

Check warning on line 359 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L359

Did you really mean 'typingIndicator'?
},
onMessageDeleted: (message: CometChat.BaseMessage) => {
console.log("Message Delted", message);
Expand All @@ -360,10 +377,10 @@
console.log("Message Moderated", message);
},
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
console.log("Message Delivered to All", messageReceipt);

Check warning on line 380 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L380

Did you really mean 'messageReceipt'?
},
onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => {
console.log("Message Read by All", messageReceipt);

Check warning on line 383 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L383

Did you really mean 'messageReceipt'?
},
onAIAssistantMessageReceived: (message: CometChat.AIAssistantMessage) => {
console.log("AI Assistant message received", message);
Expand Down Expand Up @@ -695,7 +712,7 @@
| `event.user.name` | `string` | Name of the user who started recording |
| `event.user.uid` | `string` | UID of the user who started recording |

**`onRecordingStopped()`**, **`onCallEnded()`**, **`onSessionTimeout()`**, **`onCallEndButtonPressed()`**, **`onScreenShareStarted()`**, **`onScreenShareStopped()`** — receive no arguments.

Check warning on line 715 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L715

Did you really mean 'listenerId'?

<Tabs>
<Tab title="TypeScript">
Expand All @@ -707,7 +724,7 @@
console.log("User joined:", user);
},
onUserLeft: (user: any) => {
console.log("User left:", user);

Check warning on line 727 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L727

Did you really mean 'onError'?
},
onCallEnded: () => {
console.log("Call ended");
Expand Down Expand Up @@ -773,15 +790,15 @@
const listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.addLoginListener(
listenerID,
new CometChat.LoginListener({

Check warning on line 793 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L793

Did you really mean 'loginFailure'?
loginSuccess: (user: CometChat.User) => {
console.log("LoginListener :: loginSuccess", user);

Check warning on line 795 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L795

Did you really mean 'loginFailure'?

Check warning on line 795 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L795

Did you really mean 'logoutSuccess'?
},
loginFailure: (error: CometChat.CometChatException) => {

Check warning on line 797 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L797

Did you really mean 'logoutSuccess'?
console.log("LoginListener :: loginFailure", error);

Check warning on line 798 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L798

Did you really mean 'logoutFailure'?
},
logoutSuccess: () => {
console.log("LoginListener :: logoutSuccess");

Check warning on line 801 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L801

Did you really mean 'logoutFailure'?
},
logoutFailure: (error: CometChat.CometChatException) => {
console.log("LoginListener :: logoutFailure", error);
Expand Down Expand Up @@ -836,10 +853,10 @@
```typescript
const listenerID: string = "UNIQUE_LISTENER_ID";
CometChat.addConnectionListener(
listenerID,

Check warning on line 856 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L856

Did you really mean 'inConnecting'?
new CometChat.ConnectionListener({
onConnected: () => {
console.log("ConnectionListener :: connected");

Check warning on line 859 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L859

Did you really mean 'onDisconnected'?
},
inConnecting: () => {
console.log("ConnectionListener :: connecting");
Expand All @@ -858,10 +875,10 @@
```javascript
const listenerID = "UNIQUE_LISTENER_ID";
CometChat.addConnectionListener(
listenerID,

Check warning on line 878 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L878

Did you really mean 'inConnecting'?
new CometChat.ConnectionListener({
onConnected: () => {
console.log("ConnectionListener :: connected");

Check warning on line 881 in sdk/javascript/all-real-time-listeners.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/all-real-time-listeners.mdx#L881

Did you really mean 'onDisconnected'?
},
inConnecting: () => {
console.log("ConnectionListener :: connecting");
Expand Down
17 changes: 17 additions & 0 deletions sdk/javascript/authentication-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
description: "Create users and authenticate them securely with the CometChat JavaScript SDK."
---

<Accordion title="AI Integration Quick Reference">

| Field | Value |
| --- | --- |
| Package | `@cometchat/chat-sdk-javascript` |
| Import | `import { CometChat } from "@cometchat/chat-sdk-javascript";` |
| Key methods | `CometChat.login(UID, authKey)` · `CometChat.login(authToken)` · `CometChat.getLoggedinUser()` · `CometChat.logout()` · `CometChat.createUser(user, authKey)` |
| Key classes | `CometChat.User` · `CometChat.CometChatException` |
| Primary output | `login()` resolves to a `CometChat.User`; `getLoggedinUser()` resolves to the `CometChat.User` or `null` when no session exists; `logout()` resolves on success; all reject with `CometChat.CometChatException` |
| Listeners registered | `CometChat.LoginListener` via `CometChat.addLoginListener(listenerID, ...)` / `CometChat.removeLoginListener(listenerID)`; key callbacks `loginSuccess`, `loginFailure`, `logoutSuccess`, `logoutFailure` |
| Prerequisites | SDK initialized via [`CometChat.init()`](/sdk/javascript/setup-sdk), and the user must already exist (create via the [Dashboard](https://app.cometchat.com) or the [Create User API](https://api-explorer.cometchat.com/reference/creates-user)) |
| Constraints | Auth Key login and `createUser()` with an Auth Key are for development/testing only — never ship an Auth Key in client code. For production, generate an [Auth Token](https://api-explorer.cometchat.com/reference/create-authtoken) server-side and pass it to `login(authToken)` |
| Related | [User Management](/sdk/javascript/user-management) · [Connection Status](/sdk/javascript/connection-status) · [All Real-Time Listeners](/sdk/javascript/all-real-time-listeners) · [Send a Message](/sdk/javascript/send-message) |
| Full reference | [`User`](/sdk/reference/entities#user) · [`CometChatException`](/sdk/reference/auxiliary#cometchatexception) |

</Accordion>

## Create User

Before you log in a user, you must add the user to CometChat.
Expand All @@ -13,7 +30,7 @@

<Note>

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`.

Check warning on line 33 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L33

Did you really mean 'UIDs'?

</Note>

Expand All @@ -34,8 +51,8 @@
<Tabs>
<Tab title="TypeScript">
```typescript
let authKey: string = "AUTH_KEY";

Check warning on line 54 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L54

Did you really mean 'authKey'?
let uid: string = "user1";

Check warning on line 55 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L55

Did you really mean 'uid'?
let name: string = "Kevin";

let user: CometChat.User = new CometChat.User(uid);
Expand Down Expand Up @@ -108,12 +125,12 @@
<Tab title="TypeScript">
```typescript
const UID: string = "cometchat-uid-1";
const authKey: string = "AUTH_KEY";

Check warning on line 128 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L128

Did you really mean 'authKey'?

CometChat.getLoggedinUser().then(
(user: CometChat.User) => {
if (!user) {
CometChat.login(UID, authKey).then(

Check warning on line 133 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L133

Did you really mean 'authKey'?
(user: CometChat.User) => {
console.log("Login Successful:", { user });
},
Expand Down Expand Up @@ -212,12 +229,12 @@
<Tabs>
<Tab title="TypeScript">
```typescript
const authToken: string = "AUTH_TOKEN";

Check warning on line 232 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L232

Did you really mean 'authToken'?

CometChat.getLoggedinUser().then(
(user: CometChat.User) => {
if (!user) {
CometChat.login(authToken).then(

Check warning on line 237 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L237

Did you really mean 'authToken'?
(user: CometChat.User) => {
console.log("Login Successful:", { user });
},
Expand Down Expand Up @@ -292,7 +309,7 @@
<Tab title="TypeScript">
```typescript
CometChat.logout().then(
(loggedOut: Object) => {

Check warning on line 312 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L312

Did you really mean 'loggedOut'?
console.log("Logout completed successfully");
},
(error: CometChat.CometChatException) => {
Expand Down Expand Up @@ -354,14 +371,14 @@
loginSuccess: (user: CometChat.User) => {
console.log("LoginListener :: loginSuccess", user);
},
loginFailure: (error: CometChat.CometChatException) => {

Check warning on line 374 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L374

Did you really mean 'loginFailure'?
console.log("LoginListener :: loginFailure", error);

Check warning on line 375 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L375

Did you really mean 'loginFailure'?
},
logoutSuccess: () => {

Check warning on line 377 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L377

Did you really mean 'logoutSuccess'?
console.log("LoginListener :: logoutSuccess");

Check warning on line 378 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L378

Did you really mean 'logoutSuccess'?
},
logoutFailure: (error: CometChat.CometChatException) => {

Check warning on line 380 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L380

Did you really mean 'logoutFailure'?
console.log("LoginListener :: logoutFailure", error);

Check warning on line 381 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L381

Did you really mean 'logoutFailure'?
}
})
);
Expand Down Expand Up @@ -400,7 +417,7 @@

<Warning>
Always remove login listeners when they're no longer needed (e.g., on
component unmount or page navigation). Failing to remove listeners can cause

Check warning on line 420 in sdk/javascript/authentication-overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/authentication-overview.mdx#L420

Did you really mean 'unmount'?
memory leaks and duplicate event handling.
</Warning>

Expand Down
17 changes: 17 additions & 0 deletions sdk/javascript/block-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,31 @@
description: "Block and unblock users in chat apps with the CometChat JavaScript SDK."
---

<Accordion title="AI Integration Quick Reference">

| Field | Value |
| --- | --- |
| Package | `@cometchat/chat-sdk-javascript` |
| Import | `import { CometChat } from "@cometchat/chat-sdk-javascript";` |
| Key methods | `CometChat.blockUsers(usersList)` · `CometChat.unblockUsers(usersList)` · `blockedUsersRequest.fetchNext()` (build via `BlockedUsersRequestBuilder`) |
| Request builder | `CometChat.BlockedUsersRequestBuilder` — configure with `.setLimit()` · `.setSearchKeyword()` · `.setDirection()`; then `.build()` → `.fetchNext()` |
| Key classes | `CometChat.User` (access via `getBlockedByMe()`, `getHasBlockedMe()`); direction via `CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME` / `.HAS_BLOCKED_ME` / `.BOTH` |
| Primary output | `blockUsers()` / `unblockUsers()` resolve to a `{ uid: "success" \| "fail" }` object (each UID processed independently); `fetchNext()` resolves to `Promise<CometChat.User[]>`; all reject with `CometChat.CometChatException` |
| Prerequisites | SDK initialized via [`CometChat.init()`](/sdk/javascript/setup-sdk) and a logged-in user via [`CometChat.login()`](/sdk/javascript/authentication-overview) |
| Constraints | `setDirection()` default is `BOTH`; `blockUsers()` / `unblockUsers()` take an array of UIDs |

Check warning on line 17 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L17

Did you really mean 'UIDs'?
| Related | [Retrieve Users](/sdk/javascript/retrieve-users) · [User Presence](/sdk/javascript/user-presence) · [User Management](/sdk/javascript/user-management) · [Flag a Message](/sdk/javascript/flag-message) |
| Full reference | [`User`](/sdk/reference/entities#user) |

</Accordion>

## Block Users

Block users to prevent all communication with them. Use `blockUsers()` with an array of UIDs.

Check warning on line 25 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L25

Did you really mean 'UIDs'?

<Tabs>
<Tab title="TypeScript">
```typescript
const usersList: String[] = ["UID1", "UID2", "UID3"];

Check warning on line 30 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L30

Did you really mean 'usersList'?

CometChat.blockUsers(usersList).then(
(list: Object) => {
Expand Down Expand Up @@ -42,7 +59,7 @@
const usersList = ["UID1", "UID2", "UID3"];

try {
const list = await CometChat.blockUsers(usersList);

Check warning on line 62 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L62

Did you really mean 'usersList'?
console.log("users list blocked", { list });
} catch (error) {
console.log("Blocking user fails with error", error);
Expand All @@ -53,11 +70,11 @@

</Tabs>

Returns an object with UIDs as keys and `"success"` or `"fail"` as values. Each [`User`](/sdk/reference/entities#user) in the request is processed independently.

Check warning on line 73 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L73

Did you really mean 'UIDs'?

## Unblock Users

Unblock previously blocked users using `unblockUsers()` with an array of UIDs.

Check warning on line 77 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L77

Did you really mean 'UIDs'?

<Tabs>
<Tab title="TypeScript">
Expand Down Expand Up @@ -105,7 +122,7 @@

</Tabs>

Returns an object with UIDs as keys and `"success"` or `"fail"` as values. Each [`User`](/sdk/reference/entities#user) in the request is processed independently.

Check warning on line 125 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L125

Did you really mean 'UIDs'?

## Get List of Blocked Users

Expand Down Expand Up @@ -146,7 +163,7 @@
<Tab title="TypeScript">
```typescript
let limit: number = 30;
let searchKeyword: string = "super";

Check warning on line 166 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L166

Did you really mean 'searchKeyword'?
let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder()
.setLimit(limit)
.setSearchKeyword(searchKeyword)
Expand All @@ -158,7 +175,7 @@
<Tab title="JavaScript">
```javascript
let limit = 30;
let searchKeyword = "super";

Check warning on line 178 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L178

Did you really mean 'searchKeyword'?
let blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder()
.setLimit(limit)
.setSearchKeyword(searchKeyword)
Expand Down Expand Up @@ -232,7 +249,7 @@
.build();

blockedUsersRequest.fetchNext().then(
(userList: CometChat.User[]) => {

Check warning on line 252 in sdk/javascript/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/block-users.mdx#L252

Did you really mean 'userList'?
console.log("Blocked user list received:", userList);
}, (error: CometChat.CometChatException) => {
console.log("Blocked user list fetching failed with error:", error);
Expand Down
17 changes: 17 additions & 0 deletions sdk/javascript/campaigns.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
description: "Fetch notification feed items, listen for real-time delivery, mark items as read/delivered, report engagement, and track push notifications using the CometChat JavaScript SDK."
---

<Accordion title="AI Integration Quick Reference">

| Field | Value |
| --- | --- |
| Package | `@cometchat/chat-sdk-javascript` |
| Import | `import { CometChat } from "@cometchat/chat-sdk-javascript";` |
| Key methods | `CometChat.markFeedItemAsRead(feedItem)` · `CometChat.markFeedItemAsDelivered(feedItem)` · `CometChat.markFeedItemsAsDelivered(feedItems)` · `CometChat.reportFeedEngagement(feedItem, interactionString)` · `CometChat.getNotificationFeedUnreadCount()` · `CometChat.getNotificationFeedItem(id)` · `CometChat.markPushNotificationDelivered(pushNotification)` · `CometChat.markPushNotificationClicked(pushNotification)` |
| Request builder | `new CometChat.NotificationFeedRequestBuilder().setLimit(limit).setReadState(state).setCategory(category).setChannelId(channelId).setTags(tags).build()` → `.fetchNext()` · also `NotificationCategoriesRequestBuilder().setLimit(limit).build()` → `.fetchNext()` |
| Key classes | `CometChat.NotificationFeedItem` · `CometChat.NotificationCategory` · `CometChat.PushNotification` · `CometChat.CardMessage` |
| Primary output | `NotificationFeedRequest.fetchNext()` resolves to `CometChat.NotificationFeedItem[]` (empty array when exhausted); `getNotificationFeedUnreadCount()` resolves to `{ count: number }`; mark/report methods resolve on success; all reject with `CometChat.CometChatException` |
| Listeners registered | Notification feed listener via `CometChat.addNotificationFeedListener("feedListener", ...)` / `CometChat.removeNotificationFeedListener("feedListener")`; key callback `onFeedItemReceived`. Card chat messages arrive on `CometChat.MessageListener`'s `onCardMessageReceived` callback |
| Prerequisites | SDK initialized via [`CometChat.init()`](/sdk/javascript/setup-sdk) and a logged-in user via [`CometChat.login()`](/sdk/javascript/authentication-overview); channels, categories, templates, and campaigns configured in the [Dashboard](/campaigns#setup-flow). Render cards with `@cometchat/cards-react` |
| Constraints | Card messages are **receive-only** — created and sent exclusively via the Platform (REST) API or Dashboard Bubble Builder; the SDK exposes the raw Card Schema JSON via `getCard()`. The Cards library is a pure renderer and does not execute card actions — your app must handle action callbacks |
| Related | [Card Messages](/sdk/javascript/card-messages) · [Receive a Message](/sdk/javascript/receive-message) · [All Real-Time Listeners](/sdk/javascript/all-real-time-listeners) · [Send a Message](/sdk/javascript/send-message) |

</Accordion>

CometChat Campaigns lets you deliver targeted, rich notifications to users via an in-app notification feed. Each notification is a **Card Schema JSON** — a structured layout rendered natively by the CometChat Cards library.

The SDK provides APIs to fetch feed items, listen for real-time delivery, mark items as read/delivered, report engagement, and retrieve unread counts.
Expand Down Expand Up @@ -73,12 +90,12 @@
"light": "transparent",
"dark": "transparent"
},
"textColor": {

Check warning on line 93 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L93

Did you really mean 'textColor'?
"light": "#6C5CE7",
"dark": "#6C5CE7"
},
"size": 40,
"fontSize": 13,

Check warning on line 98 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L98

Did you really mean 'fontSize'?
"borderRadius": 6,
"padding": {
"top": 0,
Expand All @@ -96,14 +113,14 @@
"id": "col_98fed9bd-1a95-4cee-aa81-84a9016e41f2"
}
],
"fallbackText": "",

Check warning on line 116 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L116

Did you really mean 'fallbackText'?
"style": {
"background": {
"light": "#E8E8E8",
"dark": "#E8E8E8"
},
"borderRadius": 16,
"borderColor": {

Check warning on line 123 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L123

Did you really mean 'borderColor'?
"light": "#DFE6E9",
"dark": "#DFE6E9"
},
Expand Down Expand Up @@ -214,7 +231,7 @@
<Tabs>
<Tab title="JavaScript">
```javascript
const categoriesRequest = new CometChat.NotificationCategoriesRequestBuilder()

Check warning on line 234 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L234

Did you really mean 'categoriesRequest'?
.setLimit(50)
.build();

Expand Down Expand Up @@ -450,7 +467,7 @@
<Tabs>
<Tab title="JavaScript">
```javascript
const pushNotification = new CometChat.PushNotification(pushPayloadJson);

Check warning on line 470 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L470

Did you really mean 'pushNotification'?

CometChat.markPushNotificationDelivered(pushNotification).then(
() => { /* Success */ },
Expand Down Expand Up @@ -548,10 +565,10 @@
window.open(action.url, "_blank");
break;
case "chatWithUser":
// Navigate to chat with action.uid

Check warning on line 568 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L568

Did you really mean 'uid'?
break;
case "chatWithGroup":
// Navigate to group chat with action.guid

Check warning on line 571 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L571

Did you really mean 'guid'?
break;
}
}}
Expand All @@ -572,15 +589,15 @@

| Action Type | Parameters | Description |
| --- | --- | --- |
| `openUrl` | url, openIn | Open a URL in browser or webview |

Check warning on line 592 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L592

Did you really mean 'openIn'?

Check warning on line 592 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L592

Did you really mean 'webview'?
| `chatWithUser` | uid | Navigate to 1:1 chat |
| `chatWithGroup` | guid | Navigate to group chat |
| `sendMessage` | text, receiverUid, receiverGuid | Send a text message |

Check warning on line 595 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L595

Did you really mean 'receiverUid'?

Check warning on line 595 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L595

Did you really mean 'receiverGuid'?
| `copyToClipboard` | value | Copy text to clipboard |
| `downloadFile` | url, filename | Download a file |
| `initiateCall` | callType (audio/video), uid, guid | Start a call |

Check warning on line 598 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L598

Did you really mean 'callType'?

Check warning on line 598 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L598

Did you really mean 'uid'?

Check warning on line 598 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L598

Did you really mean 'guid'?
| `apiCall` | url, method, headers, body | Make an HTTP request |
| `customCallback` | callbackId, payload | App-specific logic |

Check warning on line 600 in sdk/javascript/campaigns.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/campaigns.mdx#L600

Did you really mean 'callbackId'?

---

Expand Down
17 changes: 17 additions & 0 deletions sdk/javascript/card-messages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@
description: "Receive and render rich card messages with the CometChat JavaScript SDK."
---

<Accordion title="AI Integration Quick Reference">

| Field | Value |
| --- | --- |
| Package | `@cometchat/chat-sdk-javascript` |
| Import | `import { CometChat } from "@cometchat/chat-sdk-javascript";` |
| Key methods | `CometChat.addMessageListener(listenerID, new CometChat.MessageListener({...}))` · `CometChat.addAIAssistantListener(listenerID, new CometChat.AIAssistantListener({...}))` · `cardMessage.getCard()` · `message.getElements()` · `element.getType()` / `element.getData()` |
| Key classes | `CometChat.CardMessage` · `CometChat.MessageListener` · `CometChat.AIAssistantMessage` · `CometChat.AIAssistantElement` · `CometChat.AIAssistantListener` · `CometChat.AIAssistantBaseEvent` (`AIAssistantCardStartedEvent` · `AIAssistantCardReceivedEvent` · `AIAssistantCardEndedEvent`) |
| Primary output | Cards are receive-only. Standalone cards arrive as a `CardMessage` (`getCard()` returns the raw Card Schema JSON, or `undefined`); inline cards arrive as elements on an `AIAssistantMessage` (`getElements()` returns `AIAssistantElement[]`); streaming cards arrive as `card_start` / `card` / `card_end` events (`getCard()` on the `card` event) |
| Listeners registered | `MessageListener` — `onCardMessageReceived(cardMessage: CometChat.CardMessage)` and `onAIAssistantMessageReceived(message: CometChat.AIAssistantMessage)`; `AIAssistantListener` — `onAIAssistantEventReceived(event: CometChat.AIAssistantBaseEvent)` for `card_start` / `card` / `card_end`. Remove with `CometChat.removeMessageListener(id)` / `CometChat.removeAIAssistantListener(id)` |
| Prerequisites | SDK initialized via [`CometChat.init()`](/sdk/javascript/setup-sdk) and a logged-in user via [`CometChat.login()`](/sdk/javascript/authentication-overview) |
| Constraints | Card support is **receive-only** — cards cannot be composed or sent from the SDK (they are authored server-side via the Platform REST API or Dashboard). Branch on `getCategory() === "card"` (a card's `getType()` returns `"text"`). The SDK never interprets the card body; rendering is your app's responsibility. Streaming and persisted cards for the same card share a `cardId` — correlate to avoid rendering twice. Always remove listeners on unmount |

Check warning on line 17 in sdk/javascript/card-messages.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/card-messages.mdx#L17

Did you really mean 'unmount'?
| Related | [Receive a Message](/sdk/javascript/receive-message) · [AI Agents](/sdk/javascript/ai-agents) · [All Real Time Listeners](/sdk/javascript/all-real-time-listeners) · [Send a Message](/sdk/javascript/send-message) |
| Full reference | [`CardMessage`](/sdk/reference/messages#cardmessage) · [`AIAssistantMessage`](/sdk/reference/messages#aiassistantmessage) · [`AIAssistantElement`](/sdk/reference/messages#aiassistantelement) · [`AIAssistantBaseEvent`](/sdk/reference/messages#aiassistantbaseevent) |

</Accordion>

Card messages let your app display rich, structured content — such as product cards, confirmations, or AI-generated summaries — inside a conversation. In the JavaScript SDK, card support is **receive-only**: the SDK deserializes incoming cards and hands you their raw payload through typed accessors, and your app is responsible for turning that payload into UI.

Check warning on line 23 in sdk/javascript/card-messages.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/card-messages.mdx#L23

Did you really mean 'deserializes'?

Check warning on line 23 in sdk/javascript/card-messages.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/card-messages.mdx#L23

Did you really mean 'accessors'?

The body of a card is **Card Schema JSON** — the same structured layout used by [Campaigns notification feeds](/sdk/javascript/campaigns). Cards are authored server-side (they cannot be composed or sent from the SDK) via the [Platform (REST) API](/rest-api/messages/send-message) or the **Dashboard Bubble Builder**, and delivered to clients like any other message.

Expand All @@ -12,7 +29,7 @@
</Tip>

<Note>
The SDK never interprets the body of a card — every accessor returns the raw

Check warning on line 32 in sdk/javascript/card-messages.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/card-messages.mdx#L32

Did you really mean 'accessor'?
Card Schema JSON exactly as it was sent. Drawing it is your app's
responsibility: pass that JSON to the **CometChat Cards** renderer for your
framework.
Expand All @@ -37,14 +54,14 @@

## Standalone Card Messages

A standalone card arrives as a message whose category is `card` (its type is `text`). The SDK deserializes it into a [`CardMessage`](/sdk/reference/messages#cardmessage) and delivers it through the **`onCardMessageReceived`** callback of the [`MessageListener`](/sdk/javascript/all-real-time-listeners#message-listener).

Check warning on line 57 in sdk/javascript/card-messages.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/card-messages.mdx#L57

Did you really mean 'deserializes'?

<Note>
Branch on `getCategory() === "card"` to identify a card message —
`getType()` returns `"text"`, the same as a plain text message.
</Note>

`CardMessage` extends [`BaseMessage`](/sdk/reference/messages#basemessage), so all the usual metadata (`getSender()`, `getReceiver()`, `getSentAt()`, `getConversationId()`, …) is available. It adds these card-specific accessors:

Check warning on line 64 in sdk/javascript/card-messages.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/card-messages.mdx#L64

Did you really mean 'accessors'?

| Getter | Return Type | Description |
| ------------------- | -------------------- | --------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -292,7 +309,7 @@
// Pass cardPayload to your card renderer.
break;
}
case "card_end":

Check warning on line 312 in sdk/javascript/card-messages.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/card-messages.mdx#L312

Did you really mean 'card_end'?
console.log("Card generation ended:", event.getCardId());
break;
default:
Expand Down
17 changes: 17 additions & 0 deletions sdk/javascript/delivery-read-receipts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
description: "Mark messages as delivered or read and handle receipts with the CometChat JavaScript SDK."
---

<Accordion title="AI Integration Quick Reference">

| Field | Value |
| --- | --- |
| Package | `@cometchat/chat-sdk-javascript` |
| Import | `import { CometChat } from "@cometchat/chat-sdk-javascript";` |
| Key methods | `CometChat.markAsDelivered(message)` · `CometChat.markAsRead(message)` · `CometChat.markConversationAsDelivered(conversationWith, conversationType)` · `CometChat.markConversationAsRead(conversationWith, conversationType)` · `CometChat.markAsUnread(message)` · `CometChat.getMessageReceipts(messageId)` |
| Key classes | `CometChat.MessageListener` · `CometChat.MessageReceipt` · `CometChat.BaseMessage` |
| Primary output | `markAsDelivered()` / `markAsRead()` are fire-and-forget (they resolve but do **not** return a `MessageReceipt`); `markConversationAsDelivered()` / `markConversationAsRead()` resolve with a `string`; `markAsUnread()` resolves with a `string`; `getMessageReceipts()` resolves to `Promise<CometChat.MessageReceipt[]>`; all reject with `CometChat.CometChatException` |
| Listeners registered | `MessageListener` via `CometChat.addMessageListener(listenerID, ...)` / `CometChat.removeMessageListener(listenerID)` — receipt callbacks: `onMessagesDelivered`, `onMessagesRead`, `onMessagesDeliveredToAll` (groups), `onMessagesReadByAll` (groups), each receiving a `CometChat.MessageReceipt` |
| Prerequisites | SDK initialized via [`CometChat.init()`](/sdk/javascript/setup-sdk) and a logged-in user via [`CometChat.login()`](/sdk/javascript/authentication-overview) |
| Constraints | `onMessagesDeliveredToAll`, `onMessagesReadByAll`, group `deliveredAt` / `readAt`, and `markAsUnread()` require the **Enhanced Messaging Status** feature. Always remove listeners on unmount to avoid memory leaks |

Check warning on line 17 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L17

Did you really mean 'unmount'?
| Related | [Receive a Message](/sdk/javascript/receive-message) · [Typing Indicators](/sdk/javascript/typing-indicators) · [Retrieve Conversations](/sdk/javascript/retrieve-conversations) · [All Real Time Listeners](/sdk/javascript/all-real-time-listeners) |
| Full reference | [`MessageReceipt`](/sdk/reference/auxiliary#messagereceipt) · [`User`](/sdk/reference/entities#user) · [`BaseMessage`](/sdk/reference/messages#basemessage) |

</Accordion>

## Mark Messages as Delivered

_In other words, as a recipient, how do I inform the sender that I've received a message?_
Expand Down Expand Up @@ -93,12 +110,12 @@
<Tabs>
<Tab title="TypeScript (User)">
```typescript
let messageId: string = "MESSAGE_ID";

Check warning on line 113 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L113

Did you really mean 'messageId'?
let receiverId: string = "MESSAGE_SENDER_UID";

Check warning on line 114 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L114

Did you really mean 'receiverId'?
let receiverType: string = "user";

Check warning on line 115 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L115

Did you really mean 'receiverType'?
let senderId: string = "MESSAGE_SENDER_UID";

Check warning on line 116 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L116

Did you really mean 'senderId'?

CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(

Check warning on line 118 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L118

Did you really mean 'receiverId'?

Check warning on line 118 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L118

Did you really mean 'receiverType'?
() => {
console.log("Marked as delivered successfully");
},
Expand Down Expand Up @@ -131,12 +148,12 @@

<Tab title="TypeScript (Group)">
```typescript
let messageId: string = "MESSAGE_ID";

Check warning on line 151 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L151

Did you really mean 'messageId'?
let receiverId: string = "GROUP_GUID";

Check warning on line 152 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L152

Did you really mean 'receiverId'?
let receiverType: string = "group";

Check warning on line 153 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L153

Did you really mean 'receiverType'?
let senderId: string = "MESSAGE_SENDER_UID";

Check warning on line 154 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L154

Did you really mean 'senderId'?

CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(

Check warning on line 156 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L156

Did you really mean 'receiverId'?

Check warning on line 156 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L156

Did you really mean 'receiverType'?
() => {
console.log("Marked as delivered successfully");
},
Expand Down Expand Up @@ -178,8 +195,8 @@
<Tabs>
<Tab title="TypeScript (User)">
```typescript
let conversationWith: string = "USER_UID";

Check warning on line 198 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L198

Did you really mean 'conversationWith'?
let conversationType: string = "user";

Check warning on line 199 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L199

Did you really mean 'conversationType'?

CometChat.markConversationAsDelivered(conversationWith, conversationType).then(
(response: string) => {
Expand Down Expand Up @@ -212,8 +229,8 @@

<Tab title="TypeScript (Group)">
```typescript
let conversationWith: string = "GROUP_GUID";

Check warning on line 232 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L232

Did you really mean 'conversationWith'?
let conversationType: string = "group";

Check warning on line 233 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L233

Did you really mean 'conversationType'?

CometChat.markConversationAsDelivered(conversationWith, conversationType).then(
(response: string) => {
Expand Down Expand Up @@ -284,12 +301,12 @@
<Tabs>
<Tab title="TypeScript (User)">
```typescript
let messageId: string = "MESSAGE_ID";

Check warning on line 304 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L304

Did you really mean 'messageId'?
let receiverId: string = "MESSAGE_SENDER_UID";

Check warning on line 305 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L305

Did you really mean 'receiverId'?
let receiverType: string = "user";

Check warning on line 306 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L306

Did you really mean 'receiverType'?
let senderId: string = "MESSAGE_SENDER_UID";

Check warning on line 307 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L307

Did you really mean 'senderId'?

CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(

Check warning on line 309 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L309

Did you really mean 'receiverId'?

Check warning on line 309 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L309

Did you really mean 'receiverType'?
() => {
console.log("Marked as read successfully");
},
Expand Down Expand Up @@ -322,12 +339,12 @@

<Tab title="TypeScript (Group)">
```typescript
let messageId: string = "MESSAGE_ID";

Check warning on line 342 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L342

Did you really mean 'messageId'?
let receiverId: string = "GROUP_GUID";

Check warning on line 343 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L343

Did you really mean 'receiverId'?
let receiverType: string = "group";

Check warning on line 344 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L344

Did you really mean 'receiverType'?
let senderId: string = "MESSAGE_SENDER_UID";

Check warning on line 345 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L345

Did you really mean 'senderId'?

CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(

Check warning on line 347 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L347

Did you really mean 'receiverId'?

Check warning on line 347 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L347

Did you really mean 'receiverType'?
() => {
console.log("Marked as read successfully");
},
Expand Down Expand Up @@ -367,8 +384,8 @@
<Tabs>
<Tab title="TypeScript (User)">
```typescript
let conversationWith: string = "USER_UID";

Check warning on line 387 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L387

Did you really mean 'conversationWith'?
let conversationType: string = "user";

Check warning on line 388 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L388

Did you really mean 'conversationType'?

CometChat.markConversationAsRead(conversationWith, conversationType).then(
(response: string) => {
Expand Down Expand Up @@ -401,8 +418,8 @@

<Tab title="TypeScript (Group)">
```typescript
let conversationWith: string = "GROUP_GUID";

Check warning on line 421 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L421

Did you really mean 'conversationWith'?
let conversationType: string = "group";

Check warning on line 422 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L422

Did you really mean 'conversationType'?

CometChat.markConversationAsRead(conversationWith, conversationType).then(
(response: string) => {
Expand Down Expand Up @@ -454,10 +471,10 @@
CometChat.addMessageListener(
listenerID,
new CometChat.MessageListener({
onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => {

Check warning on line 474 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L474

Did you really mean 'messageReceipt'?
console.log("Message delivered:", messageReceipt);

Check warning on line 475 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L475

Did you really mean 'messageReceipt'?
},
onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => {

Check warning on line 477 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L477

Did you really mean 'messageReceipt'?
console.log("Message read:", messageReceipt);
},
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
Expand Down Expand Up @@ -508,8 +525,8 @@
| `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. |

Check warning on line 528 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L528

Did you really mean 'receiptType'?
| `readAt` | The timestamp of the time when the message was read. This will only be present when the receiptType is read. |

Check warning on line 529 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L529

Did you really mean 'receiptType'?

The `markAsDelivered()` and `markAsRead()` methods are fire-and-forget — they do not return a [`MessageReceipt`](/sdk/reference/auxiliary#messagereceipt) object. Use the listener callbacks above to receive delivery and read confirmations.

Expand Down Expand Up @@ -542,13 +559,13 @@

| Field | Getter | Return Type | Description |
| ------------ | ------------------- | -------------------------------------- | ------------------------------ |
| messageId | `getMessageId()` | `string` | ID of the message |

Check warning on line 562 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L562

Did you really mean 'messageId'?
| sender | `getSender()` | [`User`](/sdk/reference/entities#user) | User who triggered the receipt |
| receiverId | `getReceiverId()` | `string` | ID of the receiver |

Check warning on line 564 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L564

Did you really mean 'receiverId'?
| receiverType | `getReceiverType()` | `string` | `"user"` or `"group"` |

Check warning on line 565 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L565

Did you really mean 'receiverType'?
| receiptType | `getReceiptType()` | `string` | `"delivery"` or `"read"` |

Check warning on line 566 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L566

Did you really mean 'receiptType'?
| deliveredAt | `getDeliveredAt()` | `number` | Timestamp when delivered |

Check warning on line 567 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L567

Did you really mean 'deliveredAt'?
| readAt | `getReadAt()` | `number` | Timestamp when read |

Check warning on line 568 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L568

Did you really mean 'readAt'?

## Get Receipt History

Expand All @@ -557,7 +574,7 @@
<Tabs>
<Tab title="TypeScript">
```typescript
let messageId: number = 123;

Check warning on line 577 in sdk/javascript/delivery-read-receipts.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/javascript/delivery-read-receipts.mdx#L577

Did you really mean 'messageId'?

CometChat.getMessageReceipts(messageId).then(
(receipts: CometChat.MessageReceipt[]) => {
Expand Down
Loading