AI Agent Component Spec
AI Agent Component Spec
| Field | Value |
|---|---|
| Package | @cometchat/chat-uikit-react |
| Key components | CometChatSearchMessages, CometChatMessageList, CometChatMessageComposer, CometChatMessageHeader |
| Init | CometChatUIKit.init(UIKitSettings) then CometChatUIKit.login("UID") |
| Purpose | Full-text message search across conversations with result routing and navigation |
| Sample app | GitHub |
| Related | All Guides |
Components
| Component / Class | Role |
|---|---|
CometChatSearchMessages | Main container for searching messages |
CometChatMessageList | Displays filtered messages based on search results |
CometChatMessageComposer | Supports navigation after selecting a search result |
CometChatMessageHeader | Displays search context and navigation controls |
Integration Steps
1. Search State Management
Track the current search keyword and the message ID to scroll to. When a new search is triggered, resetgoToMessageId so the list doesn’t jump to a stale result.
File: CometChatHome.tsx
2. Search Input
Render the search component and wire itsonSearch callback to update the keyword state. The placeholder text is localized.
File: CometChatHome.tsx
3. Search Result Integration
PasssearchKeyword and goToMessageId to CometChatMessageList. The list filters messages matching the keyword and highlights them. When goToMessageId is set, the list scrolls to that message.
File: CometChatHome.tsx
4. Navigate to Search Result
When a user taps a search result, setgoToMessageId to that message’s ID. The message list will scroll to and highlight the target message.
File: CometChatHome.tsx
handleResultClick to your message search result selection logic.
Feature Matrix
| Feature | Component / Method | File |
|---|---|---|
| Search input | CometChatSearchMessages | CometChatHome.tsx |
| Display results | CometChatMessageList | CometChatHome.tsx |
| Keyword highlighting | searchKeyword prop | CometChatHome.tsx |
| Navigate to result | goToMessageId | CometChatHome.tsx |
| State management | onSearch handler | CometChatHome.tsx |