AI Integration Quick Reference
AI Integration Quick Reference
CometChat.init() + CometChat.login() completed, AI features enabled in Dashboard
Event flow: Run Start -> Tool Call(s) -> Text Message Stream -> Run FinishedAgents only respond to text messages.
Sending a Message to an AI Agent
Send a text message to an agent’s UID like any other user:- Swift
Agent Run Lifecycle and Message Flow
When a user sends a text message to an Agent:- The platform starts a run and streams real-time events via
AIAssistantEventsDelegate - After the run completes, persisted Agentic Messages arrive via
CometChatMessageDelegate
Real-time Events
Events are received viaonAIAssistantEventReceived as AIAssistantBaseEvent objects, in this order:
Run Start and Run Finished are always emitted. Tool Call events only appear when tools are invoked. Card events (Card Start → Card → Card End) appear only when the agent produces a card, and repeat for each card. Text Message events are always emitted and carry the assistant’s reply incrementally.- Swift
Card Streaming Events
When an agent produces a card, it is delivered through three streaming events ononAIAssistantEventReceived. Each event is a subclass of AIAssistantBaseEvent — check the concrete type to handle it.
- Swift
Agentic Messages
After the run completes, these messages arrive viaCometChatMessageDelegate:
- Swift
AIAssistantMessage Elements
Once a run completes, the assistant’s reply is persisted as anAIAssistantMessage. Its content is exposed as an ordered list of blocks via getElements(), letting you render text and cards in the exact order the agent produced them. When getElements() is nil or empty, fall back to the plain text body.
Each
AIAssistantElement exposes:
- Swift
Next Steps
AI Chatbots
Set up AI-powered chatbots for automated conversations
AI Moderation
Automatically moderate messages with AI
AI User Copilot
AI-powered features like smart replies and conversation summaries
Send Messages
Send text messages that trigger AI Agent responses