Skip to main content

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.
1:1 conversations only. AI Agents currently respond only in one-on-one conversations between an end user and the agent user. They do not respond to messages sent in groups, even if the agent user is added as a member or owner. Group support is on the roadmap — share your use case on feedback.cometchat.com.

Minimal Render

Root CSS class: .cometchat-ai-assistant-chat

Actions and Events

Callback Props

onBackButtonClicked

Fires when the header back button is clicked. Requires showBackButton={true}.

onCloseButtonClicked

Fires when the header close button is clicked. Requires showCloseButton={true}.

onSendButtonClick

Fires when the composer send button is clicked.

onError

Fires when the component encounters an internal error.

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

emptyChatImageView

emptyChatGreetingView

emptyChatIntroMessageView

aiAssistantTools

Pass a CometChatAIAssistantTools 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:
  1. Global tokens (e.g., --cometchat-primary-color, --cometchat-background-color-01) set on the .cometchat root wrapper.
  2. Component CSS (.cometchat-ai-assistant-chat) consumes these tokens via var().
  3. Overrides target .cometchat-ai-assistant-chat descendant selectors.

Key Selectors

Example: Brand-themed AI assistant

Customization Matrix


Props

aiAssistantTools

Tool/function call handlers for the AI assistant.

emptyView

Custom empty state for the message list.

emptyChatGreetingView

Custom greeting title in the empty chat state. Default uses agent metadata greetingMessage or user name.

emptyChatImageView

Custom image in the empty chat state.

emptyChatIntroMessageView

Custom intro subtitle in the empty chat state. Default uses agent metadata introductoryMessage.

errorView

Custom error state view.

headerAuxiliaryButtonView

Replaces the header auxiliary buttons (New Chat, History).

headerItemView

Replaces the entire header list item.

headerLeadingView

Replaces the header avatar / left section.

headerSubtitleView

Replaces the header subtitle text.

headerTitleView

Replaces the header title text.

headerTrailingView

Replaces the header right section.

hideChatHistory

Hides the History button/sidebar.

hideNewChat

Hides the New Chat button in header.

hideSuggestedMessages

Hides the suggested messages section in the empty state.

loadLastAgentConversation

Loads the most recent existing agent conversation on mount.

loadingView

Custom loading state view.

onBackButtonClicked

Fires when the header back button is clicked. Requires showBackButton={true}.

onCloseButtonClicked

Fires when the header close button is clicked. Requires showCloseButton={true}.

onError

Fires on internal errors.

onSendButtonClick

Fires when the composer send button is clicked.

parentMessageId

Loads a specific agent conversation. Takes priority over loadLastAgentConversation.

showBackButton

Shows back button in header.

showCloseButton

Shows close button in header.

streamingSpeed

Characters-per-second speed for streaming replies.

suggestedMessages

Quick prompt suggestions displayed in the empty state.

templates

Custom message bubble templates. See CometChatMessageTemplate.

user

The AI agent user object. Must be fetched via CometChat.getUser() before passing.

CSS Selectors