Skip to main content

Quick Start

  1. Open your layout XML file.
  2. Add the CometChatAIAssistantChatHistory XML element:
What this does: Adds the CometChatAIAssistantChatHistory component to your layout. It fills the available width and height and renders the AI assistant chat history list.
  1. In your Activity or Fragment, create a User object with the role set to @agentic and pass it to the component:
What this does: Creates a User object with the @agentic role and sets it on the CometChatAIAssistantChatHistory component. This is required for the component to fetch and display the AI assistant chat histories for that user.
  1. Build and run your app.
  2. Verify that the AI assistant chat history list appears with past conversation items.

Core Concepts

  • CometChatAIAssistantChatHistory: The main component class that renders the AI assistant chat history list. It is a Composite Component that can be launched via button clicks or any user-triggered action.
  • Actions: Callbacks such as setOnItemClickListener, setOnItemLongClickListener, setOnNewChatClickListener, and setOnCloseClickListener that let you respond to user interactions.
  • Style: XML theme styles applied via setStyle() to customize colors, fonts, and visual appearance of the chat history.
  • Functionality: Methods like setUser, setErrorStateVisibility, and setEmptyStateVisibility that configure the component’s behavior and state visibility.

Actions and Events

Callback Methods

What you’re changing: How the component responds to user interactions such as taps, long-presses, new chat clicks, and close clicks.
  • Where: Activity or Fragment where you hold a reference to CometChatAIAssistantChatHistory.
  • Applies to: CometChatAIAssistantChatHistory.
  • Default behavior: Predefined actions execute automatically when the user interacts with the component.
  • Override: Call the corresponding setter method to replace the default behavior with your own logic.

setOnItemClickListener

Function invoked when a chat history item is clicked, used to open an AI assistant chat screen.
YourActivity.java
What this does: Replaces the default item-click behavior. When a user taps a chat history item, your custom lambda executes instead of the built-in navigation.

setOnItemLongClickListener

Function executed when a chat history item is long-pressed, allowing additional actions like delete or block.
YourActivity.java
What this does: Replaces the default long-press behavior. When a user long-presses a chat history item, your custom lambda executes.

setOnNewChatClickListener

Function triggered when the new chat button is clicked, used to start a new conversation with the AI assistant.
YourActivity.java
What this does: Replaces the default new-chat-click behavior. When the user taps the new chat button, your custom logic runs instead of the built-in action.

setOnCloseClickListener

Function activated when the close button is clicked, used to exit the chat history view.
YourActivity.java
What this does: Replaces the default close-click behavior. When the user taps the close button, your custom logic runs instead of the built-in exit action.
  • Verify: After setting an action callback, trigger the corresponding user interaction (tap, long-press, new chat, close) and confirm your custom logic executes instead of the default behavior.

Styling

What you’re changing: The visual appearance of the AI Assistant Chat History component using XML theme styles.
  • Where: themes.xml for style definitions, and your Activity/Fragment for applying the style.
  • Applies to: CometChatAIAssistantChatHistory.
  • Default behavior: The component uses its default style.
  • Override: Define a custom style in themes.xml, then call setStyle() on the component.
  • Code:
themes.xml
What this does: Defines a custom style CustomAIAssistantChatHistoryStyle that sets the background color to #FFFAF6 for the component, header, new chat area, date separator, and items. It applies a Times New Roman font to the header, new chat text, date separator, and item text. A helper style textStyleTimesNewRoman defines the font family.
What this does: Applies the CustomAIAssistantChatHistoryStyle theme to the CometChatAIAssistantChatHistory component, changing the background colors and fonts.
To know more such attributes, visit the attributes file.
  • Verify: The chat history component displays with the #FFFAF6 background color and Times New Roman font for header text, new chat text, date separator text, and item text.

Functionality

What you’re changing: Small functional customizations such as setting the user and toggling visibility of UI states.
  • Where: Activity or Fragment where you hold a reference to CometChatAIAssistantChatHistory.
  • Applies to: CometChatAIAssistantChatHistory.
  • Default behavior: All UI states are visible with default settings.
  • Override: Call the corresponding method on the component instance.
  • Verify: After calling setUser(user), confirm the component fetches and displays the AI assistant chat histories for that user. After calling a visibility method, confirm the corresponding UI state is shown or hidden.

Customization Matrix

Next Steps

Message List

Display messages in a conversation

Conversations

Browse recent conversations

Users

Browse and search available users

Search

Search across conversations and messages