Prerequisites
- CometChat app (App ID, Region, Auth Key).
- Chat Widget variant configured in UI Kit Builder.
- An AI Agent already created and enabled in your app via:
- Agent Builder — build and host inside CometChat, or
- Bring Your Own Agent — 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.
Step 1 - Export & Embed
In UI Kit Builder click Get Embedded Code → copy credentials:- App ID
- Auth Key
- Region
- Variant ID
1
Include script (<head>)
Add script tag in document head (see snippet below).
2
Initialize (<body> end)
Add mount div + init script before closing body.
Option A - Anonymous (Guest Mode)
Use this when:- Let anyone chat anonymously without signing up or logging in.
- Perfect for marketing pages, help centers, or demo sites.
Option B - Create + Log In User On The Fly (Auth Key + UID)
Use this when:- 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.
Option C - Backend-Created User (Auth Token Login)
Use this when:- Create your users via server and login them using secure auth token on frontend.
- Ideal for sites with existing login systems and backends.
Replace the placeholder values (app ID, region, auth key or auth token, UID, agent ID, and variant ID) with values from your deployment. KeepchatType: "user"and setdefaultChatIDto your agent for an AI-first experience.
Step 2 - Verify
If responses fail, confirm the endpoint is publicly reachable and the Agent ID matches the Dashboard configuration.