AI Agent Component Spec
AI Agent Component Spec
Where It Fits
CometChatAIAssistantChat is a standalone AI chat panel. It composes an internal message header, message list, and message composer into a self-contained AI conversation experience. It requires a CometChat.User representing the AI agent.

Minimal Render
.cometchat-ai-assistant-chat
Actions and Events
Callback Props
onBackButtonClicked
Fires when the header back button is clicked. RequiresshowBackButton={true}.
| Detail | Value |
|---|---|
| When it fires | User clicks the back button |
| Payload type | () => void |
onCloseButtonClicked
Fires when the header close button is clicked. RequiresshowCloseButton={true}.
| Detail | Value |
|---|---|
| When it fires | User clicks the close button |
| Payload type | () => void |
onSendButtonClick
Fires when the composer send button is clicked.| Detail | Value |
|---|---|
| When it fires | User clicks the send button |
| Payload type | (message: CometChat.BaseMessage, previewMessageMode?: PreviewMessageMode) => void |
onError
Fires when the component encounters an internal error.| Detail | Value |
|---|---|
| When it fires | Any internal error during rendering or data fetching |
| Payload type | (error: CometChat.CometChatException) => void |
Global UI Events
The AI Assistant Chat component does not emit global UI events. Interaction handling uses the callback props above.SDK Events (Real-Time, Automatic)
The component internally manages SDK communication for AI streaming. No manual listener attachment needed.Custom View Slots
| Slot | Type | Replaces |
|---|---|---|
headerItemView | JSX.Element | Entire header list item |
headerTitleView | JSX.Element | Header title text |
headerSubtitleView | JSX.Element | Header subtitle text |
headerLeadingView | JSX.Element | Header avatar / left section |
headerTrailingView | JSX.Element | Header right section |
headerAuxiliaryButtonView | JSX.Element | Header auxiliary buttons (New Chat, History) |
emptyChatImageView | JSX.Element | Empty state image |
emptyChatGreetingView | JSX.Element | Empty state greeting title |
emptyChatIntroMessageView | JSX.Element | Empty state intro subtitle |
emptyView | JSX.Element | Message list empty state |
loadingView | JSX.Element | Loading state |
errorView | JSX.Element | Error state |
aiAssistantTools | CometChatAIAssistantTools | Tool/function call handlers |
templates | CometChatMessageTemplate[] | Message bubble templates |
emptyChatImageView

emptyChatGreetingView

- TypeScript
- CSS
emptyChatIntroMessageView

- TypeScript
- CSS
aiAssistantTools
Pass aCometChatAIAssistantTools instance to enable tool/function calls during assistant replies.
templates
Custom message templates to control message bubble rendering. See CometChatMessageTemplate.Common Patterns
AI assistant with suggestions and history
Minimal assistant — no chrome
CSS Architecture
The component uses CSS custom properties (design tokens) defined in@cometchat/chat-uikit-react/css-variables.css. The cascade:
- Global tokens (e.g.,
--cometchat-primary-color,--cometchat-background-color-01) set on the.cometchatroot wrapper. - Component CSS (
.cometchat-ai-assistant-chat) consumes these tokens viavar(). - Overrides target
.cometchat-ai-assistant-chatdescendant selectors.
Key Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-ai-assistant-chat |
| Wrapper | .cometchat-ai-assistant-chat__wrapper |
| Header wrapper | .cometchat-ai-assistant-chat__header-wrapper |
| Header auxiliary view | .cometchat-ai-assistant-chat__header-auxiliary-view |
| Message list wrapper | .cometchat-ai-assistant-chat__message-list-wrapper |
| Composer wrapper | .cometchat-ai-assistant-chat__composer-wrapper |
| Send button | .cometchat-ai-assistant-chat__send-button-view |
| Send button (active) | .cometchat-ai-assistant-chat__send-button-view--active |
| Send button (streaming) | .cometchat-ai-assistant-chat__send-button-view--streaming |
| Empty state | .cometchat-ai-assistant-chat__empty-state |
| Empty state content | .cometchat-ai-assistant-chat__empty-state-content |
| Empty state icon | .cometchat-ai-assistant-chat__empty-state-icon |
| Greeting message | .cometchat-ai-assistant-chat__empty-state-greeting-message |
| Intro message | .cometchat-ai-assistant-chat__empty-state-intro-message |
| Suggested messages | .cometchat-ai-assistant-chat__empty-state-suggested-messages |
| Suggestion pill | .cometchat-ai-assistant-chat__suggested-message-pill |
| Suggestion icon | .cometchat-ai-assistant-chat__suggested-message-icon |
| Chat history sidebar | .cometchat-ai-assistant-chat__sidebar |
| Sidebar open | .cometchat-ai-assistant-chat__sidebar--open |
| Sidebar overlay | .cometchat-ai-assistant-chat__sidebar-overlay |
| Copy button | .cometchat-ai-assistant-message-bubble__copy |
Example: Brand-themed AI assistant

Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Override behavior on user interaction | Component props | on<Event> callbacks | onBackButtonClicked={() => navigate(-1)} |
| Toggle visibility of UI elements | Component props | hide<Feature> / show<Feature> boolean props | hideNewChat={true} |
| Replace a section of the UI | Component props | View slot props | emptyChatGreetingView={<div>Hello</div>} |
| Change colors, fonts, spacing | Global CSS | Target .cometchat-ai-assistant-chat class | .cometchat-ai-assistant-chat .cometchat-ai-assistant-chat__suggested-message-pill { background: #30a46c; } |
Accessibility
The component composesCometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer internally. Keyboard navigation, focus management, and ARIA attributes are inherited from those components. Suggested message pills are keyboard-focusable and activate on Enter/Space. The chat history sidebar uses a backdrop overlay and traps focus when open.
Props
aiAssistantTools
| Key | Value |
|---|---|
| Type | CometChatAIAssistantTools |
| Default | undefined |
emptyView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
emptyChatGreetingView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
greetingMessage or user name.
emptyChatImageView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
emptyChatIntroMessageView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
introductoryMessage.
errorView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
headerAuxiliaryButtonView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
headerItemView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
headerLeadingView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
headerSubtitleView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
headerTitleView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
headerTrailingView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
hideChatHistory
| Key | Value |
|---|---|
| Type | boolean |
| Default | undefined |
hideNewChat
| Key | Value |
|---|---|
| Type | boolean |
| Default | undefined |
hideSuggestedMessages
| Key | Value |
|---|---|
| Type | boolean |
| Default | undefined |
loadLastAgentConversation
| Key | Value |
|---|---|
| Type | boolean |
| Default | false |
loadingView
| Key | Value |
|---|---|
| Type | React.JSX.Element |
| Default | undefined |
onBackButtonClicked
| Key | Value |
|---|---|
| Type | () => void |
| Default | undefined |
showBackButton={true}.
onCloseButtonClicked
| Key | Value |
|---|---|
| Type | () => void |
| Default | undefined |
showCloseButton={true}.
onError
| Key | Value |
|---|---|
| Type | (e: CometChat.CometChatException) => void |
| Default | undefined |
onSendButtonClick
| Key | Value |
|---|---|
| Type | (message: CometChat.BaseMessage, previewMessageMode?: PreviewMessageMode) => void |
| Default | undefined |
parentMessageId
| Key | Value |
|---|---|
| Type | number |
| Default | undefined |
loadLastAgentConversation.
showBackButton
| Key | Value |
|---|---|
| Type | boolean |
| Default | undefined |
showCloseButton
| Key | Value |
|---|---|
| Type | boolean |
| Default | undefined |
streamingSpeed
| Key | Value |
|---|---|
| Type | number |
| Default | undefined |
suggestedMessages
| Key | Value |
|---|---|
| Type | string[] |
| Default | undefined |
templates
| Key | Value |
|---|---|
| Type | CometChatMessageTemplate[] |
| Default | undefined |
user
| Key | Value |
|---|---|
| Type | CometChat.User |
| Default | — (required) |
CometChat.getUser() before passing.
CSS Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-ai-assistant-chat |
| Wrapper | .cometchat-ai-assistant-chat__wrapper |
| Header wrapper | .cometchat-ai-assistant-chat__header-wrapper |
| Header auxiliary view | .cometchat-ai-assistant-chat__header-auxiliary-view |
| Message list wrapper | .cometchat-ai-assistant-chat__message-list-wrapper |
| Composer wrapper | .cometchat-ai-assistant-chat__composer-wrapper |
| Send button | .cometchat-ai-assistant-chat__send-button-view |
| Send button (active) | .cometchat-ai-assistant-chat__send-button-view--active |
| Send button (streaming) | .cometchat-ai-assistant-chat__send-button-view--streaming |
| Empty state | .cometchat-ai-assistant-chat__empty-state |
| Empty state content | .cometchat-ai-assistant-chat__empty-state-content |
| Empty state icon | .cometchat-ai-assistant-chat__empty-state-icon |
| Greeting message | .cometchat-ai-assistant-chat__empty-state-greeting-message |
| Intro message | .cometchat-ai-assistant-chat__empty-state-intro-message |
| Suggested messages | .cometchat-ai-assistant-chat__empty-state-suggested-messages |
| Suggestion pill | .cometchat-ai-assistant-chat__suggested-message-pill |
| Suggestion icon | .cometchat-ai-assistant-chat__suggested-message-icon |
| Chat history sidebar | .cometchat-ai-assistant-chat__sidebar |
| Sidebar open | .cometchat-ai-assistant-chat__sidebar--open |
| Sidebar overlay | .cometchat-ai-assistant-chat__sidebar-overlay |
| Copy button | .cometchat-ai-assistant-message-bubble__copy |