Skip to main content

Overview

The AI Assistant Chat History component is a pre-built user interface element designed to display the conversation history between users and an AI assistant within a chat application. It provides a structured and visually appealing way to present past interactions, making it easy for users to review previous messages and context.

Usage

Integration

AIAssistantChatHistory, as a Composite Component, offers flexible integration options, allowing it to be launched directly via button clicks or any user-triggered action. The following code snippet exemplifies how you can seamlessly integrate the GroupMembers component into your application.
  • XML
    <com.cometchat.chatuikit.aiassistantchathistory.CometChatAIAssistantChatHistory
        android:id="@+id/cometchat_ai_assistant_chat_history"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
If you’re defining the Group members within the XML code, you’ll need to extract them and set them on the Group object using the appropriate method.
  • Java
  • Kotlin

User user = new User();
user.setUid("userId");
user.setName("User Name");
user.setRole("@agentic"); // User role must be @agentic to use AI Assistant features

binding.cometChatAiAssistantChatHistory.setUser(user);

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.
setOnItemClickListener
Function invoked when a chat history item is clicked, typically used to open an ai assistant chat screen.
  • Java
  • Kotlin
YourActivity.java

binding.cometchatAiAssistantChatHistory.setOnItemClickListener((view, position, message) -> {

        });

setOnItemLongClick
Function executed when a user item is long-pressed, allowing additional actions like delete or block.
  • Java
  • Kotlin
YourActivity.java
binding.cometchatAiAssistantChatHistory.setOnItemLongClickListener((view, position, message) -> {

        });

setOnNewChatClickListener
Function triggered when the new chat button is clicked, typically used to start a new conversation with the AI assistant.
  • Java
  • Kotlin
YourActivity.java
binding.cometchatAiAssistantChatHistory.setOnNewChatClickListener(() -> {

        });

setOnCloseClickListener
Function activated when the close button is clicked, usually to exit the chat history view.
  • Java
  • Kotlin
YourActivity.java
binding.cometchatAiAssistantChatHistory.setOnCloseClickListener(() -> {

        });

Customization

The AIAssistantChatHistory component offers a variety of customization options to tailor its appearance and functionality to better fit your application’s needs. These customizations are categorized into three main areas: Style, Functionality, and Advanced.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.
themes.xml
    <style name="CustomAIAssistantChatHistoryStyle">
        <item name="cometChatAIAssistantChatHistoryBackgroundColor">#FFFAF6</item>
        <item name="cometChatAIAssistantChatHistoryHeaderBackgroundColor">#FFFAF6</item>
        <item name="cometChatAIAssistantChatHistoryHeaderTextColor">?attr/cometchatTextColorPrimary</item>
        <item name="cometChatAIAssistantChatHistoryHeaderTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometChatAIAssistantChatHistoryNewChatBackgroundColor">#FFFAF6</item>
        <item name="cometChatAIAssistantChatHistoryNewChatTextColor">?attr/cometchatTextColorPrimary</item>
        <item name="cometChatAIAssistantChatHistoryNewChatTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometChatAIAssistantChatHistoryDateSeparatorTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometChatAIAssistantChatHistoryDateSeparatorTextColor">?attr/cometchatTextColorTertiary</item>
        <item name="cometChatAIAssistantChatHistoryDateSeparatorBackgroundColor">#FFFAF6</item>
        <item name="cometChatAIAssistantChatHistoryItemBackgroundColor">#FFFAF6</item>
        <item name="cometChatAIAssistantChatHistoryItemTextAppearance">@style/textStyleTimesNewRoman</item>
        <item name="cometChatAIAssistantChatHistoryItemTextColor">?attr/cometchatTextColorPrimary</item>
    </style>

    <style name="textStyleTimesNewRoman">
        <item name="android:fontFamily">@font/times_new_roman_regular</item>
    </style>
  • Java
  • Kotlin
binding.cometchatAiAssistantChatHistory.setStyle(R.style.CustomAIAssistantChatHistoryStyle);

To know more such attributes, visit the attributes file.

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can toggle the visibility of UI elements. Below is a list of customizations along with corresponding code snippets
MethodsDescriptionCode
setUserSets the user whose chat histories with the ai assistant need to be fetched. This is a required property for the component to function properly..setUser(user);
setErrorStateVisibilityUsed to toggle the visibility of the error state of the component.setErrorStateVisibility(View.GONE);
setEmptyStateVisibilityUsed to toggle the visibility of the empty state of the component.setEmptyStateVisibility(View.GONE);
I