AI Integration Quick Reference
AI Integration Quick Reference
Core Entities:
- Users: Identified by UID (alphanumeric with underscore/hyphen)
- Groups: Identified by GUID (alphanumeric with underscore/hyphen)
- Auth Token: Per user per device, generated server-side
- Roles: Categories for grouping similar users (e.g., “Premium”)
- Public: Any user can join
- Password: Requires password to join
- Private: Invitation only
- Admin: Full control (change scopes, kick/ban, update/delete group)
- Moderator: Moderate members (kick/ban participants, update group)
- Participant: Send and receive messages/calls
CometChat Dashboard
The CometChat Dashboard enables you to create new apps (projects) and manage your existing apps.How many apps to create?Ideally, you should create two apps—one for development and one for production. Use a single app regardless of the number of platforms.Do not create separate apps for every platform. If you do, your users on different platforms will not be able to communicate with each other!
- For every app, a unique App ID is generated. This App ID is required when integrating CometChat within your app.
- Along with the App ID, you need to create an Auth Key (from the Dashboard) which can be used for user authentication.
Auth & Rest API Keys
You can generate two types of keys from the dashboard.| Type | Privileges | Recommended Use |
|---|---|---|
| Auth Key | The Auth Key can be used to create & login users. | In your client side code (during development) |
| Rest API Key | The Rest API Key can be used to perform any CometChat operation. | In your server side code |
Users
A user is anyone who uses CometChat.UID
- Each user is uniquely identified using UID.
- The UID is typically the primary ID of the user from your database.
Auth Token
- A single user can have multiple auth tokens. Auth tokens should be per user per device.
- Auth tokens should ideally be generated via a server-to-server API call. The auth token should then be passed to CometChat for login.
- An Auth Token can only be deleted via the dashboard or using the REST API.
Authentication
To allow a user to use CometChat, the user must log in to CometChat. CometChat does not handle user management. You must handle user registration and login at your end. Once the user is logged into your app/site, you can log in the user to CometChat programmatically. The user never directly logs in to CometChat. CometChat does not handle friends management. If you want to associate friends with your users, you must handle friends management in your app. Once two users are friends (i.e., they have accepted each other as friends), you can associate them as friends in CometChat.Typical Workflow
| Your App | Your Server | CometChat |
|---|---|---|
| User registers in your app | You store the user information in your database (e.g. ID, name, email, phone, location etc. in users table) | You add the user to CometChat (only ID & name) using the Rest API |
| User logs in to your app | You verify the credentials, login the user and retrieve the user ID | You log in the user to CometChat using the same user ID programmatically |
| User sends a friend request | You display the request to the potential friend | No action required |
| User accepts a friend request | You display the users as friends | You add both the users as friends using the Rest API |
User Roles
A role is a category for a group of similar users. For example, you may want to group your premium users using the role “Premium”. You then use this to filter users or enable/disable features by writing conditional code.User List
- The User List can be used to build the Contacts or Who’s Online view in your app.
- The list of users can be different based on the logged-in user.
Groups
A group can be used for multiple users to communicate with each other on a particular topic/interest.GUID
- Each group is uniquely identified using GUID.
- The GUID is typically the primary ID of the group from your database. If you do not store group information in your database, you can generate a random string for use as GUID.
Group Types
CometChat supports three different types of groups:| Type | Visibility | Participation |
|---|---|---|
| Public | All users | Any user can choose to join |
| Password | All users | Any user with a valid password can choose to join |
| Private | Only users part of the group | Invited users will be auto-joined |
Members
Once a participant joins a group, they become a member of the group. Members are part of the group indefinitely i.e. they will keep receiving messages, calls & notifications. To stop, the participant must either be kicked, banned or intentionally leave the group.Member Scopes
CometChat supports three different types of member scopes in a group:| Member | Default | Privileges |
|---|---|---|
| Admin | Group creator is assigned Admin scope | - Change scope of Group Members to admin, moderator or participant. - Can add members to a group. - Kick & Ban Participants/Moderators/Admins - Send & Receive Messages & Calls - Update group - Delete group |
| Moderator | - | - Change scope of moderator or participant. - Update group - Kick & Ban Participants - Send & Receive Messages & Calls |
| Participant | Any other user is assigned Participant scope | - Send & Receive Messages & Calls |
Messaging
Any message in CometChat can belong to either one of the below categories.Message Categories
| Category | Types | Description |
|---|---|---|
message | text, image, video, audio, file | Standard messages |
custom | Developer-defined | Custom data sent to users/groups that does not fit default categories (e.g., location, polls) |
action | groupMember, message | System-generated messages when an action is performed on a group member or a message |
call | audio, video | Call-related messages |
Auto Mode Connection
Know more about auto mode connection click here
| App State | Behaviour |
|---|---|
| App in foreground | Connected with WebSocket |
| App in background | Immediately disconnected with WebSocket |
Manual Mode Connection
Know more about manual mode connection click here
| App State | Behaviour |
|---|---|
| App in foreground | Call CometChat.connect() to create the WebSocket connection |
| App in background | Disconnect the WebSocket connection if no ping is received within 30 seconds after the app goes in the background. |
Glossary
| Term | Definition | Learn More |
|---|---|---|
| UID | Unique User Identifier — alphanumeric string you assign to each user | Users Overview |
| GUID | Group Unique Identifier — alphanumeric string you assign to each group | Groups Overview |
| Auth Key | Development-only credential for quick testing. Never use in production | Authentication |
| Auth Token | Secure, per-user token generated via REST API. Use in production | Authentication |
| REST API Key | Server-side credential for REST API calls. Never expose in client code | CometChat Dashboard |
| Receiver Type | Specifies if a message target is a user or group | Send Message |
| Scope | Group member scope: admin, moderator, or participant | Change Member Scope |
| Listener | Callback handler for real-time events (messages, presence, calls, groups) | All Real-Time Listeners |
| Conversation | A chat thread between two users or within a group | Retrieve Conversations |
| Metadata | Custom JSON data attached to users, groups, or messages | Send Message |
| Tags | String labels for categorizing users, groups, conversations, or messages | Message Filtering |
| RequestBuilder | Builder pattern class for constructing filtered/paginated queries | Message Filtering |
| AppSettings | Configuration object for initializing the SDK (App ID, Region, presence) | Setup SDK |
| Transient Message | Ephemeral message not stored on server (typing indicators, live reactions) | Transient Messages |
| Interactive Message | Message with actionable UI elements (forms, cards, buttons) | Interactive Messages |
Next Steps
Setup SDK
Install and initialize the CometChat Android SDK
Authentication
Learn how to log users into CometChat
Send a Message
Start sending messages to users and groups
Create a Group
Create and manage groups in your application