From 5d15f9e3bfbfe9985c45801e5a8c27be4be8d5ce Mon Sep 17 00:00:00 2001 From: Swapnil Godambe Date: Mon, 15 Dec 2025 16:35:33 +0530 Subject: [PATCH 01/10] Update chat-widget.mdx --- ai-agents/chat-widget.mdx | 134 ++++++++++++++++++++++++++++---------- 1 file changed, 99 insertions(+), 35 deletions(-) diff --git a/ai-agents/chat-widget.mdx b/ai-agents/chat-widget.mdx index fedcb06e8..c700f1b4c 100644 --- a/ai-agents/chat-widget.mdx +++ b/ai-agents/chat-widget.mdx @@ -227,51 +227,115 @@ Example embed (HTML): ``` -```html +Choose the auth flow that matches your site: + +### Option A - Anonymous (Guest Mode) + +```html lines highlight={8-9, 11, 15-17, 22-24}
- +``` + +### Option B - Create + Log In User On The Fly (Auth Key + UID) + +```html lines highlight={8-10, 12, 14, 18-20, 26-28} +
+ + +``` + +### Option C - Backend-Created User (Auth Token Login) - // Optional advanced settings: - // dockedAlignment: "right", // For docked mode: "left" or "right" +```html lines highlight={8-9, 13, 17-18} +
+ + ``` -> Replace the placeholder values (``, etc.) with the credentials, user UID, default chat ID, and variant ID from your deployment. +> Replace the placeholder values (app ID, region, auth key or auth token, UID, agent ID, and variant ID) with values from your deployment. Keep `chatType: "user"` and set `defaultChatID` to your Mastra agent for an AI-first experience. --- From 2f472bc859b7299b8cb8f7bfe2f628562f74ca1f Mon Sep 17 00:00:00 2001 From: Swapnil Godambe Date: Mon, 15 Dec 2025 16:57:56 +0530 Subject: [PATCH 02/10] Update chat-widget.mdx --- ai-agents/chat-widget.mdx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ai-agents/chat-widget.mdx b/ai-agents/chat-widget.mdx index c700f1b4c..8c943135c 100644 --- a/ai-agents/chat-widget.mdx +++ b/ai-agents/chat-widget.mdx @@ -231,6 +231,10 @@ Choose the auth flow that matches your site: ### Option A - Anonymous (Guest Mode) +**Use this when:** +- Anyone should be able to chat without signing up. +- You just need an instant AI chat entry point (marketing page, docs, demo). + ```html lines highlight={8-9, 11, 15-17, 22-24}
@@ -267,6 +271,10 @@ Choose the auth flow that matches your site: ### Option B - Create + Log In User On The Fly (Auth Key + UID) +**Use this when:** +- You already have a unique user ID (email/username/customer id) on the page. +- You want CometChat to create or log in that user automatically with the Auth Key. + ```html lines highlight={8-10, 12, 14, 18-20, 26-28}
@@ -306,6 +314,10 @@ Choose the auth flow that matches your site: ### Option C - Backend-Created User (Auth Token Login) +**Use this when:** +- Users authenticate via your backend and you can mint an auth token server-side. +- You want to avoid exposing the Auth Key in the browser. + ```html lines highlight={8-9, 13, 17-18}
From 0c384feea92cf1b0918a2e279c246b91670b536d Mon Sep 17 00:00:00 2001 From: Swapnil Godambe Date: Mon, 15 Dec 2025 17:25:47 +0530 Subject: [PATCH 03/10] Update chat-widget.mdx --- ai-agents/chat-widget.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ai-agents/chat-widget.mdx b/ai-agents/chat-widget.mdx index 8c943135c..4b28dcac0 100644 --- a/ai-agents/chat-widget.mdx +++ b/ai-agents/chat-widget.mdx @@ -235,7 +235,7 @@ Choose the auth flow that matches your site: - Anyone should be able to chat without signing up. - You just need an instant AI chat entry point (marketing page, docs, demo). -```html lines highlight={8-9, 11, 15-17, 22-24} +```html lines highlight={7-8, 10, 14-16, 21-23}
``` -> Replace the placeholder values (app ID, region, auth key or auth token, UID, agent ID, and variant ID) with values from your deployment. Keep `chatType: "user"` and set `defaultChatID` to your Mastra agent for an AI-first experience. +> Replace the placeholder values (app ID, region, auth key or auth token, UID, agent ID, and variant ID) with values from your deployment. Keep `chatType: "user"` and set `defaultChatID` to your agent for an AI-first experience. --- -## Step 8 - Verify +## Step 2 - Verify | Check | How | |:------|:----| | Agent appears | Open widget → new conversation / agent entry available | | Basic reply | Send a prompt → response under a few seconds | -| Tool logic works | Ask for ingredient substitution / recipe (Chef example) | -| Error free | Browser console + Mastra logs have no unhandled errors | +| Tool logic works | Ask for a tool-backed request (e.g., recipe lookup or data fetch) | +| Error free | Browser console + agent logs have no unhandled errors | If responses fail, confirm the endpoint is publicly reachable and the Agent ID matches the Dashboard configuration. @@ -371,7 +183,7 @@ If responses fail, confirm the endpoint is publicly reachable and the Agent ID m | Issue | Fix | |:------|:----| | Agent not listed | Confirm it’s enabled in Dashboard + variant saved | -| 404 from Mastra | Endpoint path or agent key mismatch | +| 404 from agent | Endpoint path or agent key mismatch | | Timeout | Expose via a tunnel or deploy to a public host | | Tool not invoked | Ensure tool ID referenced in agent instructions & code | | Auth error | Re-check Auth Key / App credentials in embed snippet | From 96f5a3e2a54338d13f33836c04cdd3b6f3739805 Mon Sep 17 00:00:00 2001 From: Swapnil Godambe Date: Mon, 15 Dec 2025 18:11:46 +0530 Subject: [PATCH 07/10] Update chat-widget.mdx --- ai-agents/chat-widget.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ai-agents/chat-widget.mdx b/ai-agents/chat-widget.mdx index 427f3a6b8..80d3ea07c 100644 --- a/ai-agents/chat-widget.mdx +++ b/ai-agents/chat-widget.mdx @@ -10,12 +10,12 @@ description: "Embed your AI Agent (Agent Builder or Bring Your Own Agent) into t - Chat Widget variant configured in UI Kit Builder. - An AI Agent already created and enabled in your app via: - [Agent Builder](/ai-agents/agent-builder/overview) — build and host inside CometChat, or - - [Bring Your Own Agent](/ai-agents/ai-agents/mastra) — connect your own hosted agent. + - [Bring Your Own Agent](/ai-agents/mastra) — connect your own hosted agent. - Agent ID and (optional) variant set to default to that agent. - (Optional) Frontend Action definitions if you want UI‑bound behaviors. -Finish agent creation first in Agent Builder or Bring Your Own Agent, then continue here to embed the widget. +Finish agent creation first in Agent Builder or Bring Your Own Agent, then continue here to embed the widget. --- From eddca39c1256e615907502952234f4c3c36270ab Mon Sep 17 00:00:00 2001 From: Swapnil Godambe Date: Mon, 15 Dec 2025 18:14:07 +0530 Subject: [PATCH 08/10] Update chat-call.mdx --- chat-call.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chat-call.mdx b/chat-call.mdx index c4d5ec650..a1386dc95 100644 --- a/chat-call.mdx +++ b/chat-call.mdx @@ -294,22 +294,22 @@ import { CardGroup, Card, Icon, Badge, Steps, Columns, AccordionGroup, Accordion
    -
  • Add users directly from the CometChat Dashboard.
  • -
  • Ideal for quick testing or small teams.
  • + - Add users directly from the CometChat Dashboard. + - Ideal for quick testing or small teams.
    -
  • Create users via the SDK methods.
  • -
  • Perfect for auto-provisioning during sign-up or login.
  • + - Create users via the SDK methods. + - Perfect for auto-provisioning during sign-up or login.
    -
  • Create users using the REST API.
  • -
  • Best for batch imports or admin workflows.
  • + - Create users using the REST API. + - Best for batch imports or admin workflows.
From 7b19cd5f185d5dab2e34a1b79b52af47dad1c6b4 Mon Sep 17 00:00:00 2001 From: Swapnil Godambe Date: Mon, 15 Dec 2025 18:19:10 +0530 Subject: [PATCH 09/10] Update chat-widget.mdx --- ai-agents/chat-widget.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ai-agents/chat-widget.mdx b/ai-agents/chat-widget.mdx index 80d3ea07c..4f5e6029f 100644 --- a/ai-agents/chat-widget.mdx +++ b/ai-agents/chat-widget.mdx @@ -44,8 +44,8 @@ Choose the auth flow that matches your site: ### Option A - Anonymous (Guest Mode) **Use this when:** -- Anyone should be able to chat without signing up. -- You just need an instant AI chat entry point (marketing page, docs, demo). +- Let anyone chat anonymously without signing up or logging in. +- Perfect for marketing pages, help centers, or demo sites. ```html lines highlight={7-8, 10, 14-16, 21-22, 25-26}
@@ -84,8 +84,8 @@ Choose the auth flow that matches your site: ### Option B - Create + Log In User On The Fly (Auth Key + UID) **Use this when:** -- You already have a unique user ID (email/username/customer id) on the page. -- You want CometChat to create or log in that user automatically with the Auth Key. +- Use your existing user IDs (email, username etc.) to create and log in users automatically. +- No backend needed—CometChat creates users the first time they visit. ```html lines highlight={7-8, 10, 13, 17-19, 24-25, 28-29}
@@ -127,8 +127,8 @@ Choose the auth flow that matches your site: ### Option C - Backend-Created User (Auth Token Login) **Use this when:** -- Users authenticate via your backend and you can mint an auth token server-side. -- You want to avoid exposing the Auth Key in the browser. +- Create your users via server and login them using secure auth token on frontend. +- Ideal for sites with existing login systems and backends. ```html lines highlight={7-8, 12, 16-17, 20-21}
From 79b94d98df0910a7dbcad2a581ec2f8e6f5cbe04 Mon Sep 17 00:00:00 2001 From: Swapnil Godambe Date: Mon, 15 Dec 2025 18:20:14 +0530 Subject: [PATCH 10/10] Update chat-widget.mdx --- ai-agents/chat-widget.mdx | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ai-agents/chat-widget.mdx b/ai-agents/chat-widget.mdx index 4f5e6029f..a86472378 100644 --- a/ai-agents/chat-widget.mdx +++ b/ai-agents/chat-widget.mdx @@ -188,13 +188,3 @@ If responses fail, confirm the endpoint is publicly reachable and the Agent ID m | Tool not invoked | Ensure tool ID referenced in agent instructions & code | | Auth error | Re-check Auth Key / App credentials in embed snippet | ---- - -## Next Steps - -- Add more tools (search, summarization, domain knowledge). -- Introduce Frontend Actions for richer UI control. -- Move from tunnel to production deployment. -- Add analytics / observability (latency, error tracking). - -Need code export (React UI Kit) instead of Widget? See the “Export & Integrate” guide in AI Agents