Skip to main content
An AI agent is a CometChat user your dashboard configures to answer with AI. Chatting with one uses the same three components as any one-to-one chat; the Kit notices the agent and changes how they behave.

Overview

When the user is an agent — its role is @agentic — the components switch to agent mode on their own: The first message you send starts a conversation thread with the agent, and the rest of that conversation goes into it. Agents work in groups too: there the agent is a member, and its messages render like anyone else’s.

Prerequisites

  • The Kit is set up and a user is logged in — see Getting Started.
  • An AI agent configured in the CometChat dashboard — see AI Agents.

Integration Steps

Step 1 — Detect the agent

Route an agent to your agent chat screen; it is an ordinary one-to-one chat otherwise, so the same screen works for both.

Step 2 — The agent chat screen

Handle the header’s two buttons. New Chat starts a fresh conversation: build the list and the composer again so they drop the current thread.
AgentChatView.swift
Host the header and the composer over the list as Conversation List + Message View shows.

Step 3 — Reopen the last conversation (optional)

By default an agent chat opens on the greeting. To open the latest conversation with the agent instead:

Step 4 — Open a past conversation

Each conversation with an agent is a thread. To show one — from the chat history’s onItemClick (SwiftUI) or set(onMessageClicked:) (UIKit) — pass its first message as the parent, as for any thread:
Chat History opens CometChatAIAssistantChatHistory, which lists the past conversations and hands you the first message of the one the user picks.

Implementation Flow Summary

Customization Options

  • hideAiAssistantSuggestedMessages: true hides the suggested messages in an empty chat.
  • loadLastAgentConversation: true opens the latest conversation.
  • The composer’s sendButtonView receives isAIGenerating — disable your own button while it is true; the Kit does not block a custom button.

Feature Matrix

Next Steps

Message Composer

The composer in agent chats

Message List

Streaming replies and the greeting

AI Features

Conversation starters, smart replies and summaries

All Guides

Browse the other guides