AI Integration Quick Reference
AI Integration Quick Reference
Overview
When the user is an agent — itsrole 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
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.- SwiftUI
- UIKit
AgentChatView.swift
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:- SwiftUI
- UIKit
Step 4 — Open a past conversation
Each conversation with an agent is a thread. To show one — from the chat history’sonItemClick (SwiftUI) or set(onMessageClicked:) (UIKit) — pass its first message as the
parent, as for any thread:
- SwiftUI
- UIKit
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
- SwiftUI
- UIKit
hideAiAssistantSuggestedMessages: truehides the suggested messages in an empty chat.loadLastAgentConversation: trueopens the latest conversation.- The composer’s
sendButtonViewreceivesisAIGenerating— disable your own button while it istrue; 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