AI Agent Component Spec
AI Agent Component Spec
| Field | Value |
|---|---|
| Package | @cometchat/chat-uikit-react |
| Key components | CometChatUsers, CometChatGroups, CometChatJoinGroup, CometChatSelector |
| Init | CometChatUIKit.init(UIKitSettings) then CometChatUIKit.login("UID") |
| Purpose | Unified new chat entry point for starting 1:1 or group conversations |
| Sample app | GitHub |
| Related | All Guides |
Components
| Component / Class | Role |
|---|---|
CometChatNewChatView | Main container for new chat creation interface |
CometChatUsers | Displays list of available users for chat creation |
CometChatGroups | Shows available groups for joining |
CometChatJoinGroup | Handles protected group joining process |
CometChatSelector | Navigation component with new chat button |
Integration Steps
1. New Chat State Management
Track whether the new chat view is visible and which user/group was selected. When the “New Chat” button is clicked, show the view and hide any open side panels. File: CometChatHome.tsx2. Conditional Rendering
Switch between the new chat view, the messages view, or an empty state depending on the current app state.useCallback prevents unnecessary re-renders.
File: CometChatHome.tsx
3. New Chat View
The main new chat interface with a header, back button, and tabbed navigation between Users and Groups. Selecting a tab switches the list below. File: CometChatHome.tsx4. User Selection and Chat Creation
The tab content renders eitherCometChatUsers or CometChatGroups. Clicking a user creates a 1:1 chat and closes the new chat view. Clicking a group triggers the join flow.
File: CometChatHome.tsx
5. Group Joining Logic
Handle the join flow based on group type. Public groups are joined directly viaCometChat.joinGroup(). Password-protected groups show a password prompt first.
File: CometChatHome.tsx
Feature Matrix
| Feature | Component / Method | File |
|---|---|---|
| Open new chat view | onNewChatClicked() | CometChatHome.tsx |
| New chat interface | CometChatNewChatView | CometChatHome.tsx |
| User selection | CometChatUsers | CometChatHome.tsx |
| Group selection | CometChatGroups | CometChatHome.tsx |
| Group joining | joinGroup() | CometChatHome.tsx |
| State management | showNewChat state | appReducer.ts |
| Chat creation | setNewChat() | CometChatHome.tsx |
| Navigation handling | setShowNewChat(false) | CometChatHome.tsx |