- AI Assistant Chat History
- Chat History Management
- Contextual Responses
- Agent Detection
- Seamless Handoffs
Overview
Users can interact with AI agents through a dedicated chat interface that:- Provides intelligent responses based on conversation context.
- Maintains chat history for continuity.
- Seamlessly integrates with your existing user chat system.

Prerequisites
- Android Studio project with cometchat/cometchat-uikit-android and cometchat/chat-sdk-android in
build.gradle. - Internet permission in
AndroidManifest.xml. - Valid CometChat App ID, Region, and Auth Key configured via
UIKitSettings. - User logged in with
CometChatUIKit.login(). - AI Agent configured in your CometChat dashboard.
Components
| Component / Class | Role |
|---|---|
AIAssistantChatActivity | Main activity for AI agent chat. |
CometChatAIAssistantChatHistory | Displays previous AI conversation history. |
CometChatMessageList | Shows AI messages with threading support. |
CometChatMessageComposer | Input interface for AI conversations. |
CometChatMessageHeader | Header with AI agent info and controls. |
Integration Steps
Step 1 - Activity Setup
Create the AI Assistant chat activity with proper theme and layout configuration.AIAssistantChatActivity.kt
Step - 2 AIAssistantChatActivity layout:
AddCometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to your layout to enable a complete AI chat interface. Use the sample XML below as a reference for correct integration.
activity_ai_assistant_chat.xml
Step 3 - Style of Message List & Composer
Define custom styles for the message list and composer to differentiate AI agent chats.Step 4 - Initialize click listeners
Initialize click listeners of message header to handle new chat creation and chat history access.Step 5 - Create an activity for AIAssistantChatHistory component.
Create a new activity to hostCometChatAIAssistantChatHistory component and handle its interactions.
Step 6 - AIAssistantChatActivity layout:
AddCometChatAIAssistantChatHistory to your layout to enable access to AI chat history. Use the sample XML below as a reference for correct integration.
Step 7 - Launching AI Chat
Create intent and start AI Assistant chat from your main application.Implementation Flow Summary
| Step | Action |
|---|---|
| 1 | User selects AI agent from chat list |
| 2 | AIAssistantChatActivity launches |
| 3 | Parse intent data and detect agent chat (Role of user must be “@agentic”) |
| 4 | Initialize UI with AI-specific styling |
| 6 | Configure chat history and navigation |
| 7 | Launch chat with AI agent |
Customization Options
- Custom AI Assistant Empty Chat View: Customize the empty state view using
setAIAssistantEmptyChatGreetingView()method. - Streaming Speed: Adjust AI response streaming speed via
setStreamingSpeed()method. - AI Assistant Suggested Messages: Create custom list of suggested messages and set quick prompts using
setAIAssistantSuggestedMessages()method. - AI Assistant Tools: Set tools for the AI agent using
setAIAssistantTools()method.
Feature Matrix
| Feature | Implementation | UI Component |
|---|---|---|
| AI Chat Interface | AIAssistantChatActivity | Full chat screen |
| Chat History | CometChatAIAssistantChatHistory | Chat history screen |
Android AI Builder Sample
Explore this feature in the CometChat AI Builder:
GitHub → AI Builder
Android Sample App (Java)
Explore this feature in the CometChat SampleApp:
GitHub → SampleApp