Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
AI Integration Quick Reference
Where It Fits
CometChatAIAssistantChat is the top-level orchestrator for the AI assistant chat experience. It wires together CometChatMessageHeader, CometChatMessageList, CometChatMessageComposer, and the CometChatAIAssistantChatHistory sidebar. Register CometChatAIPlugin in the plugin registry so the message list renders AI assistant messages, tool call arguments, and tool call results correctly.
Minimal Render
.cometchat-ai-assistant-chat
Plugin Registration
RegisterCometChatAIPlugin in the CometChatProvider to enable AI message rendering in the message list:
agentic category:
assistant→CometChatAIAssistantBubble(completed AI response with markdown)toolArguments→CometChatToolCallArgumentBubble(tool call arguments as JSON)toolResults→CometChatToolCallResultBubble(tool call results as JSON)
Streaming Architecture
The AI assistant uses a sequential event queue to process streaming events:- SDK emits
AIAssistantBaseEventchunks viaCometChat.addAIAssistantListener CometChatAIStreamingServicequeues events and processes them sequentially- Text chunks are delayed by
streamingSpeedms for a typing effect CometChatStreamMessageBubblesubscribes viauseSyncExternalStorefor tear-free reads- The bubble shows “Thinking…” → tool execution text → streamed markdown content
Tool Calls
Register tool handlers viaCometChatAIAssistantTools:
Suggestion Pills
Suggestion pills appear in the empty state. They can come from:- The
suggestedMessagesprop (explicit) user.getMetadata().suggestedMessages(from user metadata)
Chat History Sidebar
The sidebar shows past AI conversations. Click a message to load that thread. Click “New Chat” to start fresh.Custom Greeting
Override the default greeting with a custom view:Actions and Events
Callback Props
onSendButtonClick
Called when a message is sent to the AI assistant.onError
Called when an error occurs (fetch failure, SDK error, etc.).Lazy Loading
CometChatAIAssistantChat is Tier 4 lazy — it’s not included in the initial bundle. Load it on demand:
CSS Architecture
The component uses CSS custom properties defined in@cometchat/chat-uikit-react/css-variables.css.
Key Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-ai-assistant-chat |
| Header | .cometchat-ai-assistant-chat__header |
| Message list wrapper | .cometchat-ai-assistant-chat__message-list-wrapper |
| Composer area | .cometchat-ai-assistant-chat__composer-area |
| Streaming (disabled) | .cometchat-ai-assistant-chat__composer-area--streaming |
| Empty state | .cometchat-ai-assistant-chat__empty-state |
| Suggestion pill | .cometchat-ai-assistant-chat__suggestion-pill |
| Stream bubble wrapper | .cometchat-ai-assistant-chat__stream-bubble-wrapper |
| Sidebar | .cometchat-ai-assistant-chat__sidebar |
| Sidebar overlay | .cometchat-ai-assistant-chat__sidebar-overlay |
Stream Message Bubble Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-stream-message-bubble |
| Thinking state | .cometchat-stream-message-bubble__thinking |
| Tool execution | .cometchat-stream-message-bubble__tool-execution |
| Content | .cometchat-stream-message-bubble__content |
| Error | .cometchat-stream-message-bubble__error |
AI Assistant Bubble Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-ai-assistant-bubble |
| Content | .cometchat-ai-assistant-bubble__content |
| Placeholder shimmer | .cometchat-ai-assistant-bubble__placeholder |
Tool Call Selectors
| Target | Selector |
|---|---|
| Argument bubble root | .cometchat-toolcall-argument-bubble |
| Argument item | .cometchat-toolcall-argument-bubble__item |
| Result bubble root | .cometchat-toolcall-result-bubble |
| Result code | .cometchat-toolcall-result-bubble__code |
Props
All props are optional unless noted otherwise.user
Required. The AI assistant user object. The component usesuser.getUid() as the chat ID for streaming events.
| Type | CometChat.User |
| Default | required |
streamingSpeed
Delay in milliseconds between text content chunks. Lower values feel faster; higher values feel more natural.| Type | number |
| Default | 30 |
aiAssistantTools
Tool handlers for function calls. When the AI invokes a tool, the corresponding handler is called with the parsed JSON arguments.| Type | CometChatAIAssistantTools |
| Default | undefined |
loadLastAgentConversation
Whentrue, automatically loads the most recent AI conversation on mount.
| Type | boolean |
| Default | false |
showSuggestedMessages
Whether to show suggestion pills in the empty state.| Type | boolean |
| Default | true |
suggestedMessages
Custom suggestion texts. Overridesuser.getMetadata().suggestedMessages.
| Type | string[] |
| Default | [] |
hideChatHistory
Hide the chat history sidebar button.| Type | boolean |
| Default | false |
hideNewChat
Hide the “New Chat” button.| Type | boolean |
| Default | false |
showBackButton
Show a back button in the header.| Type | boolean |
| Default | false |
showCloseButton
Show a close button in the header.| Type | boolean |
| Default | false |
greetingView
Custom greeting view shown in the empty state (replaces default greeting + intro text).| Type | ReactNode |
| Default | undefined |
emptyView
Custom empty state view (replaces the entire default empty state including greeting and suggestions).| Type | ReactNode |
| Default | undefined |
parentMessageId
Load a specific conversation thread by parent message ID.| Type | number |
| Default | undefined |
onSendButtonClick
Called when a message is sent.| Type | (message: CometChat.BaseMessage) => void |
| Default | undefined |
onBackButtonClicked
Called when the back button is clicked.| Type | () => void |
| Default | undefined |
onCloseButtonClicked
Called when the close button is clicked.| Type | () => void |
| Default | undefined |
onError
Called when an error occurs.| Type | (error: unknown) => void |
| Default | undefined |
CSS Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-ai-assistant-chat |
| Header | .cometchat-ai-assistant-chat__header |
| Header info | .cometchat-ai-assistant-chat__header-info |
| Header actions | .cometchat-ai-assistant-chat__header-actions |
| Header icon button | .cometchat-ai-assistant-chat__header-icon-btn |
| Body | .cometchat-ai-assistant-chat__body |
| Message list wrapper | .cometchat-ai-assistant-chat__message-list-wrapper |
| Empty state | .cometchat-ai-assistant-chat__empty-state |
| Empty state content | .cometchat-ai-assistant-chat__empty-state-content |
| Greeting | .cometchat-ai-assistant-chat__empty-state-greeting |
| Intro | .cometchat-ai-assistant-chat__empty-state-intro |
| Suggestions | .cometchat-ai-assistant-chat__empty-state-suggestions |
| Suggestion pill | .cometchat-ai-assistant-chat__suggestion-pill |
| Stream bubble wrapper | .cometchat-ai-assistant-chat__stream-bubble-wrapper |
| Composer area | .cometchat-ai-assistant-chat__composer-area |
| Composer streaming | .cometchat-ai-assistant-chat__composer-area--streaming |
| Sidebar | .cometchat-ai-assistant-chat__sidebar |
| Sidebar overlay | .cometchat-ai-assistant-chat__sidebar-overlay |
| Bubble copy footer | .cometchat-ai-assistant-chat__bubble-footer |
| Bubble copy button | .cometchat-ai-assistant-chat__bubble-copy-btn |