Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4332f97
refactor: improve sdk doc
aanshisingh-cometchat Feb 17, 2026
50e60be
refactor: update the sdk doc
aanshisingh-cometchat Feb 17, 2026
2c1d788
docs(javascript-sdk): enhance authentication and key concepts documen…
PrajwalDhuleCC Feb 18, 2026
2cdcb82
docs(javascript-sdk): enhance message handling documentation with bes…
PrajwalDhuleCC Feb 18, 2026
c14b74b
docs(javascript-sdk): enhance calling and messaging documentation wit…
PrajwalDhuleCC Feb 20, 2026
a2d6928
docs(javascript-sdk): enhance documentation with best practices and t…
PrajwalDhuleCC Feb 20, 2026
2908e24
Merge branch 'main' into docs/js-sdk-improvement
PrajwalDhuleCC Mar 4, 2026
1169d91
docs(sdk/javascript): Add message response documentation for "Send A …
PrajwalDhuleCC Mar 10, 2026
4128de3
docs(sdk): Add initial global message reference documentation and tag…
PrajwalDhuleCC Mar 13, 2026
a33f85f
docs(sdk/javascript): Add method payloads reference and update docume…
PrajwalDhuleCC Mar 16, 2026
8e3d649
Update .gitignore
swapnil-cometchat Mar 17, 2026
473ff8f
Create .mintignore
swapnil-cometchat Mar 17, 2026
de62744
Update .gitignore
swapnil-cometchat Mar 17, 2026
bd6e262
Merge branch 'main' into docs/js-sdk-agentic
swapnil-cometchat Mar 17, 2026
30144b1
updates docs
swapnil-cometchat Mar 18, 2026
55a8a50
I Integration Quick Reference
swapnil-cometchat Mar 18, 2026
201bfde
fixes
swapnil-cometchat Mar 18, 2026
053a3a0
deletes extra files
swapnil-cometchat Mar 18, 2026
b0e8a6e
SDK intialisation and Overview pages
swapnil-cometchat Mar 18, 2026
ec00ff0
Troubleshooting and Best Practices
swapnil-cometchat Mar 18, 2026
65137dc
Best Practices and Troubleshooting
swapnil-cometchat Mar 18, 2026
01ea580
Troubleshooting and error guides
swapnil-cometchat Mar 18, 2026
34dfb3a
Update docs.json
swapnil-cometchat Mar 18, 2026
17ee844
frame these pages better
swapnil-cometchat Mar 18, 2026
8e797c1
Update send-message.mdx
swapnil-cometchat Mar 18, 2026
aa7442c
Update send-message.mdx
swapnil-cometchat Mar 18, 2026
01ed70b
Update send-message.mdx
swapnil-cometchat Mar 18, 2026
90403fd
Update receive-message.mdx
swapnil-cometchat Mar 18, 2026
1f3b248
frame these better
swapnil-cometchat Mar 18, 2026
0916208
Links the references
swapnil-cometchat Mar 18, 2026
0fd5d1f
Update docs.json
swapnil-cometchat Mar 18, 2026
c3f526e
Update send-message.mdx
swapnil-cometchat Mar 18, 2026
ef2c022
updates references
swapnil-cometchat Mar 18, 2026
5eba105
calling docs - frame this better
swapnil-cometchat Mar 18, 2026
7c7c882
updates docs for Users and User Presence
swapnil-cometchat Mar 18, 2026
b4aecb1
groups - frame this better
swapnil-cometchat Mar 18, 2026
70f602d
Frame these better
swapnil-cometchat Mar 18, 2026
7387db2
minor fixes
swapnil-cometchat Mar 18, 2026
31f77c1
Update best-practices.mdx
swapnil-cometchat Mar 18, 2026
3481029
frame this better
swapnil-cometchat Mar 18, 2026
16f4a36
Update troubleshooting.mdx
swapnil-cometchat Mar 18, 2026
09c4729
Update interactive-messages.mdx
swapnil-cometchat Mar 18, 2026
d521e59
Update interactive-messages.mdx
swapnil-cometchat Mar 18, 2026
195ec6c
Update delivery-read-receipts.mdx
swapnil-cometchat Mar 18, 2026
c42d570
Update overview.mdx
swapnil-cometchat Mar 18, 2026
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
19 changes: 18 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,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",
Expand Down Expand Up @@ -2579,6 +2584,7 @@
},
"sdk/javascript/ai-moderation",
"sdk/javascript/ai-agents",
"sdk/javascript/ai-integration-quick-reference",
{
"group": "Resources",
"pages": [
Expand All @@ -2595,6 +2601,14 @@
"sdk/javascript/managing-web-sockets-connections-manually"
]
},
{
"group": "Reference",
"pages": [
"sdk/reference/messages",
"sdk/reference/entities",
"sdk/reference/auxiliary"
]
},
{
"group": "UI Kits",
"pages": [
Expand All @@ -2603,6 +2617,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",
Expand Down
13 changes: 0 additions & 13 deletions node_modules/.package-lock.json

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/22/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions node_modules/22/package.json

This file was deleted.

18 changes: 0 additions & 18 deletions package-lock.json

This file was deleted.

5 changes: 0 additions & 5 deletions package.json

This file was deleted.

218 changes: 116 additions & 102 deletions sdk/javascript/additional-message-filtering.mdx

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions sdk/javascript/advanced-overview.mdx
Original file line number Diff line number Diff line change
@@ -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 */}
<Accordion title="AI Integration 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")
}));
```
</Accordion>

This section helps you to know about the Connection Listeners.

---

## Next Steps

<CardGroup cols={2}>
<Card title="Connection Status" icon="signal" href="/sdk/javascript/connection-status">
Monitor and respond to connection state changes
</Card>
<Card title="WebSocket Management" icon="plug" href="/sdk/javascript/managing-web-sockets-connections-manually">
Manually manage WebSocket connections
</Card>
<Card title="Login Listener" icon="right-to-bracket" href="/sdk/javascript/login-listener">
Listen for login and logout events
</Card>
<Card title="All Real-Time Listeners" icon="tower-broadcast" href="/sdk/javascript/all-real-time-listeners">
Complete reference for all SDK listeners
</Card>
</CardGroup>
124 changes: 83 additions & 41 deletions sdk/javascript/ai-agents.mdx
Original file line number Diff line number Diff line change
@@ -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 */}
<Accordion title="AI Integration 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
</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).
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**.
<Note>
Agents only respond to text messages.
</Note>

## 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 |

<Note>
`Run Start` and `Run Finished` are always emitted. Tool Call events only appear when tools are invoked.
</Note>

<Tabs>
<Tab title="JavaScript">
Expand Down Expand Up @@ -69,23 +95,15 @@ Notes:
</Tab>
</Tabs>

#### 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 |

<Tabs>
<Tab title="JavaScript">
Expand Down Expand Up @@ -131,4 +149,28 @@ These events are received via the **`MessageListener`** after the run completes.
CometChat.removeMessageListener(listnerId);
```
</Tab>
</Tabs>
</Tabs>


<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 leaks and duplicate event handling.
</Warning>

---

## Next Steps

<CardGroup cols={2}>
<Card title="AI Chatbots" icon="robot" href="/ai-chatbots/overview">
Set up AI-powered chatbots for automated conversations
</Card>
<Card title="AI Moderation" icon="shield-check" href="/sdk/javascript/ai-moderation">
Automatically moderate messages with AI
</Card>
<Card title="AI User Copilot" icon="wand-magic-sparkles" href="/sdk/javascript/ai-user-copilot-overview">
AI-powered features like smart replies and conversation summaries
</Card>
<Card title="Send Messages" icon="paper-plane" href="/sdk/javascript/send-message">
Send text messages that trigger AI Agent responses
</Card>
</CardGroup>
Loading