|
# Chat & Messaging Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/chat-call Add real-time chat, voice & video calling to your apps in minutes. Choose your path: UI Kits, SDKs, or Widgets. {/* Hero Section */}
Add real-time chat and calls to your app in minutes. Choose the approach that fits your needs.
Use our pre-built UI kits or SDKs to add chat to your website or mobile app instantly.
Get a fully functional chat interface in minutes. Configure via our chat builder—no complex setup required.
{/*Build your own chat interface using individual components. Each component includes built-in chat logic.
{/*Build your own UI from scratch with our complete SDK feature set.
{/*Add chat to any website with a simple script tag. Perfect for customer support and community chat.
{/*Sync your user database with CometChat for a seamless experience.
See CometChat in action. Clone these sample apps to get started quickly.
3. Implement the chat functionality in your applications using [CometChat's **v4** Chat SDKs](/sdk/javascript/overview).
## How does it work?
CometChat AI analyzes the user's tone and writing style by reviewing recent messages sent by that user within the application.
The SDK includes a method for retrieving conversation starters in a chat. This method returns an array containing three potential starters for the conversation.
The number of messages to be fetched to generate relevant conversation starter is configurable. By default the CometChat AI takes the latest `1000` messages. This can be configured to specific timestamps as well.
| Configuration | Value |
| ------------- | ------------------------------------------------------ |
| lastNMessages | This will fetch specific number of messages. |
| fromTimestamp | This will fetch messages from a particular timestamp. |
| toTimestamp | This will fetch messages until a particular timestamp. |
3. Implement the chat functionality in your applications using [CometChat's **v4** Chat SDKs](/sdk/javascript/overview).
## How does it work?
CometChat AI goes through the messages of a conversation to understand the context of a conversation & provide a short summary of the conversation.
The CometChat SDK has a method to fetch the conversation summary. It returns the conversation summary as a string.
The number of messages to be fetched to generate relevant summaries is configurable. By default the CometChat AI takes the latest `1000` messages. This can be configured to specific timestamps as well.
| Configuration | Value |
| ------------- | ------------------------------------------------------ |
| lastNMessages | This will fetch specific number of messages. |
| fromTimestamp | This will fetch messages from a particular timestamp. |
| toTimestamp | This will fetch messages until a particular timestamp. |
| unreadOnly | This will fetch only the unread messages. |
### Set the GPT Model
Enter the name of the Open AI ChatGPT model that you intend to use.
### Save the Open AI Key
You can get the Open AI Key from your [Open AI Account](https://platform.openai.com/account/api-keys). This will be used by CometChat to interact with the Open AI APIs.
### Set a Custom Instruction
Custom Instruction is an information which gets added in each and every ChatGPT prompt made by the CometChat AI. Custom Instruction is app-level information you can add to describe your use-case & inform what kind of responses you need from the CometChat AI.
### Set the Temperature
The API is non-deterministic by default. This means that you might get a slightly different completion every time you call it, even if your prompt stays the same. Setting temperature to 0 will make the outputs mostly deterministic, but a small amount of variability will remain.
Lower values for temperature result in more consistent outputs, while higher values generate more diverse and creative results. Select a temperature value based on the desired trade-off between coherence and creativity for your specific application.
### Enable AI
Toggle on AI.
# Smart Replies
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/ai-user-copilot/smart-replies
**Smart Replies** enable the retrieval of an AI-generated response message within a conversation.
## Before you begin
1. Configure the AI settings through the CometChat dashboard as detailed in the [Overview section](/fundamentals/ai-user-copilot/overview).
2. Navigate to Chat > Features, under **AI User Copilot**, enable **Smart Replies**.
3. Implement the chat functionality in your applications using [CometChat's **v4** Chat SDKs](/sdk/javascript/overview).
## How does it work?
CometChat AI goes through the messages of a conversation to understand the context of a conversation & provide relevant replies. It returns three replies: `positive, negative & neutral`.
The CometChat SDK has a method to fetch the smart replies in a conversation. It returns an object of three replies with keys: `positive, negative & neutral`.
The number of messages to be fetched to generate relevant Smart Replies is configurable. By default the CometChat AI takes the latest `1000` messages. This can be configured to specific timestamps as well.
| Configuration | Value |
| ------------- | ------------------------------------------------------ |
| lastNMessages | This will fetch specific number of messages. |
| fromTimestamp | This will fetch messages from a particular timestamp. |
| toTimestamp | This will fetch messages until a particular timestamp. |
| unreadOnly | This will fetch only the unread messages. |
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Avatars extension.
## How does it work?
This extension allows the users to select an image for their avatar on CometChat.
Once the image file is selected for the avatar, it needs to be uploaded in the `base64` format. The extension hosts the image and updates its URL in the avatar section of the user's profile. Also, the avatar URL is sent back in the success response for being updated in your backend.
Image formats allowed by the extension are: `jpg`, `jpeg`, `png`, svg.
Make use of the `callExtension` method provided by the CometChat SDK as shown below.
## Before you begin
1. You may have an existing account created with Chatwoot. If not, sign up with [Chatwoot](https://app.chatwoot.com/app/auth/signup).
2. Do the following mandatory setup on Chatwoot:
1. To add Agent(s): [Click here](https://www.chatwoot.com/docs/user-guide/add-agent-settings)
2. To create a Channel and Inbox: [Click here](https://www.chatwoot.com/docs/product/channels/api/create-channel)
3. Only mention the name of the channel for now. The webhook URL can be skipped.
3. Get your Chatwoot Access token:
1. Once you have logged in, click on your avatar in the bottom left corner.
2. Scroll to the bottom of the Account settings section that opens up.
3. You should find the Access token.
4. Get the inbox id:
1. Once you have logged in, click on the Settings icon in the left bar.
2. Click on the "Inboxes" in the navigation.
3. Click on the Inbox that you want to set up for the CometChat support.
4. Copy the Inbox ID from the URL. For eg, if the URL is: `https://app.chatwoot.com/app/accounts/123/settings/inboxes/12128` then the Inbox ID is `12128.`
5. Get the Account ID:
1. While you have the settings open, click on the Account Settings in the navigation bar
2. Copy the Account ID from there.
6. The above details will be required during the Extension's settings.
## Extension settings
#### **On CometChat Dashboard**
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Chatwoot extension.
3. Open the Settings for this extension.
4. Enter the following details about your Chatwoot account (copied earlier):
1. Chatwoot Access token
2. Chatwoot Account ID
3. Chatwoot Inbox ID
5. Enter the user's UID on CometChat who's going to be the Customer Support contact.
6. Once you save the settings, a webhook URL will be generated for you.
#### On Chatwoot Dashboard
1. Go to the Settings and the Inboxes section.
2. Click on the settings icon for the inbox in use.
3. Paste the above copied URL in the Webhook URL section.
## How does it work?
* The end users of your app can send queries to the Customer Support user that you have set in the extension's settings.
* These queries will be forwarded to the configured Chatwoot inbox.
* When an agent replies to the queries, those will be sent over to CometChat and received by your end user.
* With this, your end users can communicate with each other as well as your Customer support team using the same Chat interface.
# Collaborative Document
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/collaborative-document
Learn how to collaborate using a document.
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Collaborative Document extension.
## How does it work?
### Initiating the session
Using the Collaborative Document extension is pretty straight-forward. As an initiator, you only have to create a session. The extension will handle the following for you:
1. Provide you with a link for collaboration.
2. Forward the link as an invitation to the receivers.
You can initiate the session in either one-on-one chat or a group chat. The session can be shared by simply submitting the `receiver` (uid/guid) and `receiverType` (user/group).
This extension uses the `callExtension` method provided by our SDKs.
The Collaborative document has the following editing features:
1. Bold
2. Italic
3. Underline
4. Strikethrough
5. Numbered list
6. Bulleted list
7. Indent and Outdent
You can export your document as:
1. Etherpad
2. HTML
3. Plain text
# Collaborative Whiteboard
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/collaborative-whiteboard
Connect with other users of the app and collaborate using a Whiteboard.
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Collaborative Whiteboard extension.
## How does it work?
### Initiating the session
Using the Collaborative Whiteboard extension is pretty straight-forward. As an initiator, you only have to create a session. The extension will handle the following for you:
1. Provide you with a link for collaboration.
2. Forward the link as an invitation to the receivers.
You can initiate a whiteboard in either one-on-one chat or a group chat. The session can be shared by simply submitting the `receiver` (uid/guid) and `receiverType` (user/group).
This extension uses the `callExtension` method provided by our SDKs.
Our whiteboard implementation provides the following features:
1. **Edit** a. Clear board b. Undo c. Redo
2. **Tools** a. Mouse pointer b. Select an area c. Pen d. Line e. Rectangle f. Circle g. Text h. Eraser
3. **Tool properties** a. Thickness b. Color
4. **Upload image to whiteboard**
5. **Export whiteboard as image**
# Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/data-import-and-migration-overview
Data import and migration, in the context of CometChat, involves transferring your existing chat-related data from your own servers or another chat service provider to the CometChat platform. This process typically encompasses the migration of users, their messages, any chat groups, and the list of members within those groups. The goal of migration is to ensure a seamless transition and continuity of the chat service for your users.
CometChat offers the follow ways to migrate your data:
### 1. [Import historical data](/fundamentals/import-historical-data)
This process is designed to transfer all of your pre-existing data at rest, that is, the data that is stored and not currently in transit, from your existing database to the CometChat database. This transfer is made possible through the use of CometChat's Data Import APIs, which are designed to handle the ingestion of large volumes of historical chat data, including users, messages, and group information.
### 2. [Live data migration](/fundamentals/live-data-migration)
Live data migration is a process designed to minimize service disruption during the transition from one chat system to CometChat. It ensures that users who have updated their applications and are now on the new system (CometChat) can still communicate seamlessly with users who have not yet updated their applications and are on the old system. This approach is crucial for maintaining uninterrupted communication between all users throughout the migration period.
# Disappearing Messages
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/disappearing-messages
The Disappearing Messages extension allows end-users to send messages that disappear after a certain interval of time. This extension works for both private (one-on-one) and group messages.
This extension is also known as exploding messages on some platforms.
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Disappearing messages extension.
## How does it work?
Once the messages are sent, you can immediately schedule them for deletion using the disappearing messages extension. The message with the mentioned `msgId` gets deleted at `timeInMS`.
## Save users' Email IDs
You can use our to set private metadata for a user. We recommend adding this code where you call our .
Alternatively, just for the sake of testing purposes, you can add this from the CometChat Dashboard as well.
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the "Users" section.
3. Select any user of your choice and select the "Profile" tab.
4. Paste the below JSON in the Metadata input box and hit Save.
The Metadata is a JSON that should have the `@private` key present and should have the value `email` specified for the user. The format for the private metadata must be as follows:
* [Create a free account](https://app.cometchat.com/signup) with CometChat.
* Familiarize yourself with the [key concepts](/fundamentals/key-concepts).
* Send invitations to other developers, product owners for collaboration.
### 2. Integrate the chosen UI Kit or SDK into your application
* Choose to integration CometChat in your app either by using UI Kits or SDKs.
* Have a look at our Sample apps for quickly checking out features and functionalities.
* UI Kits: [React](/ui-kit/react/overview), [React Native](/ui-kit/react-native/overview), [iOS](/ui-kit/ios/overview), [Android](/ui-kit/android/overview), [Flutter](/ui-kit/flutter/overview), [Angular](/ui-kit/angular/overview), [Vue](/ui-kit/vue/overview)\
SDKs: [JavaScript](/sdk/javascript/overview), [React Native](/sdk/react-native/overview), [iOS](/sdk/ios/overview), [Android](/sdk/android/overview), [Flutter](/sdk/flutter/overview), [Ionic/Capacitor](/sdk/ionic/overview) & [Sample apps](https://github.com/cometchat)
### 3. Synchronize users and groups utilizing the APIs
* This step involves the backend side of implementation.
* When a new user signs up in your system, create the corresponding user's entry with CometChat using APIs.
* Whenever a user's details are updated in your system, synchronize them with CometChat.
* [Create users API](/rest-api/users/create)
* [Update users API](/rest-api/users/update)
### 4. Enable necessary extensions
* Enable extensions like [Thumbnail generator](/fundamentals/thumbnail-generation), [Message translation](/fundamentals/message-translation), etc.
* Implement the frontend for these [extensions](/fundamentals/extensions-overview) in case the implementation does not exist.
### 5. Implement Push notifications
* Drive user engagement in your applications through the integration of [Push Notifications](/notifications/push-overview).
### 6. Integrate CometChat AI
* Ignite natural and organic converstaions between your users.
* [CometChat AI](/fundamentals/ai-user-copilot/overview)
### 7. Set up bots
* [Bots](/ai-chatbots/overview) are unique users capable of autonomously sending and receiving messages. You can define a bot's behaviour by implementing and exposing your business logic using Callback URLs.
### 7. Set up webhooks
* [Webhooks](/fundamentals/webhooks-overview) faciliate real-time event-driven communication with your system, enabling you to receive HTTP POST requests from CometChat that carry details about different events.
### 9. Secure user logins with authentication tokens
* Ensuring safe and secure authentication of users in CometChat is crucial. Achieve this by utilizing [auth tokens](https://api-explorer.cometchat.com/reference/create-authtoken).
* Generate and retrieve the [auth token](https://api-explorer.cometchat.com/reference/create-authtoken) through your backend system, then supply it to the frontend.
### 10. Set up data import and migration
* To seamlessly transition from your existing chat solution to CometChat's comprehensive solution, you will need to [import your existing data](/fundamentals/import-historical-data) as well as migrate the [live data](/fundamentals/live-data-migration) to CometChat.
### 11. Launch your applications with the new messaging capabilities
* Delete default/test users and groups.
* Select a correct billing plan.
* Go live with your apps powered by CometChat.
* [CometChat Dashboard](https://app.cometchat.com).
# Import Historical Data
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/import-historical-data
The CometChat message import API allows application owners and admins to import existing chat messages data from any source into CometChat.
## General Instructions:
1. The authentication mechanism for these APIs follows the same authentication as all public CometChat REST APIs. Please use your app REST API Key in the header.
2. The Base URL for the APIs is `https://
## Before you begin
1. You may have an existing account created with Intercom. If not, sign up with [Intercom](https://intercom.com).
2. Create a test workspace by following these [steps](https://www.intercom.com/help/en/articles/188-create-a-test-workspace-in-intercom) from Intercom's documentation.
3. Once that is done, go back to the settings and expand the Developers section.
4. Click on DeveloperHub and create an app.
5. Select the newly created app and go to the Authentication section.
6. Copy the Access token as this will be required later.
#### On Intercom Developer Hub
1. Copy the above auto-generated Webhook URL and paste it in the Webhooks section on the Intercom Developer Hub.
2. From the Webhook Topics, select `conversation.admin.replied`
## How does it work?
The end users of your app can send queries to the Custom Support user that you have set in the extension's settings.
These queries will be forwarded to the Intercom dashboard.
Similarly, messages sent from Intercom dashboard by the support team or admin will be sent over to CometChat and received by your end user.
With this, your end users can communicate with each other as well as your Custom support team using the same Chat interface.
# Key Concepts
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/key-concepts
## Dashboard
* The CometChat Dashboard enables you to create new apps (projects) and manage your existing apps.
* Ideally, you should create two apps - one for development and one for production.
* 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 (`appId`) is generated. This `appId` will be required when integrating CometChat within your app.
## Users
* In CometChat, a "user" refers to anyone who utilizes the service for communication.
* Each user is uniquely identified using `uid`.
* The `uid` is typically the primary ID of the user from your database.
* A `uid` can be alphanumeric with underscore (`_`) and hyphen (`-`). Spaces, punctuation and other special characters are not allowed.
### 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.
## Authentication
* For a user to engage with other users using CometChat, they must be authenticated and logged into CometChat's system, typically after they have logged into your application or website.
* **CometChat does not take care of user management** tasks such as registration and login processes. These aspects must be managed within your own application or website. Once a user is logged into your service, you can then programmatically log them into CometChat, ensuring that users never have to log into CometChat directly.
* Similarly, **CometChat does not manage friendships or contacts** within its platform. If your application requires a feature where users can add each other as friends, this must be handled on your end. After two users have established a mutual friend connection in your application, you can then reflect this relationship within CometChat, linking them as friends in the messaging system.
### Auth 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 |
### Auth & Rest API Keys
* From the CometChat dashboard, you can generate two types of keys.
* Each key serves a distinct purpose and provides different levels of access to the CometChat platform, ensuring that your application's interaction with CometChat is secure and appropriate permissions are maintained.
| 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 |
### Auth token
* Auth tokens are associated with users in CometChat. A single user can have multiple auth tokens. The auth tokens should be **per user per device**.
* It should be generated by API call ideally, via server to server call. The auth token should then be given to CometChat for login.
* An Auth Token can only be deleted via dashboard or using REST API.
## Groups
* A group in CometChat is a feature that allows multiple users to engage in conversations about specific topics or shared interests. It facilitates collective communication and collaboration among its members.
* 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`.
* A `guid` can be alphanumeric with underscore (`_`) and hyphen (`-`). Spaces, punctuation and other special characters are not allowed.
### 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 |
### Group members
* After joining a group on CometChat, a participant is considered a member of that group.
* This membership is ongoing, meaning they will continue to receive messages, calls, and notifications from the group indefinitely.
* If a member no longer wishes to receive these communications, they must actively leave the group or be removed by being kicked out or banned by a group administrator.
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 | A participant can be made a 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
Every message in CometChat belongs to either one of the five categories:
1. Message
2. Custom
3. Action
4. Call
5. Interactive
Each category can be further be classified into types.
### Message
The category `message` can be used to send messages of the following types:
1. `text` - A plain text message
2. `image`- An image message
3. `video`- A video message
4. `audio`- An audio message
5. `file`- A file message
### Custom
* In the case of messages that belong to the `custom` category, there are no predefined types.
* Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat.
* For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message.
* A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
### Action
Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types:
1. `groupMember` - action performed on a group member.
2. `message` - action performed on a message.
Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below:
1. `joined` - when a group member joins a group
2. `left` - when a group member leaves a group
3. `kicked` - when a group member is kicked from the group
4. `banned` - when a group member is banned from the group
5. `unbanned` - when a group member is unbanned from the group
6. `added` - when a user is added to the group
7. `scopeChanged` - When the scope of a group member is changed.
For the type `message`, the action can be either one of the below:
1. `edited` - when a message is edited.
2. `deleted` - when a message is deleted.
### Call
Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types
1. `audio`
2. `video`
The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values:
1. `initiated` - when a is initiated to a user/group
2. `ongoing` - when the receiver of the call has accepted the call
3. `canceled` - when the call has been canceled by the initiator of the call
4. `rejected` - when the call has been rejected by the receiver of the call
5. `unanswered` - when the call was not answered by the receiver.
6. `busy` - when the receiver of the call was busy on another call.
7. `ended` - when the call was successfully completed and ended by either the initiator or receiver.
### Interactive
Messages with the category `interactive` are useful where users can perform some action without leaving the conversation. Interactive messages can be of the following types:
1. `form`
2. `card`
3. `scheduler`
4. `customInteractive`
# Limits
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/limits
To ensure a reliable and seamless chat experience while minimizing downtime and errors, certain limits are in place.
You can fetch the details for the Link Preview using `getMetadata()` method.
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Message shortcuts extension.
3. Open the settings for this extension.
4. You should a list of Global Message shortcuts.
5. Edit the existing shortcuts or add new ones.
6. Save your settings.
## How does it work?
The shortcuts saved in the Extension's settings are Global message shortcuts that can be accessed by all the users of your app. The shortcuts saved by users are accessible only to them along with the Global message shortcuts.
With the Message Shortcuts extension, you can:
1. Fetch all shortcuts on your user's device.
2. Allow users to edit, define or delete shortcuts.
3. Send predefined message by typing shortcuts.
## Implementation
### 1. Fetch all shortcuts
Once the user has successfully logged in, you can request the shortcuts from the extension. Additionally, you can provide a button to refresh the shortcuts.
Make use of the `callExtension` method exposed by the CometChat SDK to fetch the shortcuts.
## 2. Receiving a poll
Polls are custom messages. So, you have to implement our `onCustomMessageReceived` listener in order to receive the Poll-related message. Please refer to our [Receive Messages](/sdk/javascript/receive-message) documentation under the SDK of your choice.
The `metadata` stores all the information about the poll. You will find the following details in `metadata` -> `@injected` -> `extensions` -> `polls`.
| Key | Value |
| -------- | ------------------------------------------------------------------------------------ |
| id | A String representing a unique ID for the poll. |
| options | An Object with the option number as the key and the option description as the value. |
| question | A string representing the question asked in the poll. |
| results | An object that stores voting results. |
Apart from the above Poll-related details, the `metadata` will also contain `incrementUnreadCount` with value as `true`. This will be useful for incrementing the unread count every time a poll is received.
## 3. Voting in a poll
Voting in a poll simply requires you to provide the `id` of the poll and the option you intend to vote for. The `vote` parameter is basically the option number.
You can allow users to vote for a poll by using the `callExtension` method provided by our SDKs:
## 4. Getting Results
There are 2 ways to fetch the results of the poll:
1. Real-time updates from the `metadata`
2. Fetch the results by using the `callExtension` method.
### Real-time updates
As mentioned earlier, a Poll is a message of the category: `custom`. When the votes are cast by the users, the metadata for the message will be updated accordingly. To get real-time voting information, you need to implement the `onMessageEdited` listener. Please check our [Edit message](/sdk/javascript/edit-message) documentation under the SDK of your choice.
The updated details will be available in the metadata of the message. Here is a sample response:
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Reactions extension.
## How do reactions work?
A user can react to a message using multiple emojis.
To allow a user to react to a message, show a popup with all the available emojis. Once the user clicks on a particular emoji, add that emoji as a reaction to the target message.
If a user has reacted to a message using a certain emoji and clicks on the same emoji, remove it from the target message.
Sending Reactions
To add a reaction using selected emoji, use the `callExtension` method provided by our SDKs as follows:
## Extension Settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Reminders extension.
3. Go to the Users section and create a new user with `cc_reminder_bot` as the UID. The name and Avatar can be of your choice.
Users can choose to be reminded about a message from a conversation or set some sort of custom personalized reminder.
When the reminder is due, `cc_reminder_bot` will send a message to the user.
Users can then list, edit or delete reminders.
### Set reminders
The following parameters are required for setting a reminder
| Parameter | Value | Description |
| ---------- | -------------- | ----------------------------------------------------------------------------------------- |
| `about` | Integer/String | `Integer` => For setting a message reminder. `String` => For setting a personal reminder. |
| `isCustom` | Boolean | `false` => For setting a message reminder. `true` => For setting a personal reminder. |
| `timeInMS` | Integer | Unix timestamp: (e.g.: `1638351344989`) |
#### Message reminders
To set Message reminders, the `about` should be an integer corresponding to the message id. The `isCustom` value should be set to`false`.
In order to set the reminders, use the `CometChat.callExtension` method as shown below:
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Stickers extension.
3. Open the Settings for this extension.
4. Click on Save to start using Stickers with in your app.
CometChat provides 14 Default Sets of stickers for your use. Apart from these 14 sets, you can also create your own sets. Moreover, you can also choose stickers from each set as per your liking and use only those in your app.
## How does it work?
### Loading stickers
Before you start Sending or Receiving stickers in your app, you first have to load the Sticker Sets. In your app, you can add a section/drawer that shows the enabled stickers. A user can click on any of these stickers to send it in a chat.
In order to load stickers, you can use the `callExtension` method provided by our SDKs.
### Steps:
1. Log in to your [CometChat Dashboard](https://app.cometchat.com/login) and select your app.
2. Go to **Settings** > **Legacy Webhooks** from the left menu.
3. Click on **Add New Webhook**.
4. Fill in the configuration:
* **Webhook ID**: A unique identifier for your webhook.
* **URL**: Endpoint where event payloads will be delivered.
* **Triggers**: Select the events you want to receive.
* **Security**: (Recommended) Enable authentication.
5. Enable the webhook.
6. Save the configuration.
***
## Option 2: Manage via Management APIs
CometChat also provides Management APIs to automate webhook and trigger management.
### Webhook Management Endpoints
| Operation | API Reference |
| -------------------------- | ----------------------------------------------------------------------------- |
| Create a new webhook | [Create Webhook](https://api-explorer.cometchat.com/reference/create-webhook) |
| Update an existing webhook | [Update Webhook](https://api-explorer.cometchat.com/reference/update-webhook) |
| List all webhooks | [List Webhooks](https://api-explorer.cometchat.com/reference/list-webhooks) |
| Get a webhook by ID | [Get Webhook](https://api-explorer.cometchat.com/reference/get-webhook) |
| Delete a webhook | [Delete Webhook](https://api-explorer.cometchat.com/reference/delete-webhook) |
### Trigger Management Endpoints
| Operation | API Reference |
| ------------------------------ | ------------------------------------------------------------------------------- |
| Add triggers to a webhook | [Add Triggers](https://api-explorer.cometchat.com/reference/add-triggers) |
| List all triggers of a webhook | [List Triggers](https://api-explorer.cometchat.com/reference/list-triggers) |
| Remove triggers from a webhook | [Remove Triggers](https://api-explorer.cometchat.com/reference/remove-triggers) |
***
Choose the method that best suits your workflow—dashboard for manual setup or APIs for automated, scalable integration.
# Legacy Webhooks Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/webhooks-legacy-overview
CometChat legacy webhooks enable real-time event-driven communication with your system. They allow you to receive HTTP POST requests whenever specific events occur—such as sending a message or a user coming online. These webhooks are ideal for integrating external services like SMS, email, analytics, or auditing systems.
***
## Webhook Endpoint Requirements
To ensure reliable delivery and security, your webhook endpoint must meet the following requirements:
1. **HTTPS Required**: Your endpoint must use `HTTPS` to ensure secure data transmission.
2. **Public Accessibility**: It must be accessible from the public internet.
3. **Support for POST Requests**: The endpoint must accept `HTTP POST` requests with a `Content-Type` of `application/json`.
4. **Immediate Acknowledgment**: Your server must respond with an `HTTP 200 OK` status quickly to acknowledge receipt.
***
## Security
It is strongly recommended to use **Basic Authentication** to protect your webhook endpoints.
### Header Format
When enabled, every webhook request from CometChat will include the following HTTP header:
```html
Authorization: Basic
***
## Option 2: Managing Webhooks via Management APIs
If you prefer automation or need to manage webhooks programmatically, you can use our REST APIs.
### Webhook Operations
| Operation | API Reference |
| -------------------------- | --------------------------------------------------------------------------------- |
| Create a new webhook | [Create Webhook](https://api-explorer.cometchat.com/reference/create-webhook-api) |
| Update an existing webhook | [Update Webhook](https://api-explorer.cometchat.com/reference/update-webhook-api) |
| List all webhooks | [List Webhooks](https://api-explorer.cometchat.com/reference/list-webhooks-api) |
| Get webhook by ID | [Get Webhook](https://api-explorer.cometchat.com/reference/get-webhook-api) |
| Delete a webhook | [Delete Webhook](https://api-explorer.cometchat.com/reference/delete-webhook-api) |
### Trigger Operations
| Operation | API Reference |
| ------------------------------ | ----------------------------------------------------------------------------------- |
| Add triggers to a webhook | [Add Triggers](https://api-explorer.cometchat.com/reference/add-triggers-api) |
| List triggers for a webhook | [List Triggers](https://api-explorer.cometchat.com/reference/list-triggers-api) |
| Remove triggers from a webhook | [Remove Triggers](https://api-explorer.cometchat.com/reference/remove-triggers-api) |
***
Choose the method that best fits your use case—Dashboard for quick setup, or APIs for advanced and automated configurations.
# Webhooks Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/fundamentals/webhooks-overview
CometChat Webhooks enable real-time, event-driven communication with your server by sending HTTP POST requests for specific events such as messages, user actions, group updates, calls, and moderation results.
You can use webhooks to build custom workflows such as sending SMS or email notifications, logging activity, syncing with external systems, or triggering automation.
***
## Setting Up Your Webhook Endpoint
To successfully receive and process events from CometChat, your webhook endpoint must meet the following criteria:
1. **Use HTTPS** – All webhook URLs must be secured with SSL.
2. **Be publicly accessible** – Your server should be reachable from the internet.
3. **Support POST method** – Events will be delivered as `HTTP POST` requests with `application/json` content.
4. **Return a 200 OK** – Your endpoint must acknowledge receipt by responding with `HTTP 200`.
***
## Securing Your Webhook
### Basic Authentication (Recommended)
To ensure only authorized systems can access your endpoint, use Basic Authentication:
```html
Authorization: Basic
To access media files, use the media URL from the webhook payload to obtain a URL secured with a file access token (FAT). This URL redirects to a pre-signed URL that remains valid for 5 minutes.
**Sample request:**
```html
curl --location 'https://files-Seamlessly integrate real-time chat, voice, and video functionalities.
Quick links to deeper integration guides, API references, and community support.
You can also set this up from your end using the [List Moderation Blocked Message List REST API](https://api-explorer.cometchat.com/reference/list-moderation-blocked-messages).
### Approve Blocked Message
Allows the approval of messages previously blocked due to moderation violations.
You can also set this up from your end using the [Approve Blocked Message REST API](https://api-explorer.cometchat.com/reference/approve-moderation-blocked-messages).
# Constraints And Limits
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/constraints-and-limits
## Constraints
### Rule Management
Here are the constraints for managing rules within the system:
| Parameter | Constraint |
| ------------------- | ------------------------------------------------------------------------- |
| **Rule ID** | No spaces or special characters allowed, Maximum length of 100 characters |
| **Name** | Maximum length of 100 characters |
| **Description** | Maximum length of 255 characters |
| **Rule Filters** | Each rule can have a maximum of 10 filters |
| **Rule Conditions** | Each rule can have a maximum of 10 conditions |
| **Rules per app** | An app can have up to 25 rules (exluding default rules) |
### Lists Management
Here are the constraints for managing lists within the system:
| Parameter | Constraint |
| ----------------- | ------------------------------------------------------------------------- |
| **ID** | No spaces or special characters allowed, Maximum length of 100 characters |
| **Name** | Maximum length of 100 characters |
| **Description** | Maximum length of 255 characters |
| **CSV File** | Accepted file size: up to 1 MB |
| **Lists per app** | An app can have up to 25 lists (excluding the default lists) |
## Limitations
* Make sure the SDK version you are using is 3.0 or higher.
* AI Image moderation currently supports & moderates JPEG and PNG image formats.
* AI video moderation currently supports & moderates MP4, MOV, and AVI formats.
* If a message is marked as delivered/read and previous messages include pending/disapproved ones, those will also be automatically marked as delivered/read, even though they haven't actually been delivered to the receiver.
# Custom API Moderation
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/custom/custom-api
CometChat allows you to integrate your own moderation logic using a **Custom API**. With this feature, you can define a webhook URL in the **List Configuration**, where CometChat will send messages for moderation along with relevant context from the conversation (if provided in settings).
## **How It Works**
1. When a user sends a message, CometChat retrieves the webhook URL from the configured **List**.
2. The message, along with previous conversation messages (if a context window is set in settings), is sent to the webhook.
3. The webhook (your external API) processes the data using your custom moderation logic.
4. The webhook responds with a structured decision containing details about the moderation outcome.
5. CometChat processes the response and applies the moderation decision in real-time.
This approach gives you complete control over moderation, allowing you to implement **custom filtering, AI-based analysis, or any other logic** on your own servers.
## Integration
### Step 1: Configure Custom API Settings
1. **Login to the CometChat Dashboard**
* Navigate to [CometChat Dashboard](https://app.cometchat.com) and select your app.
2. **Navigate to Moderation Settings**
* Go to **Moderation → Settings** in the left-hand menu.
3. **Open Custom API Settings Tab**
* Click on the **Custom API** tab within the Moderation Settings.
4. **Fill in the Custom API Configuration**
* **Set Action on API Error**
* Define how the system should respond if the Custom API is unavailable (e.g., "Allow message" or "Block message").
* **Set Context Window**
* Specify the number of previous messages in a conversation that will be used for context.
5. **Click Save Settings**
### Step 2: Enable Custom API Moderation
1. Navigate to **Moderation → Rules**.
2. Click **"Create New Rule"**.
3. Select **Custom API** as the moderation type.
4. The rule you create should be of type **"Text Contains"** or **"Image Contains"**.
5. Save the rule.
## Payload Sent to Webhook
When a message is sent, CometChat invokes your webhook with a payload that includes:
* he latest message (the one just sent) — provided in full detail (entire message object)
* The previous messages — provided as plain text only, for context (based on the context window setting)
This structure allows you to apply moderation logic to the current message while considering its surrounding context.
```json
{
"contextMessages": [
{
"cometchat-uid-1": "Hello there!"
},
{
"cometchat-uid-2": "Hey, how are you?"
},
{
"cometchat-uid-1": "Let's team up."
},
{
"cometchat-uid-2": {
"id": "30431",
"muid": "_r49ocm6oj",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "message",
"type": "text",
"data": {
"text": "ok",
"resource": "WEB-4_0_10-04aecbad-8354-4fc8-98df-d0119e1a9539-1747717193939",
"entities": {
"sender": {
"entity": {
"uid": "cometchat-uid-1",
"name": "Andrew Joseph",
"avatar": "https://data-us.cometchat-staging.com/assets/images/avatars/andrewjoseph.png",
"status": "available",
"role": "default",
"lastActiveAt": 1747717203
},
"entityType": "user"
},
"receiver": {
"entity": {
"uid": "cometchat-uid-2",
"name": "George Alan",
"avatar": "https://data-us.cometchat-staging.com/assets/images/avatars/georgealan.png",
"status": "offline",
"role": "default",
"lastActiveAt": 1721138868,
"conversationId": "cometchat-uid-1_user_cometchat-uid-2"
},
"entityType": "user"
}
},
"moderation": {
"status": "pending"
}
},
"sentAt": 1747717214,
"updatedAt": 1747717214,
}
}
]
}
```
## Webhook Response Format
The webhook should return a response in the following format:
```javascript
{
isMatchingCondition: true, // True if the message violates the rule
confidence: 0.95, // Confidence score of the decision
reason: "Contains hate speech" // Reason for flagging
}
```
# Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/custom/custom-api-overview
CometChat offers AI-powered message moderation to help maintain a safe and respectful chat environment. You can choose between two moderation options:
### **Custom API Moderation**
If you prefer to use a third-party moderation service or your own AI model, CometChat enables integration via a **Custom Moderation API**. With this option, you can:
* **Set Up a Webhook** – Configure an endpoint where messages will be sent for moderation.
* **Customize Authentication** – Add security layers like basic authentication.
* **Contextual Moderation** – Define how many previous messages from the conversation should be included in the webhook request for better analysis.
* **Process Moderation Decisions** – CometChat processes the webhook response and applies moderation actions accordingly.
This moderation provide flexibility to enhance user safety and compliance within your chat platform.
# Getting Started
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/getting-started
# Moderation Integration
To maintain a safe, respectful, and engaging environment for your users, our platform offers a powerful **Moderation Integration** system. This system allows you to automatically review, filter, and take action on user-generated messages, images, and videos before they are delivered.
With Moderation Integration, you can define flexible rules, receive real-time updates, and ensure your app meets community guidelines, legal standards, and brand values without manual intervention.
Define content moderation rules for your app's messaging system.
Set up a webhook to receive real-time moderation events.
Use APIs to send and review flagged messages programmatically.
If you have specific requirements, you can create **custom moderation rules** tailored to your app’s needs. Rules can be created in two ways:
1. **Using the CometChat Dashboard** — A simple, no-code interface for visually creating and managing moderation rules.
{/*  */}
2. **Using the CometChat API** — Programmatically create and manage moderation rules for advanced or automated workflows. See the [Create Rule API documentation](\{apiEndpoints.createRule.url}).
***
## Configuring a Moderation Webhook
To automate your moderation flow and receive updates in real time, configure a **moderation webhook**. This allows your system to react instantly when a message or media is moderated.
### How It Works
* Every time content is moderated, a webhook event is triggered and sent to the URL you specify.
* Your application can then take action based on the moderation result.
### Prerequisites
* Your webhook URL must be accessible over **HTTPS** to ensure secure data transmission.
* The URL should be publicly accessible from the internet.
* Ensure your endpoint supports the `HTTP POST` method. Event payloads will be delivered via `POST` requests in JSON format.
* Configure your endpoint to respond immediately to the CometChat server with a `200 OK` response.
* For security, set up **Basic Authentication** (username and password) for server-to-server communication.
When your webhook URL is triggered, the HTTP header includes:
```http
Authorization: Basic
***
## Integrating and Testing the Moderation API
Once your moderation rules and webhook are configured, integrate the **Moderation API** into your application to programmatically submit content and receive moderation results.
### Steps to Integrate and Test
1. **Submit content:** Use the API to send messages, images, or videos for moderation.
2. **Check responses:** Verify moderation status in real time.
3. **Handle outcomes:** Apply business logic based on approved, flagged, or disapproved responses.
4. **End-to-end testing:** Test both the API response and webhook delivery to ensure complete coverage.
When you’re ready, you can render all moderation endpoints dynamically:
### Send message
This endpoint is used to submit a message for moderation before it is delivered to the recipient. The message is scanned against the moderation rules configured for the app.
**URL:**
```
https://api-explorer.cometchat.com/reference/chat-api-send-message-moderation
```
**Request Body:**
```json
{
"category": "message",
"type": "text",
"data": {
"text": "Hi new user"
},
"sender": "cometchat-uid-2",
"receiver": "cometchat-uid-1",
"receiverType": "user",
"sentAt": 1750335220
}
```
### List messages
Retrieves a list of messages submitted for moderation, along with the current moderation status of each message as determined by your configured rules.
**URL:**
```
https://api-explorer.cometchat.com/reference/chat-api-list-message-moderation/
```
### Get message
Retrieves the details of a specific message submitted for moderation, including its current moderation status as determined by your configured rules.
**URL:**
```
https://api-explorer.cometchat.com/reference/chat-api-get-message-moderation/
```
### Update message
Edits an existing message. The moderation status is re-evaluated based on your configured rules.
**URL:**
```
https://api-explorer.cometchat.com/reference/chat-api-update-message-moderation/
```
### Delete message
Deletes a previously submitted message along with its associated moderation data, in accordance with your configured rules.
**URL:**
```
https://api-explorer.cometchat.com/reference/chat-api-delete-message-moderation/
```
### Approve message
Approves a previously blocked message, allowing it to be delivered to the recipient.
**URL:**
```
https://api-explorer.cometchat.com/reference/chat-api-approve-moderation-blocked-messages/
```
***
| Endpoint | Purpose |
| ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **Send message for moderation**
**Extension settings**
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Report messages extension.
3. Open the settings for this extension.
4. The settings page has the following:
* **Moderation criteria:** The max number of reports after which you want to be notified.
* **Moderation actions:** Get the list of reports on the configured Webhook URL.
## How does it work?
The extension has the following functionalities:
1. Allowing end-users to report messages.
2. Allowing admins to login to the dashboard to take action on the reports.
### 1. Reporting a message
Messages can be reported in either group conversations or one-on-one conversations.
In the context menu of a message, you can have a "Report" button. Clicking it should open up a modal asking for the reason.
Here's the description of the parameters that need to be passed to the extension:
| Parameters | Value | Description |
| ---------- | ------- | --------------------------------------------- |
| msgId | Integer | The ID of the message that has to be reported |
| reason | String | The reason for reporting the message. |
Once you have the message to be reported along with the reason, make use of the `callExtension` method provided by the SDK to submit the report:
In order to list and take action on the reported users:
1. Open up the Extension's settings page
2. Click "View Reports" link. This will load all the reports.
3. The following actions can be taken for users reported in Group:
1. Delete => Reported message will be deleted.
2. Ignore => The report is ignored.
4. To load new reports, click on the Refresh button.
# Report User (Legacy)
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/legacy/report-user
## Extension settings
1. Login to CometChat and select your app.
2. Go to the Extensions section and enable the Report user extension.
3. Open the settings for this extension.
4. The settings page has the following:
* **Moderation criteria:** The max number of reports after which you want to be notified.
* **Moderation actions**: Get the list of reports on the configured Webhook URL.
## How does it work?
The extension has the following functionalities:
1. Allowing end-users to report other users.
2. Allowing admins to login to the Dashboard to take action on the reports.
### 1. Reporting a user
Users can be reported in either group conversations or one-on-one conversations.
By clicking on the user's avatar, you can show an item in the context menu called "Report". Clicking on the "Report" button should open up a modal asking for the reason.
Here's the description of the parameters that need to be passed to the extension:
| Parameters | Value | Description |
| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| uid | String | The UID of the user that needs to be reported |
| reason | String | Reason for reporting. This should be max 150 characters. |
| guid | String | The GUID of the group in which the user is being reported.If the user is being reported in a one-on-one conversation, this can be skipped. |
Once you have the user to be reported along with the reason, make use of the callExtension method provided by the SDK to submit the report:
In order to list and take an action on the reported users:
1. Open up the Extension's settings page
2. Click "View Reports" link. This will load all the reports.
3. Select the criteria from the dropdown:
1. One-on-one conversations => Lists the users who have been reported in One-on-one conversations.
2. Group conversations => List the users who have been reported in a Group.
3. All reports => Lists all the reports.
4. The following actions can be taken for users reported in Group:
1. Kick => Reported user is kicked out of the group.
2. Ban => Reported user is banned from the group.
3. Ignore => The report is ignored.
5. The following actions can be take for users reported in one-on-one conversations:
1. Block => The reported user is blocked on behalf of the reporter.
2. Ignore => The report is ignored.
6. To load new reports, click on the Refresh button.
# Slow Mode (Deprecated)
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/legacy/slow-mode
## Extension settings
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and enable the Slow mode extension.
## How does Slow mode work?
Slow mode extension works great in groups with a large number of participants. Especially, during a live event with a potential for a flood of messages being sent every second. When the extension is enabled and enforced in a group, it allows the participants to send messages only after a certain intervals. This helps to keep chats readable for everyone during large events.
The extension has the following 4 parts:
1. Enabling the slow mode for a group
2. Disabling the slow mode for a group
3. Enforcing slow mode for participants
4. Fetching the slow mode details
### Enabling slow mode
Slow mode can be enabled only by the group admins or moderators. Participants cannot enable the slow mode.
Once slow mode is enabled in a group, the information is shared with its members in real-time as a custom message. With this, it can be enforced immediately.
You need to implement the `onCustomMessageReceived` listener in order to receive the Slow mode related messages. The message sent has the category of `custom` and type `extension_slow-mode`.
Following are the inputs required to enable slow mode in a particular group:
| Parameter | Type | Description |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------- |
| `guid` | string | The group's ID in which the slow mode needs to be enabled. |
| `slowDownTimeInMS` | int | The time in milliseconds for which the participants have to wait before being able to send the consecutive message. |
You can make use of the `callExtension` method exposed by CometChat SDKs to enable slow mode as an admin/moderator.
To begin managing lists:
* Login to your [CometChat dashboard](https://app.cometchat.com/login) and choose your app.
* Navigate to **Moderation** > **Settings** in the left-hand menu.
* Select the **Lists** tab.
## Default Lists
Default lists are predefined lists of words, patterns and sentences that are readily available for use on your platform. Here are the standard default lists available:
### Profane Words
Our default list is a comprehensive compilation of predefined profane words and phrases. This list is designed to enhance message moderation efforts by automatically identifying and flagging inappropriate language.
### Platform Circumvention
The Platform Cicurvention list contains a curated set of sentences and words designed to identify attempts to circumvent platform rules and policies. These phrases are used by the AI Platform Circumvention Rule to detect and prevent efforts aimed at bypassing restrictions, ensuring compliance and maintaining platform integrity.
### Spam Detection
The Default Spam Detection List identifies repetitive or irrelevant messages promoting products, services, or schemes without user consent. It helps filter out unwanted content, including bulk messages, phishing attempts, and fraudulent offers, ensuring a cleaner and more secure communication experience.
### Scam Detection
The Default Scam Detection List includes messages crafted to deceive users by creating a sense of urgency, promising false rewards, or impersonating trusted entities. These messages often aim to manipulate users into sharing personal information, making payments, or clicking on malicious links. The list helps identify and block scams, protecting users from fraud, phishing attempts, and other deceptive practices.
### Fraud or Scam Indicators Prompt
The Fraud or Scam Indicators list is designed to detect manipulated images used for fraudulent or deceptive activities. It helps flag fake documents, counterfeit products, and misleading visuals that could be used to scam users or spread misinformation.
### Terrorism or Extremist Promotion Prompt
The Terrorism or Extremist Promotion list identifies imagery that endorses terrorism, violent extremism, or radical ideologies. It helps prevent the spread of extremist propaganda, recruitment materials, and content that incites violence.
### Minor Safety and Exploitation Prompt
The Minor Safety and Exploitation list is used to detect sexualized or exploitative imagery of minors. It helps prevent child abuse, grooming, and the sharing of harmful content, ensuring compliance with child protection policies.
### Privacy or Personal Data Prompt
The Privacy or Personal Data list flags images that expose sensitive or private information, such as identification documents, financial details, or personal records. This helps prevent identity theft, unauthorized data leaks, and privacy violations.
### Graphic Violence or Gore Prompt
The Graphic Violence or Gore list identifies violent or gory imagery, including depictions of severe injuries, crime scenes, or graphic deaths. It helps limit exposure to disturbing content and ensures a safer viewing experience.
### Explicit or Sexual Content Prompt
The Explicit or Sexual Content list is designed to detect nudity, sexually explicit imagery, or highly suggestive content. It helps enforce platform guidelines by filtering out inappropriate material.
### Hate or Harassment Prompt
The Hate or Harassment list flags imagery containing hateful symbols, offensive gestures, or harassment. It helps identify and prevent content that promotes discrimination, hate speech, or targeted abuse.
### Hate and Harassment Prompt
The Hate and Harassment list detects messages that contain hate speech, threats, slurs, or harassment directed at individuals or groups. It helps create a respectful and safe online environment by preventing abusive behavior.
### Explicit or Inappropriate Content Prompt
The Explicit or Inappropriate Content list identifies text that includes explicit sexual descriptions, extreme violence, or other unsuitable material. It helps ensure compliance with content policies and maintains platform integrity.
### Impersonation or Fraud Prompt
The Impersonation or Fraud list detects deceptive attempts to impersonate individuals, businesses, or organizations. It helps prevent identity theft, scam attempts, and fraudulent activities.
### Non-Consensual Sexual Content or Exploitation Prompt
The Non-Consensual Sexual Content or Exploitation list flags messages that depict or encourage non-consensual sexual acts, grooming, or coercion. It helps protect users from exploitation and ensures adherence to safety policies.
### Privacy and Sensitive Info Prompt
The Privacy and Sensitive Info list identifies messages that share personal or sensitive information without consent. It helps protect user privacy by preventing unauthorized data exposure.
### Self-Harm or Suicidal Content Prompt
The Self-Harm or Suicidal Content list detects messages indicating self-harm, suicidal thoughts, or encouragement of self-injury. It helps enable early intervention and support mental health safety.
### Spam and Scam Prompt
The Spam and Scam list identifies spam messages, phishing attempts, and fraudulent schemes. It helps filter out unwanted content, including bulk messages and misleading offers, ensuring a cleaner and more secure communication environment.
### Violent or Terroristic Threats Prompt
The Violent or Terroristic Threats list detects content that promotes violence, terrorism, or extremist actions. It helps prevent harmful speech, glorification of violence, and threats against individuals or groups.
## Managing Lists
### Create List
Allows you to define new moderation lists specifying the words or patterns under which text or custom messages should be blocked.
Creating a new list from the dashboard:
1. Click the Add button within the Lists tab.
2. Create the list by saving the following details:
* Name: Descriptive name for the moderation list.
* ID: The unique identifier of the list.
* Category: Choose the type for list, either 'word', 'pattern' or 'sentence similarity'.
* Description: Detailed explanation of the list.
* Your Source type for lists could be either words, patterns or sentences, separated by a comma or a CSV file.
3. Save
You can also set this up from your end using the [Create Moderation List REST API](https://api-explorer.cometchat.com/reference/create-rule-keyword).
### Fetch All Lists
Fetches the details of existing list lists.
You can also set this up from your end using the [List Moderation Lists REST API](https://api-explorer.cometchat.com/reference/list-rule-keywords).
### Get List
Fetches the details of an existing list. You can set this up from your end using the [Get Moderation List REST API](https://api-explorer.cometchat.com/reference/get-rule-keyword).
### Update List
Allows you to update existing lists, which includes modifying the list name, category, and individual words or patterns within the list.
Updating a list from the dashboard:
1. Click on "Edit" in the action menu of the List you want to update.
2. Update the list by saving the following details:
* Name: Descriptive name for the moderation list.
* Category: Choose the type for List, either 'word', 'pattern' or 'sentence similarity'.
* Description: Detailed explanation of the list.
* Your Source type for list could be either words, patterns or sentences separated by a comma or a CSV file.
3. Save
You can also set this up from your end using the [Update Moderation List REST API](https://api-explorer.cometchat.com/reference/update-rule-keyword).
### Delete List
Allows for the removal of lists from the system that are no longer needed.
Deleting a list from the dashboard:
* Click "Delete" in the action menu of the list you want to remove, then confirm.
You can also set this up from your end using the [Delete Moderation List REST API](https://api-explorer.cometchat.com/reference/delete-rule-keyword).
# OpenAI Moderation
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/open-ai/openai-custom
CometChat allows you to integrate OpenAI for real-time message moderation, enabling automated detection of harmful, offensive, or inappropriate content.
## Integration
### **Step 1: Configure OpenAI Settings**
1. **Login to the CometChat Dashboard**
* Navigate to [CometChat Dashboard](https://app.cometchat.com) and select your app.
2. **Navigate to Moderation Settings**
* Go to **Moderation → Settings** in the left-hand menu.
3. **Open OpenAI Settings Tab**
* Click on the **OpenAI Settings** tab within the Moderation Settings.
4. **Fill in the OpenAI Configuration**
* **Select OpenAI Model**
* Choose the OpenAI model you want to use (e.g., `gpt-4-turbo`).
* **Provide OpenAI API Key**
* Enter your OpenAI API key to authenticate requests.
* **Set Action on OpenAI Error**
* Define how the system should respond if OpenAI is unavailable (e.g., "Allow message" or "Block message").
* **Set Context Window**
* Specify the number of previous messages in a conversation that will be used for OpenAI context.
5. **Click Save Settings**
### **Step 2: Enable OpenAI Moderation**
1. Navigate to **Moderation → List**.
2. Click **"Create New Rule"**.
3. Select **OpenAI** as the moderation type.
4. Select a predefined **prompt** from the List Section or create your own.
5. **Ensure that the rule type is either** `Text Contains` **or** `Image Contains`.
6. Save the rule and Enable it.
> **Note:** The rule you create should be of type **Text Contains** or **Image Contains** to work with OpenAI moderation.
***
# Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/open-ai/openai-overview
# Overview
CometChat offers AI-powered message moderation to help maintain a safe and respectful chat environment. You can choose between two moderation options:
### **OpenAI Moderation**
Leverage OpenAI’s AI models to automatically detect and filter offensive, harmful, or inappropriate messages in real time. This option allows you to:
* **Define Custom Prompts** – Set specific prompts to classify and moderate messages based on your needs.
* **Choose an AI Model** – Select the OpenAI model that best suits your moderation requirements.
* **Contextual Moderation** – Configure how many previous messages from the conversation should be considered for better contextual understanding.
* **Flexible Moderation Actions** – Block, allow, or take fallback actions if the API request fails.
* **Secure API Management** – Provide and manage OpenAI credentials directly in the CometChat dashboard.
This moderation provide flexibility to enhance user safety and compliance within your chat platform.
# Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/overview
The Moderation feature provides a comprehensive suite of capabilities designed to manage and enforce message moderation rules across various types of messages, ensuring your platform remains safe and compliant for all users. These capabilities include rule management for creating, updating, and deleting moderation rules, as well as keyword lists for detecting inappropriate content. Additionally, automated actions promptly address potential violations, and detailed reports on blocked messages help to continuously improve safety and compliance measures. By leveraging these robust functionalities, you can effectively maintain a secure and welcoming environment on your platform.
Here’s an in-depth look at the key functionalities provided by the Moderation Service:
## Rules Management
This feature enables you to define and manage a set of moderation rules tailored to address inappropriate messages under various conditions. You can establish specific criteria that determine what constitutes unacceptable behavior or content, such as the use of offensive language, unsafe content, or sharing sensitive information.
By customizing these rules, you ensure that the moderation system effectively identifies and manages messages that violate your platform's standards, thereby maintaining a safe and respectful environment for all users. The ability to manage these rules includes adding new rules, updating existing ones, and removing obsolete rules, providing a flexible and dynamic approach to message moderation.
For more detailed management, refer to the [rules management](/moderation/rules-management) section.
## Lists Management
This feature allows you to create and manage comprehensive lists of keywords or regex patterns that are used for message moderation. These lists serve as a vital component in identifying and handling inappropriate content. You can customize these lists to include specific terms and patterns that are relevant to your platform's moderation needs.
Once created, these keyword lists can be linked to various moderation rules when creating or updating rules, ensuring that the moderation system effectively detects and manages content that violates your standards. The ability to manage these lists includes adding new keywords or patterns or sentences, updating existing ones, and removing those that are no longer relevant, providing a flexible and responsive approach to message moderation.
For more detailed management, refer to the [lists management](/moderation/lists-management) section.
## Blocked Messages
This feature allows you to retrieve all the violated messages. You can retrieve a comprehensive list of messages that have been blocked due to violations of moderation rules. Additionally, you can perform searches within this list to find specific messages or filter results based on date ranges and find details for the violation. This functionality helps you effectively monitor and manage inappropriate content, ensuring a safe and compliant environment on your platform.
For more details, refer to the [Blocked Messages](/moderation/blocked-messages) section.
***
## Overview of Moderation Rules
Our platform offers a wide range of moderation rules to help you detect and manage various types of risky, sensitive, or inappropriate content. Below is an overview of the available rules categorized by content type:
### 🚩 Message Moderation Rules
| Name | Description |
| -------------------------------------------- | --------------------------------------------------------------------------------- |
| **Word Pattern Match** | Identifies profane or offensive words using word matching. |
| **Contact Details Removal** | Detects and removes phone numbers from text. |
| **Email Detection** | Detects and removes email addresses from messages. |
| **Spam Detection (English)** | Detects spam messages in English. |
| **Scam Detection (English)** | Detects scam or fraudulent text in English. |
| **Platform Circumvention (English)** | Identifies attempts to bypass platform rules. |
| **Toxicity Detection (English)** | Detects toxic or harmful language in text. |
| **Explicit or Inappropriate Content Prompt** | Detects explicit sexual descriptions, graphic violence, or other unsuitable text. |
| **Privacy and Sensitive Info Prompt** | Identifies sensitive personal information shared without consent. |
| **Hate and Harassment Prompt** | Detects hateful or harassing language toward individuals or groups. |
| **Self-Harm or Suicidal Content Prompt** | Detects content suggesting self-harm or suicidal thoughts. |
| **Impersonation or Fraud Prompt** | Detects deceptive attempts to impersonate individuals or organizations. |
| **Violent or Terroristic Threats Prompt** | Detects content promoting violence or extremism. |
| **Non-Consensual Sexual Content Prompt** | Detects sexual exploitation, grooming, or non-consensual content. |
| **Spam and Scam Prompt** | Identifies spam, phishing attempts, and fraudulent schemes. |
### 🖼️ Image Moderation Rules
| Name | Description |
| ------------------------------------------- | ---------------------------------------------------------------------------------------- |
| **Unsafe & Prohibited Content** | Detects unsafe or prohibited content in images. |
| **Terrorism or Extremist Promotion Prompt** | Detects extremist propaganda, terrorist symbols, or images promoting violent ideologies. |
| **Minor Safety and Exploitation Prompt** | Detects child sexual content or exploitative imagery of minors. |
| **Self-Harm or Suicidal Content Prompt** | Detects imagery suggesting self-harm or suicidal ideation. |
| **Privacy or Personal Data Prompt** | Identifies images containing personal or sensitive data. |
| **Graphic Violence or Gore Prompt** | Detects images of extreme violence or gore. |
| **Explicit or Sexual Content Prompt** | Identifies nudity, explicit sexual content, or suggestive imagery. |
| **Hate or Harassment Prompt** | Detects hate symbols, harassment, or extremist imagery. |
| **Fraud or Scam Indicators Prompt** | Flags manipulated or fraudulent images, such as fake IDs. |
### 🎥 Video Moderation Rules
| Name | Description |
| ------------------------------- | ---------------------------------------------------- |
| **Unsafe & Prohibited Content** | Detects unsafe or prohibited content in video files. |
# Rules Management
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/rules-management
## Overview
The Rules Management endpoints in the Moderation Service API provide the functionality to define and manage moderation rules that help in identifying and handling inappropriate content based on a variety of conditions. These endpoints empower app owners and collaborators to create a customized message moderation strategy tailored to the specific needs of their platform. The next section provides a detailed elaboration of the capabilities offered.
To begin managing rules:
* Login to your [CometChat dashboard](https://app.cometchat.com/login) and choose your app.
* Navigate to **Moderation** > **Settings** in the left-hand menu.
* Select the **Rules** tab.
## Default Rules
Default rules are predefined sets of message moderation conditions that are readily available for use on your platform, and automatically applied to moderate messages when enabled. These default rules form the foundation of an effective message moderation strategy, combining automation with customizable options to ensure a safe, respectful, and compliant environment for platform users. Here are the standard default rules available:
### Profanity Filter
This feature automatically detects and manages text and custom messages containing offensive language, profanity, or derogatory remarks using a predefined list of offensive keywords to block inappropriate content. Ensuring user interactions maintain a respectful tone and comply with community standards, enhances overall platform decency.
**Example**
Before enabling the profanity filter, messages containing profane words are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
### Contact Details Filter
This feature detects and manages messages containing phone numbers by applying rules to prevent the sharing of private information that could compromise user privacy or security. It protects users from potential misuse of personal data and ensures compliance with data protection regulations.
**Example**
Before enabling the contact details filter, messages containing phone numbers are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
### Email Filter
This feature detects and manages messages containing email addresses by applying rules to prevent the sharing of private information that could compromise user privacy or security. It protects users from potential misuse of personal data and ensures compliance with data protection regulations.
**Example**
Before enabling the email filter, a message containing an email address is delivered to the receiver and can be seen on the receiver's chat screen. After enabling the filter, such messages are not delivered to the receiver, like in the example where the personal email isn't delivered to the receiver.
The blocked messages are then visible on the dashboard for monitoring purposes.
### AI-based Image Moderation
This feature identifies and manages image-type messages containing sensitive, explicit, or prohibited content using advanced artificial intelligence algorithms for image recognition. Once detected, the system automatically blocks the images that violate platform guidelines, ensuring that such content is not displayed to users. This proactive approach safeguards users from exposure to harmful visual material, maintaining a safe and compliant environment on the platform.
\**Example*
Non-violating images are being delivered as seen in the example. Enabling this filter blocks violating images that are not delivered to the receiver, like in the example where the second image is indicated by a single tick in the message status on the sender's screen and isn't delivered to the receiver.
The blocked messages are then visible on the dashboard for monitoring purposes.
### AI-based Video Moderation
This feature identifies and manages video-type messages containing sensitive, explicit, or prohibited content using advanced artificial intelligence algorithms for image recognition. Once detected, the system automatically blocks the images that violate platform guidelines, ensuring that such content is not displayed to users. This proactive approach safeguards users from exposure to harmful visual material, maintaining a safe and compliant environment on the platform.
**Example**
Before enabling the AI-based Video Moderation filter, a message containing violating videos is delivered to the receiver, like in the example where the first video can be seen on the receiver's chat screen. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status on the sender's chat screen.
The blocked messages are then visible on the dashboard for monitoring purposes.
### AI Message Toxicity
The AI Message Toxicity Detection rule is a powerful, AI-driven tool designed to identify and flag toxic, harmful, or inappropriate language within user-generated messages. This feature analyzes text in real-time, detecting patterns of abusive speech, such as threats, harassment, hate speech, and other forms of offensive communication. By automatically blocking these messages based on predefined moderation rules, the tool helps prevent the spread of toxic content, fostering a safer and more respectful communication environment. This system empowers platform administrators to maintain community standards, allowing them to intervene or moderate flagged messages promptly. It also supports various languages and contexts, ensuring that the platform remains compliant with safety guidelines and user conduct policies.
**Example**
Before enabling the AI message toxicity rule, a message containing a sentence which violates AI message toxicity is delivered to the receiver and can be seen on the receiver's chat screen. After enabling the filter, such messages are not delivered to the receiver.
The blocked messages are then visible on the dashboard for monitoring purposes.
### AI Platform Circumvention
The AI Platform Circumvention Rule employs a list of categories related to sentence similarity to identify and manage attempts by users to circumvent platform rules. This filter analyzes user-generated content for patterns and phrases that may indicate efforts to bypass established guidelines. By leveraging AI technology, it compares new submissions against a predefined set of sentence structures and categories to detect similarities that suggest rule violations.
**Example**
Before enabling the platform circumvention filter, a message containing a sentence which violates platform circumvention is delivered to the receiver and can be seen on the receiver's chat screen. After enabling the filter, such messages are not delivered to the receiver.
The blocked messages are then visible on the dashboard for monitoring purposes.
### AI Scam Detection
The AI Scam Detection rule leverages advanced AI-powered text moderation techniques to identify and prevent scam-related messages in real-time. By analyzing message patterns and identifying specific language markers and behaviors commonly associated with scams, this rule ensures that fraudulent schemes are swiftly intercepted before reaching users. This proactive detection system scans for misleading content, phishing attempts, fake offers, and other tactics typically employed by scammers, thereby safeguarding users and maintaining the trust and security of the platform. It also continuously adapts to evolving scam strategies through machine learning, making it more effective over time.
**Example**
Before enabling the AI Scam Detection rule, a message containing a sentence which violates AI Scam Detection rule is delivered to the receiver and can be seen on the receiver's chat screen. After enabling the filter, such messages are not delivered to the receiver.
The blocked messages are then visible on the dashboard for monitoring purposes.
### AI Spam Detection
AI Spam Detection uses sophisticated AI algorithms to automatically detect and filter out spam messages in real-time. By analyzing message content and patterns, it effectively identifies unwanted or irrelevant communications, reducing the risk of spam flooding your platform. This feature helps ensure a cleaner, more efficient messaging experience, allowing users to focus on genuine, meaningful interactions.
**Example**
Before enabling the AI Spam Detection rule, a message containing a sentence which violates AI Spam Detection rule is delivered to the receiver and can be seen on the receiver's chat screen. After enabling the filter, such messages are not delivered to the receiver.
The blocked messages are then visible on the dashboard for monitoring purposes.
### OpenAI (Message): Hate and Harassment Prompt (All Languages)
This feature uses a predefined OpenAI moderation prompt to detect hateful or harassing language toward individuals or groups. By automatically identifying and blocking such content, it ensures a respectful and inclusive environment, fostering positive interactions among users.
**Example**
Before enabling the hate and harassment detection, messages containing hateful or harassing language are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Message): Privacy and Sensitive Info Prompt (All Languages)
This feature leverages OpenAI to detect messages that share personal or sensitive information without consent. It helps prevent unauthorized disclosure of private data, safeguarding user privacy and maintaining compliance with data protection standards.
**Example**
Before enabling the privacy and sensitive information detection, messages containing personal or sensitive information are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Message): Explicit or Inappropriate Content Prompt (All Languages)
This feature identifies and manages messages containing explicit sexual descriptions, graphic violence, or other unsuitable text using OpenAI moderation. It ensures that such content is automatically blocked, maintaining a safe and appropriate environment for all users.
**Example**
Before enabling the explicit or inappropriate content detection, messages containing explicit or inappropriate content are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Message): Spam and Scam Prompt (All Languages)
This feature uses OpenAI to detect and block spam messages, phishing attempts, and fraudulent schemes. By filtering out malicious or unwanted content, it enhances user trust and protects them from potential scams or harmful activities.
**Example**
Before enabling the spam and scam detection, messages containing spam or scam content are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Message): Violent or Terroristic Threats Prompt (All Languages)
This feature identifies content that encourages, promotes, or glorifies violence or extremism using OpenAI moderation. It ensures that such messages are automatically blocked, contributing to a safer and more secure platform for all users.
**Example**
Before enabling the violent or terroristic threats detection, messages containing violent or terroristic content are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Message): Non-Consensual Sexual Content or Exploitation Prompt (All Languages)
This feature detects messages related to sexual exploitation, grooming, or non-consensual content using OpenAI moderation. It proactively blocks such content, protecting users from harmful interactions and maintaining a safe environment.
**Example**
Before enabling the non-consensual sexual content or exploitation detection, messages containing such content are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Message): Impersonation or Fraud Prompt (All Languages)
This feature identifies deceptive attempts to impersonate individuals or organizations using OpenAI moderation. By detecting and blocking such content, it prevents fraudulent activities and ensures the authenticity of user interactions.
**Example**
Before enabling the impersonation or fraud detection, messages containing impersonation or fraudulent content are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Message): Self-Harm or Suicidal Content Prompt (All Languages)
This feature uses OpenAI to detect messages suggesting self-harm, suicidal thoughts, or related instructions. It helps identify and address potentially harmful content, providing a supportive environment and connecting users with appropriate resources when needed.
**Example**
Before enabling the self-harm or suicidal content detection, messages containing such content are delivered to the receiver, as indicated by double ticks in the message status. After enabling the filter, such messages are not delivered to the receiver, which is indicated by a single tick in the message status.
The blocked messages are then visible on the dashboard for monitoring purposes.
### OpenAI (Image): Hate or Harassment Prompt
This feature uses a predefined OpenAI moderation prompt to detect hate symbols, extremist insignia, and harassing imagery in images. By automatically identifying and blocking such content, it ensures a respectful and safe environment for all users.
**Example**
Before enabling the hate or harassment detection for images, images containing hate symbols or harassing content are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Image): Explicit or Sexual Content Prompt
This feature leverages OpenAI to identify nudity, explicit sexual content, or suggestive imagery unsuitable for general audiences. It ensures that such images are automatically blocked, maintaining a safe and appropriate environment.
**Example**
Before enabling the explicit or sexual content detection, images containing explicit or suggestive content are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Image): Graphic Violence or Gore Prompt
This feature uses OpenAI to detect images of extreme violence, gore, or other disturbing content. It ensures that such images are automatically blocked, contributing to a safer and more secure platform.
**Example**
Before enabling the graphic violence or gore detection, images containing violent or disturbing content are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Image): Privacy or Personal Data Prompt
This feature identifies images containing personal or sensitive data, such as IDs, addresses, or financial documents, using OpenAI moderation. It helps prevent unauthorized sharing of private information, safeguarding user privacy.
**Example**
Before enabling the privacy or personal data detection, images containing sensitive information are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Image): Self-Harm or Suicidal Content Prompt
This feature uses OpenAI to detect imagery suggesting self-harm, suicidal ideation, or content that promotes self-injury. It helps identify and address potentially harmful content, providing a supportive environment.
**Example**
Before enabling the self-harm or suicidal content detection, images containing such content are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Image): Minor Safety and Exploitation Prompt
This feature detects child sexual content, exploitative imagery of minors, or unsafe depictions of children using OpenAI moderation. It proactively blocks such content, protecting minors and maintaining a safe environment.
**Example**
Before enabling the minor safety and exploitation detection, images containing exploitative or unsafe content are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Image): Fraud or Scam Indicators Prompt
This feature flags manipulated or fraudulent images, such as fake IDs or doctored screenshots, using OpenAI moderation. It helps prevent fraudulent activities and ensures the authenticity of user interactions.
**Example**
Before enabling the fraud or scam indicators detection, images containing fraudulent or manipulated content are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
***
### OpenAI (Image): Terrorism or Extremist Promotion Prompt
This feature detects extremist propaganda, terrorist symbols, or images promoting violent ideologies using OpenAI moderation. It ensures that such images are automatically blocked, contributing to a safer platform.
**Example**
Before enabling the terrorism or extremist promotion detection, images containing extremist or violent content are delivered to the receiver. After enabling the filter, such images are not delivered to the receiver.
The blocked images are then visible on the dashboard for monitoring purposes.
## Rule Filters, Conditions and Actions
### Filters
Filters allow you to narrow down messages based on the Sender or Receiver of a message.
For Senders, you can filter by specific properties like UID, Role, Name, and Tags, or see when the sender was created. Similarly, for Receivers, you can filter by properties such as Name, GUID, Tags, Group type or see when the receiver was created, and the Type of receiver (for example, a user or group). This enables targeted filtering based on user or group attributes within the conversation.
### Conditions
Conditions allow you to define criteria for blocking messages based on their type—text, image, video, or custom.
You can select a keyword list, define a list of words or patterns, for text and custom messages.
In addition to selecting specific words, patterns, or lists for text and custom messages, you can also choose filters based on Toxicity, Sentiment, or Sentence Similarity for more advanced moderation and content analysis. You can refine Toxicity filtering by selecting categories such as Identity Attack, Insult, Obscene, Mild Toxicity, or Severe Toxicity. For Sentiment, you can choose to filter messages based on positive or negative sentiment. In Sentence Similarity, you have the option to apply a default or custom list. Additionally, you can set a confidence percentage for each criterion to determine the threshold for blocking messages.
For media messages you can select among categories like Violence, Gambling, Alcohol, Drugs and Tobacco, Rude gestures, Explicity nudity, Non-explicit nudity, Swimwear or underwear, Visually disturbing, Hate symbols or Any unsafe content. Additionally, you can set a confidence percentage for each criterion to determine the threshold for blocking messages.
### Actions
Actions specify what happens when content matches the conditions. In addition to blocking the message by default, actions include options such as banning or kicking a user from a group and blocking a user.
## Configuring rules
### Create Rule
Allows you to define new moderation rules specifying the conditions under which messages should be blocked.
Creating a new rule from the dashboard:
1. Click the Add button within the Rules tab.
2. Configure the Rule by saving the following details:
* Name: Name for the moderation rule.
* Rule ID: The unique identifier of the rule.
* Description: Detailed explanation of the rule's purpose.
* Filter: List of filters that must be met for the rule to trigger.
* Condition: List of conditions that must be met for the rule to trigger.
* Action: Choose from a set of actions to be taken when a violation is detected.
3. Save
4. Enable the Rule to start moderating!
You can also set this up from your end using the [Create Moderation Rule REST API](https://api-explorer.cometchat.com/reference/create-rule).
### List Rules
Fetches the details of the existing list of rules.
You can also set this up from your end using the [List Moderation Rules REST API](https://api-explorer.cometchat.com/reference/list-rules).
### Get Rule
Fetches the details of a rule. You can set this up from your end using the [Get Moderation Rule REST API](https://api-explorer.cometchat.com/reference/get-rule).
### Update Rule
Enables modifications to existing rules. This includes changing conditions, updating actions, or refining parameters to improve accuracy.
Updating a rule from the dashboard:
1. Click on "Edit" in the action menu of the rule you want to update.
2. Update the Rule by saving the following details:
* Name: Descriptive name for the moderation rule.
* Description: Detailed explanation of the rule's purpose.
* Filter: List of filters that must be met for the rule to trigger.
* Condition: List of conditions that must be met for the rule to trigger.
* Action: Choose from a set of actions to be taken when a violation is detected.
3. Save
You can also set this up from your end using the [Update Moderation Rule REST API](https://api-explorer.cometchat.com/reference/update-rule).
### Delete Rule
Permits the deletion of outdated or unnecessary rules from the system. This helps in maintaining an efficient and relevant set of moderation guidelines.
Deleting a rule from the dashboard:
* Click "Delete" in the action menu of the rule you want to remove, then confirm.
You can also set this up from your end using the [Delete Moderation Rule REST API](https://api-explorer.cometchat.com/reference/delete-rule).
### Rule Revisions
The ability to fetch all revisions of a rule in a moderation system allows app owners and collaborators to retrieve a comprehensive history of updates and changes made to specific moderation rules over time. This feature provides detailed insights into how rules have been adjusted and refined to better manage and moderate content on the platform.
Viewing the rule revisions on the dashboard:
1. Click "View" in the action menu of the rule for which you wish to see revisions.
2. Navigate to the Rule History section.
You can also set this up from your end using the [Get Moderation Rule Revisions REST API](https://api-explorer.cometchat.com/reference/list-rule-revisions).
# Webhook Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/moderation/webhooks-overview
# Android Connection Service
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/notifications/android-connection-service
Learn how to send Push Notifications to your Android app using Firebase Cloud Messaging or FCM.
This is a simple 3 step process where:
1. You give a name to your project
2. Add Google Analytics to your project (Optional)
3. Configure Google Analytics account (Optional)
Click on Create and you are ready to go.
### Step 2: Add Firebase to your Android App
1. Click on the Android icon as shown on the screen below.
2. Register your Android app by providing the following details:
1. Android Package name
2. App nickname (optional)
3. Debug signing certificate SHA-1 (optional)
3. Download the google-services.json file and place it in the required location in your project.
4. Add Firebase SDK by copying and pasting the snippets in the Project-level build.gradle file.
5. Add Firebase SDK by copying and pasting the snippets in the App-level build.gradle file.
6. Click on 'Continue to Console' to finish the setup.
### Step 3: Download the service account file
## Extension settings
### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open the settings for this extension and save the following.
### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension.
* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications.
* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely.
2. **Select the platforms that you want to support**
* Select from Web, Android, Ionic, React Native, Flutter & iOS.
3. **Notification payload settings**
* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/concept-options).
4. **Push payload message options**
The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
5. **Notification Triggers**
* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
* These are pretty self-explanatory and you can toggle them as per your requirement.
## Android App Setup
In the Firebase Project setup, we did the following things:
1. Added google-services.json file to the project.
2. Added the required Firebase SDK snippets to the Project-level build.grade file.
3. Added the required Firebase SDK snippets to the App-level build.gradle file.
If you want more details, check the [Firebase Documentation](https://firebase.google.com/docs/cloud-messaging/android/client).
### Step 1: Register the FCM Token on user login
1. Initialize CometChat and then login your user.
2. On successful login, you can register the obtained FCM Token using `CometChat.registerTokenForPushNotification()` function call. (You can see the process of getting the FCM Token in the next step)
**ConnectionService** is an abstract service used to handle VoIP & other calls. It is part of android.telecom package which helps to handle telecom services. ConnectionService can be used either as System-Managed Service where System defined UI is shown to handle the calls. It can also be used as Self-Managed Service where users can show their own calling UI to handle the calls.
*Note - Currently the sample app uses system-managed connection service, So the System UI will be displayed to handle incoming calls.*
Learn more about [ConnectionService](https://developer.android.com/reference/android/telecom/ConnectionService).
| Files | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [CallConnectionService.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/CallConnectionService.java) | Custom ConnectionService file which is used to handle incoming & outgoing calls. It is used to manages the ConnectionService with your app. It also handles PhoneAccounts and bind it's services to Telecom. |
| [CallConnection.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/CallConnection.java) | Custom Connection class which is used to handle the callbacks of ConnectionService. Call backs such as onAnswer(), onReject(), onHold(), etc. |
| [CallManager.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/CallConnectionService.java) | It is used to manages the ConnectionService with your app. It also handles PhoneAccounts and bind it's services to Telecom. |
### Step 3: Receive notifications
1. The FCM Token can be received by overriding the `onNewToken()` method. This token is stored as a String variable. You can choose to store it in SharedPreferences as well.
2. To receive messages, you need to override the onMessageReceived(RemoteMessage remoteMessage).
3. [PushNotificationService.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/PushNotificationService.java) has the code that provides a way you can handle messages received from CometChat users and groups.
4. Since Android O, there have been certain restrictions added for background tasks and users cannot launch intent directly from the service. More details [here](https://developer.android.com/guide/components/activities/background-starts).
5. You also need to add the above-mentioned MyFirebasMessagingService.java fil in your AndroidManifest.xml to make Push notification work in the background as well.
This is a simple 3 step process where:
1. You give a name to your project
2. Add Google Analytics to your project (Optional)
3. Configure Google Analytics account (Optional)
Click on Create and you are ready to go.
### Step 2: Add Firebase to your Android App
1. Click on the Android icon as shown on the screen below.
2. Register your Android app by providing the following details:
1. Android Package name
2. App nickname (optional)
3. Debug signing certificate SHA-1 (optional)
3. Download the `google-services.json` file and place it in the required location in your project.
4. Add Firebase SDK by copying and pasting the snippets in the Project-level `build.gradle` file.
5. Add Firebase SDK by copying and pasting the snippets in the App-level `build.gradle` file.
6. Click on 'Continue to Console' to finish the setup.
### Step 3: Download the service account file
## Extension settings
### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open the settings for this extension and save the following.
### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension.
* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications.
* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely.
2. **Select the platforms that you want to support**
* Select from Web, Android, Ionic, React Native, Flutter & iOS.
3. **Notification payload settings**
* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/concept-options).
4. **Push payload message options**
The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
5. **Notification Triggers**
* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
* These are pretty self-explanatory and you can toggle them as per your requirement.
## Android App Setup
In the Firebase Project setup, we did the following things:
1. Added google-services.json file to the project.
2. Added the required Firebase SDK snippets to the Project-level build.grade file.
3. Added the required Firebase SDK snippets to the App-level build.gradle file.
If you want more details, check the [Firebase Documentation](https://firebase.google.com/docs/cloud-messaging/android/client).
### Step 1: Register the FCM Token on user login
1. Initialize CometChat and then login your user.
2. On successful login, you can register the obtained FCM Token using `CometChat.registerTokenForPushNotification()` function call. (You can see the process of getting the FCM Token in the next step)
**Step 1. Process push notification payload and grab BaseMessage object**
To open a chat view, firstly you will need a BaseMessage object. You can grab this from the push notification payload received in `onMessageReceived(RemoteMessage message)`. You need to call `CometChat.processMessage()` method to process push notification payload.
This is a simple 3 step process where:
1. You give a name to your project
2. Add Google Analytics to your project (Optional)
3. Configure Google Analytics account (Optional)
Click on Create and you are ready to go.
### Step 2: Add Firebase to your App
React native setup will require 2 files for Android and iOS:
1. For Android, you need to download the `google-services.json` file. You can refer to the [Android Firebase Project Setup - Step 2](/notifications/android-push-notifications#firebase-project-setup) and resume here once done.
2. For iOS, you need to download the `GoogleService-Info.plist` file. You can refer to the [iOS Firebase Project Setup - Step 2](/notifications/ios-fcm-push-notifications#firebase-project-setup) and resume here once done.
3. For web, you need to have the Firebase Config object. You can refer to the [Web Firebase Project Setup - Step 2](/notifications/web-push-notifications#firebase-project-setup) and resume here once done.
### Step 3: Download the service account file
## Extension settings
### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open the settings for this extension and save the following.
### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension.
* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications.
* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely.
2. **Select the platforms that you want to support**
* Select from Web, Android, Ionic, React Native, Flutter & iOS.
3. **Notification payload settings**
* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/concept-options).
4. **Push payload message options**
The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
5. **Notification Triggers**
* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
* These are pretty self-explanatory and you can toggle them as per your requirement.
## App Setup
### Step 1: Initial plugin setup
1. For Cordova & Ionic, there are numerous plugins available via NPM which can be used to set up push notifications for your apps like [FCM Plugin](https://ionicframework.com/docs/v3/native/fcm/) and [Push Plugin](https://ionicframework.com/docs/native/push).
2. To setup Push Notification, you need to follow the steps mentioned in the Plugin's Documentation.
At this point, you will have:
1. Separate apps created on the Firebase console. (For Web, Android and iOS).
2. Plugin setup completed as per the respective documentation.
### Step 2: Register FCM Token
1. This step assumes that you already have a React Native app setup with CometChat installed. Make sure that the CometChat object is initialized and user has been logged in.
2. On the success callback of user login, you can fetch the FCM Token and register it with the extension as shown below:
|
1. Login to [CometChat](https://app.cometchat.com/login) dashboard and select your app.
2. Navigate to **Notifications** > **Notifications** in the left-hand menu.
3. Enable Email notifications feature.
### Save the SendGrid credentials
Save the following details:
* SendGrid API key
* SendGrid Template ID
* SendGrid Unsubscribe Group ID
* Sender's name
* Sender's email
Send a message to any user and keep the conversation unread for the designated amount of time to receive an email notification.
### Configure email replies
In the SendGrid provider settings, enable the email replies. Optionally, you can set a different sender's email address. Only ensure that the it doesn't contain any "+" symbol in it.
Copy the Replies webhook URL as that will be required for Inbound parse configuration on SendGrid's end. Follow the [SendGrid's Inbound parse webhook](https://www.twilio.com/docs/sendgrid/for-developers/parsing-email/setting-up-the-inbound-parse-webhook) steps.
Before saving the Inbound Host and URL:
1. Uncheck Spam Check checkbox.
2. Uncheck Send Raw checkbox.
Once this setup is successful, users will be able to reply to an email notification and send messages in a particular conversation on CometChat. The parsing of the replies is heavily dependent on the Email client used and the content of the reply.
## Custom Email provider
Custom provider allows you to make use of providers apart from SendGrid for triggering Email notifications. This is implemented using webhook URL which gets all the required details that can be used to trigger Email notifications.
#### Pre-requisite
1. Your webhook endpoint must be accessible over `HTTPS`. This is essential to ensure the security and integrity of data transmission.
2. This URL should be publicly accessible from the internet.
3. Ensure that your endpoint supports the `HTTP POST` method. Event payloads will be delivered via `HTTP POST` requests in `JSON` format.
4. Configure your endpoint to respond immediately to the CometChat server with a 200 OK response. The response should be sent within 2 seconds of receiving the request.
5. For security, it is recommended to set up Basic Authentication that is usually used for server-to-server calls. This requires you to configure a username and password. Whenever your webhook URL is triggered, the HTTP Header will contain:
```html
Authorization: Basic
#### How does it work?
The Custom provider is triggered once for an event in one-on-one conversation. In case of notifying the members of a group, the custom provider is triggered once for each user present in that group.
For example, if there are 100 members in the group, your webhook will receive 100 HTTP requests. Once for each member of the group.
|
## Receive Email Notifications
Send a message to an offline user and watch them receive an email automagically!
# Overview
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/notifications/email-overview
## Introduction
Email notifications are useful as a re-engagement tool, prompting users to return to the app after an extended absence. These are useful for providing updates on messages that are unread while the user was away. The email alerts or notifications are dispatched at predetermined intervals and not in real time.
## Key features
1. **Notify users at intervals**:
Users who have unread messages can be notified at the specified intervals. The email includes these messages and are triggered for every such conversation.
2. **Contacts management**
Once the emails are verified and vetted on your end, they can be shared with the notifications system using APIs.
3. **Preferences management**:
Through CometChat's Notification Preferences, users and admins have the ability to customize the notification settings, that help provide pertinent alerts while avoiding notification fatigue.
4. **Ability to set up a schedule**:
CometChat's notifications service ensures that the notifications are delivered based on the specified daily timetable, adhering to the user's local time zone.
5. **Ability to mute notifications**:
Users have the option to completely mute notifications for the app (DND mode), or selectively mute them for specific users and groups, for a designated duration.
6. **Ability to set up Templates**:
CometChat offers developers a set of pre-defined templates that define the content shown in notifications. These templates act as a blueprint for customizing the payload content sent with notifications as per the needs and requirements.
# Flutter
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/notifications/flutter-push-notifications
Learn how to implement Push notifications for the Flutter platform using FCM as well as APNs. This document guides you to set up Flutter push notifications as follows:
1. Using FCM to implement push notifications for messaging on Android and iOS.
2. Using APN to implement push notifications for messaging on iOS.
### Step 3: FCM setup in app
This requires you to first set up a global context. It will help you in opening your app once your notification is tapped. Using this global context, you can write a function to navigate to the screen of choice once the notification is tapped.
The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
## APN: Push notifications for messaging on iOS
Apple Push Notifications service or APNs is only available for Apple devices. This will not work on Android devices.
This setup ensures that the Push notifications for CometChat messages is sent using APNs `device token`.
# iOS APNs
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/notifications/ios-apns-push-notifications
Apple Push Notification service or APNs is used to send notifications to iOS devices. With this, you can also use Apple's CallKit for showing the call screen.
2. The Certificate Information dialog box appears. Enter the email address that you use in your Apple Developer account, and enter a common name for your private key. Don't enter CA email address, choose Saved to disk, and then click the Continue button.
3. Specify the name of your CSR to save and choose the location to save the file on your local disk. Then your CSR file is created, which contains a public/private key pair.
### Step 2: Create an SSL certificate
1. Sign in to your account at the [Apple Developer Member Center](https://developer.apple.com/membercenter).
2. Go to Certificates, Identifiers & Profiles.
3. Create new Certificate by clicking on the + icon.
4. Under Services, select - Apple Push Notification services SSL (Sandbox & Production)
5. Select your App ID from the dropdown.
6. Upload CSR file., upload the CSR file you created through the **Choose File** button. To complete the process, choose Continue. When the certificate is ready, choose Download to save it to your Mac.
### Step 3: Export and update .p8 certificate
1. To generate a .p8 key file, go to [Apple developer account page](https://developer.apple.com/account/), then select Certificates, IDs & Profiles.
2. Select Keys and click on the "+" button to add a new key.
3. In the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click "Continue" and click "Register".
4. Then proceed to download the key file by clicking Download.
5. Make note of the `Key ID`, `Team ID` and your `Bundle ID` for saving in the Extension's settings.
**If you wish to use the .p12 certificate instead, do the following:**
1. Type a name for the .p12 file and save it to your Mac.
2. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and export it.
3. DO NOT provide an export password when prompted.
4. The .p12 file will be required in the next step for uploading in the CometChat Dashboard.
## Extension settings
### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open the settings for this extension and save the following.
### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
1. The extension version has to be set to 'V2' or 'V1 & V2' in order to use APNs as the provider.
2. **Select Platforms**
1. You can select the platforms on which you wish to receive Push Notifications.
3. **APNs Settings**
1. You can turn off the Production mode when you create a development build of your application.
2. Upload the .p8 or .p12 certificate exported in the previous step.
4. **Push payload message options**
The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
5. **Notification Triggers**
1. Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
2. These are pretty self-explanatory and you can toggle them as per your requirement.
## iOS App Setup
### Initial Setup
1. Call `CometChat.init()` method to initialize CometChat in your application. This needs to be called only once.
2. The user has to be logged in using `CometChat.login()` method. On the success callback, register the token with the extension. Two tokens need to be registered, out of which one is APNs token and other is CallKit token: a. `CometChat.registerTokenForPushNotification(token: apnsToken, settings: ["voip":false])`\
b. `CometChat.registerTokenForPushNotification(token: voipToken, settings: ["voip":true])`
This is a simple 3 step process where:
1. You give a name to your project
2. Add Google Analytics to your project (Optional)
3. Configure Google Analytics account (Optional)
Click on Create and you are ready to go.
### Step 2: Add Firebase to your iOS App
1. Click on the iOS icon as shown on the screen below.
2. Register your Android app by providing the following details: a. iOS bundle name b. App nickname (optional) c. App Store ID (optional)
3. Download the GoogleService-Info.plist file and place it in the mentioned location of your project. Move your config file into the root of your Xcode project. If prompted, select to add the config file to all targets as follows.
4. We will Add Firebase SDK and Initialisation code later. So, click on 'Next', 'Next', and 'Continue to the Console'.
### Step 3: Download the service account file
## Extension settings
### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open the settings for this extension and save the following settings.
### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension.
* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications.
* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely.
2. **Select the platforms that you want to support**
* Select from Web, Android, Ionic, React Native, Flutter & iOS.
3. **Notification payload settings**
* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/concept-options).
4. **Push payload message options**
The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
5. **Notification Triggers**
* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
* These are pretty self-explanatory and you can toggle them as per your requirement.
## Get APNS Credentials
The following steps in this section are written on the assumption that you already have an app ID assigned to your client app.
### Step 1: Create a Certificate Signing Request
To obtain a signing certificate required to sign apps for installation on iOS devices, you should first create a certificate signing request (CSR) file through Keychain Access on your Mac.
1. Open the Keychain Access from the utility folder, go to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority, and then click.
2. The Certificate Information dialog box appears. Enter the email address that you use in your Apple Developer account, and enter a common name for your private key. Don't enter CA email address, choose Saved to disk, and then click the Continue button.
3. Specify the name of your CSR to save and choose the location to save the file on your local disk. Then your CSR file is created, which contains a public/private key pair.
### Step 2: Create an SSL certificate
1. Sign in to your account at the [Apple Developer Member Center](https://developer.apple.com/membercenter).
2. Go to Certificates, Identifiers & Profiles. In the Identifiers > App IDs and select the Push Notifications service under Application Services
3. Click the Edit button.
4. Under the Push Notifications service, choose which SSL certificate to create either Development or Production.
5. In the Generate your certificate pane that appears after the selection, under Upload CSR file., upload the CSR file you created through the Choose File... button. To complete the process, choose Continue. When the certificate is ready, choose Download to save it to your Mac.
6. In order to install the downloaded certificate to the KeyChain Access on your Mac, double-click it. You can find the certificate in the KeyChain Access > login > Certificates.
### Step 3: Export and update .p12 file to Firebase
1. Type a name for the .p12 file and save it to your Mac.
2. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and export it.
### Step 4: Upload your APNs Certificates
1. Go to Firebase console and open your project.
2. Inside your iOS project in the Firebase console, select settings and then select the `Cloud Messaging` tab.
3. Scroll down to iOS app configuration, click the Upload button for APNS certificate.
4. Browse to the location where you saved your APNs Certificates, select it, and click Open.
## iOS App Setup
### Step 1: Initial Firebase Cloud Messaging client setup
1. Add the Firebase SDK, Add the firebase pods that you want to install. You can include a Pod in your Podfile like this:
## Step 2 : Obtain Firebase configuration for your platform
### For Web
1. Sign into Firebase and open your project.
2. On the Overview page, click Add app.
3. Select Add Firebase to your web app.
4. Copy the snippet and add it to your HTML application.
### For Android
1. Sign into Firebase and open your project.
2. On the Overview page, click Add app.
3. Select Add Firebase to your Android app.
4. Follow the on-screen instructions and finally download the google-services.json file.
### For iOS
1. Sign into Firebase and open your project.
2. On the Overview page, click Add app.
3. Select Add Firebase to your iOS app.
4. Enter the relevant details like your bundle ID and download the GoogleService-Info.plist file.
5. Move this plist file to the root of your XCode project. If prompted, select to add the config file to all targets as follows:
### For React Native
1. For React Native to Android, you need to download the `google-services.json` file.
2. For React native to iOS, you need to download the `GoogleServices-Info.plist` file.
### For Capacitor, Cordova & Ionic
1. For React Native to Android, you need to download the `google-services.json` file.
2. For React native to iOS, you need to download the `GoogleServices-Info.plist` file.
3. For web, you will need the Firebase Config object.
## Step 3: Extension setup
1. You need the Firebase Service key which you can get from Firebase console.
1. Open your Firebase app
2. Click on the Settings Cog in the left navigation menu
3. Select Project Settings and go to the Cloud Messaging tab
4. Add a Server Key and copy it for further use.
2. Login to the [CometChat Dashboard](https://app.cometchat.io/login) and select your app.
3. On the Extensions page, enable the Push Notifications extension.
4. Open the Settings for this extension.
5. Enter FCM Server key.
6. Select the platforms of choice.
7. Enter the title for notifications.
8. You can also toggle the triggers for sending Push Notifications. The triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
## Step 4: Application Setup
In order to use the topic-based Push Notifications, you need to subscribe to topics. In case of CometChat, you need to subscribe to 2 different types of topics:
1. Topic to receive Push Notifications for one-on-one messages and calls.
2. Topic to receive Push Notifications for group messages and calls.
Also, you can:
1. Subscribe to one topic
2. Subscribe to all the topics
Below steps guide you with this process of subscription to topics and specific setup for the platform of your choice.
### For Web
#### **1. Installing Firebase SDK**
Select the downloaded `GoogleService-Info.plist` file from your computer, and ensure the "Copy items if needed" checkbox is enabled.
**Configure Firebase in iOS:**
To allow Firebase on iOS to use the credentials, the Firebase iOS SDK must be configured during the bootstrap phase of your application.
To do this, open your /ios/\{projectName}/AppDelegate.m file, and add the following:
At the top of the file, import the Firebase SDK:
Lastly, Open your projects /ios/Podfile and add any of the globals shown below to the top of the file:
| Payload setting | Available preferences |
| -------------------------------- | ----------------------------------------------------------------- |
| Include CometChat message object | • **false (Default)**
1. Login to [CometChat](https://app.cometchat.com/login) dashboard and select your app.
2. Navigate to **Notifications** > **Notifications** in the left-hand menu.
3. Enable the Push notifications feature.
4. Continue to configure Push notifications by clicking on "Configure".
## Add Providers
Firebase Cloud Messaging (FCM) and Apple Push Notification Service (APNS) are the two primary supported providers for sending push notifications.
### Add FCM credentials
#### Pre-requisite
Generate a service account key for your Firebase application by navigating to the "Service accounts" section within the "Project settings" of the Firebase Cloud Messaging Dashboard. Generate new private key and download the JSON file. This will be required in the next steps.
#### Add credentials
1. Select the "+ Add Credentials" button.
2. In the dialogue that appears, provide a unique, memorable identifier for your provider.
3. Upload the service account JSON file you previously acquired.
4. Specify whether the push payload should include the "notification" key. Additional information on this configuration is available in FCM's documentation - [About FCM messages](https://firebase.google.com/docs/cloud-messaging/concept-options).
Similarly, you can add multiple FCM Credentials in case you have multiple FCM projects for your apps.
### Add APNS credentials
#### Pre-requisite
1. To generate a .p8 key file, go to [Apple developer account](https://developer.apple.com/account), then select "Certificates, IDs & Profiles".
2. Select Keys and click on the "+" button to add a new key.
3. In the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click "Continue" and click "Register".
4. Then proceed to download the key file by clicking Download.
5. Make note of the Key ID, Team ID and your Bundle ID. These are required in the next steps.
Additional information on this configuration is available in Apple's documentation - [Create a private key to access a service](https://developer.apple.com/help/account/manage-keys/create-a-private-key/)
#### Add credentials
1. Select the "+ Add Credentials" button.
2. Enable the toggle if your app is in the Production. For apps under development, the toggle has to be disabled.
3. In the dialogue that appears, provide a unique, memorable identifier for your provider.
4. Store the Key ID, Team ID, Bundle ID for your app.
5. Upload the .p8 file
6. Enable "Include content-available" if you want to receive background notifications. However, this is not recommended as the background notifications are throttled. Additional information is available in Apple's documentation - [Pushing background updates to your App](https://developer.apple.com/documentation/usernotifications/pushing-background-updates-to-your-app)
7. Enable "Include mutable-content" if you want to modify the notification before it is displayed to the user. Additional information is available in Apple's documentation - [Modifying content on newly delivered notifications](https://developer.apple.com/documentation/usernotifications/modifying-content-in-newly-delivered-notifications)
Similarly, you can add multiple APNS Credentials in case you have multiple apps with different Bundle IDs.
### Add Custom provider credentials
Custom providers allow you to make use of providers apart from FCM and APNs. This is implemented using webhook URL which gets all the required details that can be used to trigger Push notifications.
#### Pre-requisite
1. Your webhook endpoint must be accessible over `HTTPS`. This is essential to ensure the security and integrity of data transmission.
2. This URL should be publicly accessible from the internet.
3. Ensure that your endpoint supports the `HTTP POST` method. Event payloads will be delivered via `HTTP POST` requests in `JSON` format.
4. Configure your endpoint to respond immediately to the CometChat server with a 200 OK response. The response should be sent within 2 seconds of receiving the request.
5. For security, it is recommended to set up Basic Authentication that is usually used for server-to-server calls. This requires you to configure a username and password. Whenever your webhook URL is triggered, the HTTP Header will contain:
```html
Authorization: Basic
#### How does it work?
The Custom provider is triggered once for an event in one-on-one conversation. In case of notifying the members of a group, the custom provider is triggered once for each user present in that group.
For example, if there are 100 members in the group, your webhook will receive 100 HTTP requests. Once for each member of the group.
Below are the sample payloads for different events:
## Key Features
1. **Support for multiple providers**:
CometChat provides support for **Firebase Cloud Messaging (FCM)** and **Apple Push Notification Service (APNS)**. This approach, involving multiple providers, provides flexibility in notification delivery, independent of the recipient's platform. It also enables CometChat to respond effectively to the evolving push notification landscape, maintaining consistent delivery across Android, iOS, and web platforms.
2. **Support for multiple platforms**:
CometChat provides multi-platform support, compatible with an extensive array of mobile and web platforms. This includes native mobile platforms such as Android and iOS, web frameworks like React, Angular, and Vue.js, and hybrid environments including React Native and Flutter.
3. **Tokens management**:
CometChat's Push Notification service provides developers with functions and APIs for easy tokens management, ensuring that push notifications are delivered reliably to intended user's devices.
4. **Preferences management**:
Through CometChat's Notification Preferences, users and admins have the ability to customize the notification settings, that help provide pertinent alerts while avoiding notification fatigue.
5. **Ability to set up a schedule**:
CometChat's Push notifications service ensures that the notifications are delivered based on the specified daily timetable, adhering to the user's local time zone.
6. **Ability to mute notifications**:
Users have the option to completely mute push notifications for the app (DND mode), or selectively mute them for specific users and groups, for a designated duration.
7. **Ability to set up Templates and Sounds**:
CometChat offers developers a set of pre-defined templates that define the content shown in push notifications. These templates act as a blueprint for customizing the payload content sent with push notifications as per the needs and requirements.
***
## Triggering Events
In CometChat various user actions and interactions within the chat environment can trigger push notifications to ensure users stay updated and engaged. Here are some common events that typically trigger push notifications:
* **New Messages**: Whenever a user sends a new message in a one-on-one or group chat, CometChat can trigger a push notification to alert other participants about the incoming message.
* **Replies**: When a user replies to a specific message within a chat, it can trigger a push notification to notify relevant users about the reply, ensuring they are aware of the ongoing conversation.
* **Message Edited or Deleted**: Notifications are triggered when a user edits or deletes a message, informing relevant users about the changes made to the message content.
* **Mentions**: If a user is mentioned by another user using their username or handle in a message, CometChat can trigger a push notification to notify the mentioned user about the mention, prompting their attention to the message.
* **Reactions**: Users can react to messages with emojis or symbols. When a user reacts to a message, CometChat can trigger a push notification to the original sender or other participants in the chat to notify them about the reaction.
* **Group Actions**: Notifications are triggered for group actions such as member joins, member bans, and member leaves, ensuring group members are informed about changes in group dynamics.
* **Calling Events**: CometChat supports real-time audio and video calling features. Events related to incoming calls, missed calls or call invitations can trigger push notifications to alert users about these calling events, ensuring they don't miss important calls.
# React Native
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/notifications/react-native-push-notifications
Learn how to set up Push notifications for React Native using Firebase Cloud Messaging or FCM.
This is a simple 3 step process where:
1. You give a name to your project
2. Add Google Analytics to your project (Optional)
3. Configure Google Analytics account (Optional)
Click on Create and you are ready to go.
### Step 2: Add Firebase to your App
React native setup will require 2 files for Android and iOS:
1. For Android, you need to download the google-services.json file from the Firebase console.
2. For iOS, you need to download the GoogleService-Info.plist file from the Firebase console.
### Step 3: Download the service account file
## Extension settings
### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open up the settings and save the following settings.
### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension.
* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications.
* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely.
2. **Select the platforms that you want to support**
* Select from Web, Android, Ionic, React Native, Flutter & iOS.
3. **Notification payload settings**
* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/concept-options).
4. **Push payload message options**
The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
5. **Notification Triggers**
* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
* These are pretty self-explanatory and you can toggle them as per your requirement.
## App Setup
### Step 1: Initial plugin setup
1. For React Native, there are numerous plugins available via NPM which can be used to set up push notifications for your apps. [react-native-firebase](https://www.npmjs.com/package/react-native-firebase) and [react-native-notifications](https://www.npmjs.com/package/react-native-notifications) are just the two out of many available.
2. To setup Push Notification, you need to follow the steps mentioned in the Plugin's Documentation.
At this point, you will have:
1. Two separate apps created on the Firebase console. (For Android and iOS).
2. Plugin setup completed as per the respective documentation and our reference.
### Step 2: Register FCM Token
1. This step assumes that you already have a React Native app setup with CometChat installed. Make sure that the CometChat object is initialized and user has been logged in.
2. On the success callback of user login, you can fetch the FCM Token and register it with the extension as shown below:
2. The Certificate Information dialog box appears. Enter the email address that you use in your Apple Developer account, and enter a common name for your private key. Don't enter CA email address, choose Saved to disk, and then click the Continue button. \
\
3. Create new Certificate by clicking on the + icon.
4. Under Services, select - Apple Push Notification services SSL (Sandbox & Production)
5. Select your App ID from the dropdown.
6. Upload CSR file., upload the CSR file you created through the **Choose File** button. To complete the process, choose Continue. When the certificate is ready, choose Download to save it to your Mac.
#### Step 3: Export and update .p8 certificate
1. To generate a .p8 key file, go to [Apple developer account page](https://developer.apple.com/account/), then select Certificates, IDs & Profiles.
2. Select Keys and click on the "+" button to add a new key.
3. In the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click "Continue" and click "Register".
4. Then proceed to download the key file by clicking Download.
5. Make note of the `Key ID`, `Team ID` and your `Bundle ID` for saving in the Extension's settings.
**If you wish to use the .p12 certificate instead, do the following:**
1. Type a name for the .p12 file and save it to your Mac.
2. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and export it.
3. DO NOT provide an export password when prompted.
4. The .p12 file will be required in the next step for uploading in the CometChat Dashboard.
#### Extension settings
#### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open the settings for this extension and save the following.
#### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
The extension version has to be set to 'V2' or 'V1 & V2' in order to use APNs as the provider.
2. **Select Platforms**
You can select the platforms on which you wish to receive Push Notifications.
3. **Firebase Cloud Messaging Settings**
This includes the FCM Server key that you can fetch from the Firebase Dashboard.
4. **APNs Settings**
You can turn off the Production mode when you create a development build of your application. Upload the .p12 certificate exported in the previous step.
5. **Push Notifications Title**
This is usually the name of your app.
6. **Notification Triggers**
Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
These are pretty self-explanatory and you can toggle them as per your requirement.
#### Installation
We need to add two packages for this
* React-native-CallKeep
This package also require some additional installation steps. Follow [this](https://github.com/react-native-webrtc/react-native-callkeep) link to install react-native-callkeep
1. Login to [CometChat](https://app.cometchat.com/login) dashboard and select your app.
2. Navigate to **Notifications** > **Notifications** in the left-hand menu.
3. Enable SMS notifications feature.
### Save Twilio credentials
Save the following details:
* Twilio Account SID
* Twilio Auth token
* Twilio sender phone number
### Save user's timezone
A user's timezone is required to allow them to set a schedule for receiving notifications. In case the timezone is not registered, the default timezone for
* For US region: EST
* For EU region: GMT
* For IN region: Asia/Kolkata
The timezone can be registered for a user from the SDK using the `updateTimezone()` method of `CometChatNotifications` class.
Send a message to any user and keep the conversation unread for the designated amount of time to receive an SMS notification.
## Custom SMS provider
Custom provider allows you to make use of providers apart from Twilio for triggering SMS notifications. This is implemented using webhook URL which gets all the required details that can be used to trigger SMS notifications.
#### Pre-requisite
1. Your webhook endpoint must be accessible over `HTTPS`. This is essential to ensure the security and integrity of data transmission.
2. This URL should be publicly accessible from the internet.
3. Ensure that your endpoint supports the `HTTP POST` method. Event payloads will be delivered via `HTTP POST` requests in `JSON` format.
4. Configure your endpoint to respond immediately to the CometChat server with a 200 OK response. The response should be sent within 2 seconds of receiving the request.
5. For security, it is recommended to set up Basic Authentication that is usually used for server-to-server calls. This requires you to configure a username and password. Whenever your webhook URL is triggered, the HTTP Header will contain:
```html
Authorization: Basic
#### How does it work?
The Custom provider is triggered once for an event in one-on-one conversation. In case of notifying users in a group, the custom provider is triggered once for each user present in that group.
## Configure your backend to store phone number
You can use our [Update user](https://api-explorer.cometchat.com/reference/update-user) API to set private metadata for a user. We recommend adding this code when you call our [Create user](https://api-explorer.cometchat.com/reference/creates-user) API.
Alternatively, just for the sake of testing purposes, you can add this from the CometChat Dashboard as well.
1. Login to the [CometChat](https://app.cometchat.com/login).
2. Select your app and go to the "Users" section.
3. Click on the Edit option available under the three dots for the user under consideration.
4. Click on the Edit button on the Details section.
5. Paste the below JSON in the Metadata input box and hit Save.
The Metadata is a JSON that should have the `@private` key present and should have the value `contactNumber` specified for the user. The format for the private metadata must be as follows:
This is a simple 3 step process where:
1. You give a name to your project
2. Add Google Analytics to your project (Optional)
3. Configure Google Analytics account (Optional)
Click on Create and you are ready to go.
### Step 2: Add Firebase to your Web App
1. Click on the Web icon on the below screen and Register your app with a nickname.
2. Once done, click on Continue to Console.
### Step 3: Download the service account file
## Extension settings
### Step 1: Enable the extension
1. Login to [CometChat](https://app.cometchat.com/login) and select your app.
2. Go to the Extensions section and Enable the Push Notifications extension.
3. Open the settings for the extension and add all the mentioned settings and hit save.
### Step 2: Save your settings
On the Settings page you need to enter the following:
1. **Set extension version**
* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension.
* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications.
* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely.
2. **Select the platforms that you want to support**
* Select from Web, Android, Ionic, React Native, Flutter & iOS.
3. **Notification payload settings**
* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/concept-options).
4. **Push payload message options**
* The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field.
* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs.
5. **Notification Triggers**
* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories:
1. Message Notifications
2. Call Notifications
3. Group Notifications
* These are pretty self-explanatory and you can toggle them as per your requirement.
## Web App Setup
### Step 1: Folder and files setup
Create a folder with the following three files:
| Files | Description |
| ------------------------- | ------------------------------------------------------------------------------------------- |
| index.html | Displays a simple User Login Form. |
| PushNotification.js | File with the logic to initialize CometChat and Firebase. |
| firebase-messaging-sw\.js | Service worker shows Push Notifications when the tab is either in the background or closed. |
### Step 2: Add the Firebase Config to the HTML File
1. Go to the Firebase Console and click on the Web app and open up the Settings page.
2. Go to the "General" tab on the Settings page.
3. Scroll down and copy the Firebase SDK snippet and paste in the \ tag of your index.html file.
### Step 3: Setup index.html file
1. Include the latest CometChat library using CDN.
2. Register the service worker file.
3. Also, include the `PushNotification.js`.
4. The \ has a simple form:
1. Text input for UID.
2. Login button.
3. Logout button.
Once done, your `index.html` file should look like this:
Plug in your provider, wire actions, and ship chat UI — in minutes, not sprints.
Easily create, customize, and deploy intelligent AI chatbots, agents, and copilots right into your app with CometChat AI Agents.
CometChat AI Agents connect your app’s logic, state, and user context to AI-powered assistants that deliver engaging, interactive experiences — whether through embedded UIs or fully headless interfaces. You get everything you need to build, deploy, and monitor AI-assisted features that feel seamless, helpful, and deeply integrated.
With model-agnostic flexibility, CometChat AI Agents let you upgrade your AI stack anytime - without disrupting your user experience.
Three core steps to get an AI Agent into your product.
Start by linking your AI builders. Choose from popular platforms (OpenAI, Mastra, LangGraph and many more..)
More providers coming…
Create and manage frontend actions and tools to enhance your agent’s capabilities.
Actions: trigger UI & workflows. Tools: structured capabilities the agent can call.
Customize the agent’s appearance and copy the embed code to integrate it into your app.
chef, Deployment URL=public base URL from Step 2.id matches the action name for invocation context.
***
## Step 7 - Export & Embed
In Chat Builder click **Get Embedded Code** → copy credentials:
* App ID
* Auth Key
* Region
* Variant ID
Example embed (HTML):
open\_product).
***
{/* npx mastra dev starts local API (commonly [http://localhost:4111/api](http://localhost:4111/api)).Quick test (replace AGENT\_ID):
Append route (e.g. /api/agents/chef/generate) to the forwarded HTTPS URL.
Use the final HTTPS URL + path for Deployment URL and the agent key (e.g. chef) for Mastra Agent ID.
authKey only for development. For production, implement a secure token flow for user login./api/agents/deals/generate and verify the answer is backed by tool output.deals, Deployment URL=your public generate endpoint./api/agents/deals/generate returns a message backed by tool output./api/agents includes "deals".get-deals tool invoked when appropriate./api/agents/celebration/generate and inspect tool calls in the response.celebration, Deployment URL=your public generate endpoint./api/agents/celebration/generate returns a message, possibly with a tool call./api/agents includes "celebration".confetti tool when the agent requests it.namespace using the ingestSources tool. Parsed content is stored under knowledge/\ for repeatable retrieval.
* Retrieves relevant snippets with the docsRetriever tool. It scans your knowledge/\ content, chunks and ranks results, and returns the best matches with source metadata.
* Generates answers using only retrieved context. The agent replies when invoked (e.g., @agent), composes a concise answer, and appends a short “Sources” list with citations.
* Handles errors defensively. Server utilities sanitize errors before returning responses.
Key components (source-linked below): the agent, docs retriever tool, ingest endpoints, and server routes.
***
## Setup
OPENAI\_API\_KEY in .env. See the repository README for exact steps.
@agent).
/api/tools/ingestSources, /api/tools/searchDocs, and /api/agents/knowledge/generate (see server entry).
namespace (e.g., docs) and POST sources to /api/tools/ingestSources. Use URLs, file paths, or raw text. Request shape is documented in the README Quickstart.
/api/agents/knowledge/generate with a messages array. Optionally pass toolParams.namespace to scope retrieval.
knowledge, and point Deployment URL to your public generate endpoint.
/api/tools/ingestSources with a namespace. Example commands are in the README Quickstart.
/api/agents/knowledge/generate. See the README Quickstart for request bodies and examples.
knowledge, Deployment URL=your public generate endpoint.
***
## Step 7 - Integrate
Once your Knowledge Agent is configured, you can integrate it into your app using the CometChat No Code - Widget:
/api/agents/knowledge/generate returns a doc-grounded answer./api/agents includes "knowledge".docsRetriever tool invocation.OPENAI\_API\_KEY in .env. See the repository README for exact steps.
/api/agents/orchestratorAgent/generate (see server entry).
/api/agents/orchestratorAgent/generate with a messages array and verify routed answers.
orchestratorAgent, and point Deployment URL to your public generate endpoint.
.env with OPENAI\_API\_KEY
* Runtime & config
* [package.json](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/package.json)
* [tsconfig.json](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/tsconfig.json)
* [README.md](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/README.md)
* Agents
* [src/mastra/agents/orchestrator-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/orchestrator-agent.ts)
* [src/mastra/agents/billing-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/billing-agent.ts)
* [src/mastra/agents/support-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/support-agent.ts)
* [src/mastra/agents/tech-support-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/tech-support-agent.ts)
* [src/mastra/agents/manager-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/manager-agent.ts)
* [src/mastra/agents/human-rep-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/human-rep-agent.ts)
* Tools
* [src/mastra/tools/orchestrator-tool.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/tools/orchestrator-tool.ts)
* Workflows
* [src/mastra/workflows/orchestrator-workflow.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/workflows/orchestrator-workflow.ts)
* Server
* [src/mastra/index.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/index.ts)
***
## Step 1 - Create the Orchestrator and Specialist Agents
**`src/mastra/agents/orchestrator-agent.ts`** ([view in repo](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/orchestrator-agent.ts)):
Checklist for the orchestrator:
* Register the agent with key **"orchestratorAgent"** so the API path is `/api/agents/orchestratorAgent/*`.
* Detect intents (billing, support, tech, manager, human rep).
* Use the routing tool/workflow to hand off.
* Compose a concise final reply.
Specialists (configure as needed):
* Billing: [billing-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/billing-agent.ts)
* Support: [support-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/support-agent.ts)
* Tech Support: [tech-support-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/tech-support-agent.ts)
* Manager: [manager-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/manager-agent.ts)
* Human Rep: [human-rep-agent.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/agents/human-rep-agent.ts)
***
## Step 2 - Routing Tool and Workflow
* Routing tool: [orchestrator-tool.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/tools/orchestrator-tool.ts)
* Workflow: [orchestrator-workflow.ts](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/workflows/orchestrator-workflow.ts)
Ensure the orchestrator agent calls the tool/workflow with the correct context, and specialists are discoverable by key.
***
## Step 3 - Register the Agents in Mastra
**`src/mastra/index.ts`** ([view in repo](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/src/mastra/index.ts)):
* Register the orchestrator with key **"orchestratorAgent"** → API path `/api/agents/orchestratorAgent/*`.
* Register specialist agents and expose only the orchestrator externally.
* Keep config and logger settings as per the repo README.
***
## Step 4 - Run the Orchestrator
*Dev scripts & server details are in your repo:*
* Scripts: [package.json](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/package.json)
* README: [Project README](https://github.com/cometchat/ai-agent-mastra-examples/blob/main/mastra-orchestrator-agent/README.md)
Expected local API base: `http://localhost:4111/api`
npm install.npx mastra dev (or npm run dev)./api/agents/orchestratorAgent/generate and verify the routed specialist answers.(\[routedTo] | escalated: yes/no); check logs for which specialist was chosen.orchestratorAgent, Deployment URL=your public generate endpoint./api/agents/orchestratorAgent/generate returns an answer from the chosen specialist and ends with routing metadata./api/agents includes "orchestratorAgent".
## Complete Integration Workflow
1. Design your chat experience in Chat Builder.
2. Export your code and settings package.
3. Enable extra features in the CometChat Dashboard if needed.
4. Optionally preview the experience in a sample app.
5. Integrate into your Android project.
6. Customize further with UI Kit styling and components.
***
## Launch the Chat Builder
1. Log in to your CometChat Dashboard: [https://app.cometchat.com](https://app.cometchat.com)
2. Select your application.
3. Go to Integrate → Android → Launch Chat Builder.
***
## Enable Features in CometChat Dashboard
If your app needs any of these, enable them from your Dashboard: [https://app.cometchat.com](https://app.cometchat.com)
* Stickers
* Polls
* Collaborative whiteboard
* Collaborative document
* Message translation
* AI User Copilot: Conversation starter, Conversation summary, Smart reply
How to enable:
1. Log in to the Dashboard.
2. Select your app.
3. Navigate to Chat → Features.
4. Toggle ON the required features and Save.
***
## Integration with CometChat Chat Builder (Android)
Follow these steps in your existing Android app (from README):
### Step 1: Add CometChat Maven repository
Add to `settings.gradle.kts` (dependencyResolutionManagement):
```kotlin
maven("https://dl.cloudsmith.io/public/cometchat/cometchat/maven/")
```
### Step 2: Add UI Kit dependencies
In your app module `build.gradle`:
```gradle
dependencies {
// CometChat UIKit
implementation 'com.cometchat:chat-uikit-android:5.1.0'
// Optional: voice/video calling
implementation 'com.cometchat:calls-sdk-android:4.1.2'
}
```
### Step 3: Apply the Builder Settings plugin
In your app module `build.gradle` plugins block:
```gradle
plugins {
id("com.cometchat.builder.settings") version "5.0.0"
}
```
Sync the project to download plugin dependencies.
### Step 4: Add Builder configuration JSON
Place `cometchat-builder-settings.json` at your app module root (same level as `build.gradle`).
### Step 5: Build to generate settings and styles
Run a build to generate `CometChatBuilderSettings.kt` and add required theme styles:
```bash
./gradlew build
```
### Step 6: Copy the helper utility
Copy `BuilderSettingsHelper.kt` from the sample app into your project package (adjust package name):
* Source: `src/main/java/com/cometchat/sampleapp/kotlin/buildersetup/BuilderSettingsHelper.kt`
* Destination: `src/main/java/
***
## Try Live Demo
Experience the CometChat Builder in action:
## Complete Integration Workflow
1. Design your chat experience in Chat Builder.
2. Export your code/settings or connect via QR.
3. Enable extra features in the CometChat Dashboard if needed.
4. Optionally preview on device/simulator.
5. Integrate into your Xcode project.
6. Customize further with UI Kit styling and components.
***
## Launch the Chat Builder
1. Log in to your CometChat Dashboard: [https://app.cometchat.com](https://app.cometchat.com)
2. Select your application.
3. Go to Integrate → iOS → Launch Chat Builder.
***
## Enable Features in CometChat Dashboard
If your app needs any of these, enable them from your Dashboard: [https://app.cometchat.com](https://app.cometchat.com)
* Stickers
* Polls
* Collaborative whiteboard
* Collaborative document
* Message translation
* AI User Copilot: Conversation starter, Conversation summary, Smart reply
How to enable:
1. Log in to the Dashboard.
2. Select your app.
3. Navigate to Chat → Features.
4. Toggle ON the required features and Save.
***
## Integration with CometChat Chat Builder (iOS)
Installation and configuration options from README‑iOS:
### Install the Builder package
***
## Try Live Demo
Experience the CometChat Builder in action:
***
### Default Format Used
```javascript
new CalendarObject({
today: "today",
yesterday: "yesterday",
otherDays: "DD MMM, YYYY", // e.g., "25 Jan, 2025"
});
```
***
## **Complete Integration Workflow**
1. **Design Your Chat Experience** - Use the Chat Builder to customize layouts, features, and styling.
2. **Export Your Code** - Once satisfied, download the generated code package.
3. **Enable Features** - Enable additional features in the CometChat Dashboard if required.
4. **Preview Customizations** - Optionally, preview the chat experience before integrating it into your project.
5. **Integration** - Integrate into your existing application.
6. **Customize Further** - Explore advanced customization options to tailor the chat experience.
***
## **Launch the Chat Builder**
1. Log in to your [**CometChat Dashboard**](https://app.cometchat.com).
2. Select your application from the list.
3. Navigate to **Integrate** > **React** > **Launch Chat Builder**.
***
## **Enable Features in CometChat Dashboard**
If your app requires any of the following features, make sure to enable them from the **[CometChat Dashboard](https://app.cometchat.com/)**
* **Stickers** – Allow users to send expressive stickers.
* **Polls** – Enable in-chat polls for user engagement.
* **Collaborative Whiteboard** – Let users draw and collaborate in real time.
* **Collaborative Document** – Allow multiple users to edit documents together.
* **Message Translation** – Translate messages between different languages.
* **AI User Copilot**
* Conversation Starter – Suggests conversation openers.
* Conversation Summary – Generates AI-powered chat summaries.
* Smart Reply – Provides quick reply suggestions.
### **How to Enable These Features?**
1. Log in to your **[CometChat Dashboard](https://app.cometchat.com)**
2. Select your application.
3. Navigate to **Chat > Features**.
4. Toggle **ON** the required features.
5. Click **Save Changes**.
***
## **Preview Customizations (Optional)**
Before integrating the Chat Builder into your project, you can preview the chat experience by following these steps. This step is completely optional and can be skipped if you want to directly integrate the Chat Builder into your project.
> You can preview the experience:
>
> 1. Open the `cometchat-app-react` folder.
> 2. Add credentials for your app in `src/index.tsx`:
>
> ```javascript
> export const COMETCHAT_CONSTANTS = {
> APP_ID: "", // Replace with your App ID
> REGION: "", // Replace with your App Region
> AUTH_KEY: "", // Replace with your Auth Key or leave blank if you are authenticating using Auth Token
> };
> ```
>
> 3. Install dependencies:
>
> ```
> npm i
> ```
>
> 4. Run the app:
>
> ```powershell
> npm start
> ```
***
## **Integration with CometChat Chat Builder (Next.js)**
### **Step 1: Install Dependencies**
```ruby
npm install @cometchat/chat-uikit-react@6.2.3 @cometchat/calls-sdk-javascript
```
### **Step 2: Copy CometChat Folder**
Copy the `cometchat-app-react/src/CometChat` folder inside your `src/app` directory.
***
### **Step 3: Create & Initialize `CometChatNoSSR.tsx`**
Directory Structure:
```swift
src/app/
├── CometChat/
└── CometChatNoSSR/
└── CometChatNoSSR.tsx
```
src/app/CometChatNoSSR/CometChatNoSSR.tsx
```javascript
import React, { useEffect } from "react";
import {
CometChatUIKit,
UIKitSettingsBuilder,
} from "@cometchat/chat-uikit-react";
import CometChatApp from "../CometChat/CometChatApp";
import { CometChatProvider } from "../CometChat/context/CometChatContext";
import { setupLocalization } from "../CometChat/utils/utils";
export const COMETCHAT_CONSTANTS = {
APP_ID: "", // Replace with your App ID
REGION: "", // Replace with your App Region
AUTH_KEY: "", // Replace with your Auth Key or leave blank if you are authenticating using Auth Token
};
const CometChatNoSSR: React.FC = () => {
useEffect(() => {
const UIKitSettings = new UIKitSettingsBuilder()
.setAppId(COMETCHAT_CONSTANTS.APP_ID)
.setRegion(COMETCHAT_CONSTANTS.REGION)
.setAuthKey(COMETCHAT_CONSTANTS.AUTH_KEY)
.subscribePresenceForAllUsers()
.build();
CometChatUIKit.init(UIKitSettings)
?.then(() => {
setupLocalization();
console.log("Initialization completed successfully");
})
.catch((error) => console.error("Initialization failed", error));
}, []);
return (
***
## **Try Live Demo**
**Experience the CometChat Chat Builder in action:**
***
### Default Format Used
```javascript
new CalendarObject({
today: "today",
yesterday: "yesterday",
otherDays: "DD MMM, YYYY", // e.g., "25 Jan, 2025"
});
```
***
## **Complete Integration Workflow**
1. **Design Your Chat Experience** - Use the Chat Builder to customize layouts, features, and styling.
2. **Export Your Code** - Once satisfied, download the generated code package.
3. **Enable Features** - Enable additional features in the CometChat Dashboard if required.
4. **Preview Customizations** - Optionally, preview the chat experience before integrating it into your project.
5. **Integration** - Integrate into your existing application.
6. **Customize Further** - Explore advanced customization options to tailor the chat experience.
***
## **Launch the Chat Builder**
1. Log in to your [**CometChat Dashboard**](https://app.cometchat.com).
2. Select your application from the list.
3. Navigate to **Integrate** > **React** > **Launch Chat Builder**.
***
## **Enable Features in CometChat Dashboard**
If your app requires any of the following features, make sure to enable them from the **[CometChat Dashboard](https://app.cometchat.com/)**
* **Stickers** – Allow users to send expressive stickers.
* **Polls** – Enable in-chat polls for user engagement.
* **Collaborative Whiteboard** – Let users draw and collaborate in real time.
* **Collaborative Document** – Allow multiple users to edit documents together.
* **Message Translation** – Translate messages between different languages.
* **AI User Copilot**
* Conversation Starter – Suggests conversation openers.
* Conversation Summary – Generates AI-powered chat summaries.
* Smart Reply – Provides quick reply suggestions.
### **How to Enable These Features?**
1. Log in to your **[CometChat Dashboard](https://app.cometchat.com)**
2. Select your application.
3. Navigate to **Chat > Features**.
4. Toggle **ON** the required features.
5. Click **Save Changes**.
***
## **Preview Customizations (Optional)**
Before integrating the Chat Builder into your project, you can preview the chat experience by following these steps. This step is completely optional and can be skipped if you want to directly integrate the Chat Builder into your project.
> You can preview the experience:
>
> 1. Open the `cometchat-app-react` folder.
> 2. Add credentials for your app in `src/index.tsx`:
>
> ```javascript
> export const COMETCHAT_CONSTANTS = {
> APP_ID: "", // Replace with your App ID
> REGION: "", // Replace with your App Region
> AUTH_KEY: "", // Replace with your Auth Key or leave blank if you are authenticating using Auth Token
> };
> ```
>
> 3. Install dependencies:
>
> ```
> npm i
> ```
>
> 4. Run the app:
>
> ```powershell
> npm start
> ```
***
## **Integration with CometChat Chat Builder (React Router)**
### **Step 1: Install Dependencies**
```ruby
npm install @cometchat/chat-uikit-react@6.2.3 @cometchat/calls-sdk-javascript
```
### **Step 2: Copy CometChat Folder**
Copy the `cometchat-app-react/src/CometChat` folder inside your `src/app` directory.
***
### **Step 3: Create & Initialize `CometChatNoSSR.tsx`**
Directory Structure:
```swift
src/app/
├── CometChat/
└── CometChatNoSSR/
└── CometChatNoSSR.tsx
```
```tsx src/app/CometChatNoSSR/CometChatNoSSR.tsx
import React, { useEffect, useState } from "react";
import {
CometChatUIKit,
UIKitSettingsBuilder,
} from "@cometchat/chat-uikit-react";
import CometChatApp from "../CometChat/CometChatApp";
import { CometChatProvider } from "../CometChat/context/CometChatContext";
import { setupLocalization } from "../CometChat/utils/utils";
export const COMETCHAT_CONSTANTS = {
APP_ID: "", // Replace with your App ID
REGION: "", // Replace with your App Region
AUTH_KEY: "", // Replace with your Auth Key
};
const CometChatNoSSR: React.FC = () => {
const [initialized, setInitialized] = useState(false);
useEffect(() => {
if (typeof window === "undefined") return;
const UIKitSettings = new UIKitSettingsBuilder()
.setAppId(COMETCHAT_CONSTANTS.APP_ID)
.setRegion(COMETCHAT_CONSTANTS.REGION)
.setAuthKey(COMETCHAT_CONSTANTS.AUTH_KEY)
.subscribePresenceForAllUsers()
.build();
CometChatUIKit.init(UIKitSettings)
?.then(() => {
setupLocalization();
console.log("Initialization completed successfully");
setInitialized(true);
})
.catch((error) => console.error("Initialization failed", error));
}, []);
if (!initialized) {
return
***
***
## **Try Live Demo**
**Experience the CometChat Chat Builder in action:**
***
### Default Format Used
```javascript
new CalendarObject({
today: "today",
yesterday: "yesterday",
otherDays: "DD MMM, YYYY", // e.g., "25 Jan, 2025"
});
```
***
## **Complete Integration Workflow**
1. **Design Your Chat Experience** - Use the Chat Builder to customize layouts, features, and styling.
2. **Export Your Code** - Once satisfied, download the generated code package.
3. **Enable Features** - Enable additional features in the CometChat Dashboard if required.
4. **Preview Customizations** - Optionally, preview the chat experience before integrating it into your project.
5. **Integration** - Integrate into your existing application.
6. **Customize Further** - Explore advanced customization options to tailor the chat experience.
***
## **Launch the Chat Builder**
1. Log in to your [**CometChat Dashboard**](https://app.cometchat.com).
2. Select your application from the list.
3. Navigate to **Integrate** > **React** > **Launch Chat Builder**.
***
## **Enable Features in CometChat Dashboard**
If your app requires any of the following features, make sure to enable them from the **[CometChat Dashboard](https://app.cometchat.com/)**
* **Stickers** – Allow users to send expressive stickers.
* **Polls** – Enable in-chat polls for user engagement.
* **Collaborative Whiteboard** – Let users draw and collaborate in real time.
* **Collaborative Document** – Allow multiple users to edit documents together.
* **Message Translation** – Translate messages between different languages.
* **AI User Copilot**
* Conversation Starter – Suggests conversation openers.
* Conversation Summary – Generates AI-powered chat summaries.
* Smart Reply – Provides quick reply suggestions.
### **How to Enable These Features?**
1. Log in to your **[CometChat Dashboard](https://app.cometchat.com)**
2. Select your application.
3. Navigate to **Chat > Features**.
4. Toggle **ON** the required features.
5. Click **Save Changes**.
***
## **Preview Customizations (Optional)**
Before integrating the Chat Builder into your project, you can preview the chat experience by following these steps. This step is completely optional and can be skipped if you want to directly integrate the Chat Builder into your project.
> You can preview the experience:
>
> 1. Open the `cometchat-app-react` folder.
> 2. Add credentials for your app in `src/index.tsx` (`src/main.tsx` incase for Vite):
>
> ```javascript
> export const COMETCHAT_CONSTANTS = {
> APP_ID: "", // Replace with your App ID
> REGION: "", // Replace with your App Region
> AUTH_KEY: "", // Replace with your Auth Key or leave blank if you are authenticating using Auth Token
> };
> ```
>
> 3. Install dependencies:
>
> ```
> npm i
> ```
>
> 4. Run the app:
>
> ```powershell
> npm start
> ```
***
## **Integration with CometChat Chat Builder (React.js)**
Follow these steps to integrate CometChat Chat Builder into your existing React project:
### **Step 1: Install Dependencies**
Run the following command to install the required dependencies:
```ruby
npm install @cometchat/chat-uikit-react@6.2.3 @cometchat/calls-sdk-javascript
```
### **Step 2: Copy CometChat Folder**
Copy the `cometchat-app-react/src/CometChat` folder into your project's `src` directory.
### **Step 3: Initialize CometChat UI Kit**
The initialization process varies depending on your setup. Select your framework:
***
## **Try Live Demo**
**Experience the CometChat Builder in action:**
## Why It Matters
* Gain detailed statistics about user interactions with CometChat services.
* Measure user engagement using various parameters.
* Identify churn patterns and take corrective actions.
* Define and analyze conversational funnels using AI-powered insights.
* Classify and measure user personalities based on conversation styles.
* Optimize chat experiences and enhance user engagement through data-driven decision-making.
***
## Users & Groups
High‑level engagement & population health.
At the recipients' end, from the `message` object, you can fetch the metadata by calling the `getMetadata()` method. Using this metadata, you can fetch information whether the image is safe or unsafe.
All the messages that match the moderation criteria will get listed from oldest to newest. You can perform the following actions for a particular message:
1. **Approve:** The message gets sent to the Receiver and disappears from the list.
2. **Reject:** The message gets deleted and is not sent to the intended receiver.
3. **Kick:** Available for Group conversations. A notorious user gets kicked out of the group. They can rejoin the group.
4. **Ban:** Available for Group conversations. A notorious user gets banned from the group. They cannot rejoin later unless they are unbanned.
Apart from the above actions, you can also quickly access the Settings for the Extension. You can toggle Auto-refresh Messages and also toggle the Switch to Enable/Disable the Moderation.
At the recipients' end, from the `message` object, you can fetch the metadata by calling the `getMetadata()` method. Using this metadata, you can fetch the sentiment of the message.
As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
1. Message
2. Custom
3. Action
4. Call
Each category can be further be classified into types.
A message belonging to the category `message` can be classified into either 1 of the below types:
1. text - A plain text message
2. image- An image message
3. video- A video message
4. audio- An audio message
5. file- A file message
## Custom
In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
## Interactive
An InteractiveMessage is a specialized object that encapsulates an interactive unit within a chat message, such as an embedded form that users can fill out directly within the chat interface. Messages belonging to the interactive category can further be classified into one of the below types:
1. form- for interactive form
2. card- for interactive card
3. customInteractive- for custom interaction messages
Loading....
; } ```Loading....
) } ```
## Conversation Starters
When a user initiates a new chat, the UI kit displays a list of suggested opening lines that users can select, making it easier for them to start a conversation. These suggestions are powered by CometChat's AI, which predicts contextually relevant conversation starters.
For a comprehensive understanding and guide on implementing and using the Conversation Starters, refer to our specific guide on the [Conversation Starter](/fundamentals/ai-user-copilot/conversation-starter).
Once you have successfully activated the [Conversation Starter](/fundamentals/ai-user-copilot/conversation-starter) from your CometChat Dashboard, the feature will automatically be incorporated into the [MessageList](/ui-kit/react/message-list) Component of UI Kits.
## Smart Replies
Smart Replies are AI-generated responses to messages. They can predict what a user might want to say next by analyzing the context of the conversation. This allows for quicker and more convenient responses, especially on mobile devices.
For a comprehensive understanding and guide on implementing and using the Smart Replies, refer to our specific guide on the [Smart Replies](/fundamentals/ai-user-copilot/smart-replies).
Once you have successfully activated the [Smart Replies](/fundamentals/ai-user-copilot/smart-replies) from your CometChat Dashboard, the feature will automatically be incorporated into the Action sheet of [MessageComposer](/ui-kit/react/message-composer) Component of UI Kits.
## Conversation Summary
The Conversation Summary feature provides concise summaries of long conversations, allowing users to catch up quickly on missed chats. This feature uses natural language processing to determine the main points in a conversation.
For a comprehensive understanding and guide on implementing and using the Conversation Summary, refer to our specific guide on the [Conversation Summary](/fundamentals/ai-user-copilot/conversation-summary).
Once you have successfully activated the [Conversation Summary](/fundamentals/ai-user-copilot/conversation-summary) from your CometChat Dashboard, the feature will automatically be incorporated into the Action sheet of [MessageComposer](/ui-kit/react/message-composer) Component of UI Kits.
# Call Buttons
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/ui-kit/react/call-buttons
## Overview
The `Call Button` is a Component provides users with the ability to make calls, access call-related functionalities, and control call settings. Clicking this button typically triggers the call to be placed to the desired recipient.
## Usage
### Integration
**Example**
## Features
### Incoming Call
The [Incoming Call](/ui-kit/react/incoming-call) component of the CometChat UI Kit provides the functionality that lets users receive real-time audio and video calls in the app.
When a call is made to a user, the Incoming Call component triggers and displays a call screen. This call screen typically displays the caller information and provides the user with options to either accept or reject the incoming call.
### Outgoing Call
The [Outgoing Call](/ui-kit/react/outgoing-call) component of the CometChat UI Kit is designed to manage the outgoing call process within your application. When a user initiates an audio or video call to another user or group, this component displays an outgoing call screen, showcasing information about the recipient and the call status.
Importantly, the Outgoing Call component is smartly designed to transition automatically into the ongoing call screen once the receiver accepts the call. This ensures a smooth flow from initiating the call to engaging in a conversation, without any additional steps required from the user.
### Call Logs
[Call Logs](/ui-kit/react/call-logs) component provides you with the records call events such as who called who, the time of the call, and the duration of the call. This information can be fetched from the CometChat server and displayed in a structured format for users to view their past call activities.
# Call Logs
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/ui-kit/react/call-logs
## Overview
`CometChatCallLogs` is a Component that shows the list of Call Log available . By default, names are shown for all listed users, along with their avatar if available.
The `Call Logs` is comprised of the following components:
| Components | Description |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
| CometChatList | A reusable container component having title, search box, customizable background and a list view. |
| CometChatListItem | A component that renders data obtained from a Group object on a Tile having a title, subtitle, leading and trailing view. |
| CometChatDate | This component used to show the date and time. You can also customize the appearance of this widget by modifying its logic. |
## Usage
### Integration
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
## Usage
### Integration
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
| Components | Functionality |
| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [Message Composer](/ui-kit/react/message-composer) | The [Message Composer](/ui-kit/react/message-composer) is a Component that enables users to write and send a variety of messages. |
| [Message List](/ui-kit/react/message-list) | The [Message List](/ui-kit/react/message-list) is a Component that renders a list of messages sent and messages received using Text Bubble. |
## Media Sharing
Beyond text, CometChat allows users to share various media types within their conversations. This includes images, videos, audio files, and documents, enriching the chat experience and enabling more comprehensive communication.
| Components | Functionality |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Message Composer](/ui-kit/react/message-composer) | The [Message Composer](/ui-kit/react/message-composer) component includes an ActionSheet. This ActionSheet serves as a menu appearing over the app's context, offering various options for sharing media files. |
| [Message List](/ui-kit/react/message-list) | The [Message List](/ui-kit/react/message-list) component is responsible for rendering various Media Message bubbles, such as Image, File, Audio & Video Bubble. |
## Read Receipts
CometChat's Read Receipts feature provides visibility into the message status, letting users know when a message has been delivered and read. This brings clarity to the communication and ensures users are informed about the status of their messages.
| Components | Functionality |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Conversations](/ui-kit/react/conversations) | [Conversations](/ui-kit/react/conversations) is a component that renders conversation list item. Conversation item also displays the delivery status of the last message providing users with real-time updates on the status of their messages. |
| [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) is a component that renders different types of message bubbles. Read receipt status is an integral part of all message bubbles, no matter the type and provides real-time updates about the status of the message. |
| Message Information | Message Information component provides transparency into the status of each sent message, giving the sender insights into whether their message has been delivered and read. |
## Typing Indicator
The Typing Indicator feature in CometChat shows when a user is typing a response in real-time, fostering a more interactive and engaging chat environment. This feature enhances the real-time communication experience, making conversations feel more natural and fluid.
| Components | Functionality |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Conversations](/ui-kit/react/conversations) | [Conversations](/ui-kit/react/conversations) is a component that renders conversation list item. Conversations item also shows real-time typing status indicators. This means that if a user in a one-on-one chat or a participant in a group chat is currently typing a message. |
| [Message Header](/ui-kit/react/message-header) | [Message Header](/ui-kit/react/message-header) that renders details of User or Groups in ToolBar. The Message Header also handles the typing indicator functionality. When a user or a member in a group is typing, the Message Header dynamically updates to display a `typing...` status in real-time. |
## User Presence
CometChat's User Presence feature allows users to see whether their contacts are online, offline. This helps users know the best time to initiate a conversation and sets expectations about response times.
| Components | Functionality |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Conversations](/ui-kit/react/conversations) | [Conversations](/ui-kit/react/conversations) is a component that renders conversation list item. Conversations item also shows user presence information. |
| [Message Header](/ui-kit/react/message-header) | [Message Header](/ui-kit/react/message-header) that renders details of user/group. The Message Header also handles user presence information. |
| [Users](/ui-kit/react/users) | [Users](/ui-kit/react/users) renders list of users available in your app.It also responsible to render users presence information. |
| [Group Members](/ui-kit/react/group-members) | [Group Members](/ui-kit/react/group-members) renders list of users available in the group. The Group Members component also handles user presence information. |
## Reactions
CometChat's Reactions feature adds a layer of expressiveness to your chat application by allowing users to react to messages. With reactions, users can convey a range of emotions or express their thoughts on a particular message without typing out a full response, enhancing their user experience and fostering greater engagement.
| Components | Functionality |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) is a component that renders different types of message bubbles. Reactions are an integral part and offer a more engaging, expressive way for users to respond to messages. |
## Mentions
Mentions is a robust feature provided by CometChat that enhances the interactivity and clarity of group or 1-1 chats by allowing users to directly address or refer to specific individuals in a conversation.
| Components | Functionality |
| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Conversations](/ui-kit/react/conversations) | [Conversations](/ui-kit/react/conversations) component provides an enhanced user experience by integrating the Mentions feature. This means that from the conversation list itself, users can see where they or someone else have been specifically mentioned. |
| [Message Composer](/ui-kit/react/message-composer) | [Message Composer](/ui-kit/react/message-composer) is a component that allows users to craft and send various types of messages, including the usage of the mentions feature for direct addressing within the conversation. |
| [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) is a component that displays a list of sent and received messages. It also supports the rendering of Mentions, enhancing the readability and interactivity of conversations. |
## Threaded Conversations
The Threaded Conversations feature enables users to respond directly to a specific message in a chat. This keeps conversations organized and enhances the user experience by maintaining context, especially in group chats.
| Components | Functionality |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| [Threaded Message Preview](/ui-kit/react/threaded-message-preview) | [Threaded Message Preview](/ui-kit/react/threaded-message-preview) component displays the parent message along with the number of replies. |
## Group Chat
CometChat facilitates Group Chats, allowing users to have conversations with multiple participants simultaneously. This feature is crucial for team collaborations, group discussions, social communities, and more.
For a comprehensive understanding and guide on implementing and using the Groups feature in CometChat, you should refer to our detailed guide on [Groups](/ui-kit/react/groups).
# Custom Text Formatter
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/ui-kit/react/custom-text-formatter-guide
## Overview
You can create your custom text formatter for CometChat using the `CometChatTextFormatter`. `CometChatTextFormatter` is an abstract utility class that serves as a foundational structure for enabling text formatting in the message composer and text message bubbles. It can be extended to create custom formatter classes, tailored to suit specific application needs, making it a valuable tool for text customization and enhancement in chat interfaces.
## Features
* **Text Formatting:**: Enables automatic formatting of text within messages based on specified styles and settings, enhancing the visual presentation of chat content.
* **Customizable Styles:**: Tailor text styles, including colors, fonts, and background colors, to match the desired appearance for formatted text.
* **Dynamic Text Replacement:**: Utilizes regular expression patterns to identify and replace specific text patterns with formatted content, offering flexibility in text manipulation.
* **Input Field Integration:**: Seamlessly integrates with the text input field, allowing for real-time monitoring and processing of user input for formatting purposes.
* **Callback Functions:**: Implement callback functions for key up and key down events, providing hooks for custom actions or formatting logic based on user interactions.
### Polls
The Polls extension enhances group discussions by allowing users to create polls. Users can ask questions with a predefined list of answers, enabling a quick, organized way to gather group opinions. For a comprehensive understanding and guide on implementing and using the Polls Extension, refer to our specific guide on the [Polls Extension](/fundamentals/polls).
Once you have successfully activated the [Polls Extension](/fundamentals/polls) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of the [Message Composer](/ui-kit/react/message-composer) component of UI Kits.
### Collaborative Whiteboard
The Collaborative Whiteboard extension facilitates real-time collaboration. Users can draw, brainstorm, and share ideas on a shared digital whiteboard. For a comprehensive understanding and guide on implementing and using the Collaborative Whiteboard Extension, refer to our specific guide on the [Collaborative Whiteboard Extension](/fundamentals/collaborative-whiteboard).
Once you have successfully activated the [Collaborative Whiteboard Extension](/fundamentals/collaborative-whiteboard) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of the [Message Composer](/ui-kit/react/message-composer) component of UI Kits.
### Collaborative Document
With the Collaborative Document extension, users can work together on a shared document. This feature is essential for remote teams where document collaboration is a recurring requirement. For a comprehensive understanding and guide on implementing and using the Collaborative Document Extension, refer to our specific guide on the [Collaborative Document Extension](/fundamentals/collaborative-document).
Once you have successfully activated the [Collaborative Document Extension](/fundamentals/collaborative-document) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of the [Message Composer](/ui-kit/react/message-composer) component of UI Kits.
### Message Translation
The Message Translation extension in CometChat is designed to translate any message into your local locale. It eliminates language barriers, making the chat more inclusive. For a comprehensive understanding and guide on implementing and using the Message Translation Extension, refer to our specific guide on the [Message Translation Extension](/fundamentals/message-translation).
Once you have successfully activated the [Message Translation Extension](/fundamentals/message-translation) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of [MessageList Component](/ui-kit/react/message-list) component of UI Kits.
### Link Preview
The Link Preview extension provides a summary of the URL shared in the chat. It includes the title, a description, and a thumbnail image from the web page. For a comprehensive understanding and guide on implementing and using the Link Preview Extension, refer to our specific guide on the [Link Preview Extension](/fundamentals/link-preview).
Once you have successfully activated the [Link Preview Extension](/fundamentals/link-preview) from your CometChat Dashboard, the feature will automatically be incorporated into the Message Bubble of [MessageList Component](/ui-kit/react/message-list) component of UI Kits.
### Thumbnail Generation
The Thumbnail Generation extension automatically creates a smaller preview image whenever a larger image is shared, helping to reduce the upload/download time and bandwidth usage. For a comprehensive understanding and guide on implementing and using the Thumbnail Generation Extension, refer to our specific guide on the [Thumbnail Generation Extension](/fundamentals/thumbnail-generation).
Once you have successfully activated the [Thumbnail Generation Extension](/fundamentals/thumbnail-generation) from your CometChat Dashboard, the feature will automatically be incorporated into the Message Bubble of [MessageList Component](/ui-kit/react/message-list) component of UI Kits.
***
## Usage
### Integration
The following code snippet illustrates how you can directly incorporate the Group Members component into your Application.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The Groups component is composed of the following BaseComponents:
| Components | Description |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------- |
| CometChatList | A reusable container component having title, search box, customisable background and a list view. |
| CometChatListItem | A component that renders data obtained from a Group object on a Tile having a title, subtitle, leading and trailing view. |
***
## Usage
### Integration
The following code snippet illustrates how you can directly incorporate the Groups component into your Application.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The `Incoming Call` is comprised of the following base components:
| Components | Description |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| cometchat-list-item | This component’s view consists of avatar, status indicator , title, and subtitle. The fields are then mapped with the SDK’s user, group class. |
| cometchat-button | This component represents a button with optional icon and text. |
| cometchat-avatar | This component component displays an image or user's avatar with fallback to the first two letters of the username. |
## Usage
### Integration
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
## Usage
### Integration
The following code snippet illustrates how you can directly incorporate the MessageComposer component into your app.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
The `MessageHeader` is comprised of the following components:
| Component | Description |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| CometChatListItem | This component’s view consists of avatar, status indicator , title, and subtitle. The fields are then mapped with the SDK’s user, group class. |
| Back Button | BackButton that allows users to navigate back from the current activity or screen to the previous one. |
## Usage
### Integration
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
***
## Usage
### Integration
The following code snippet illustrates how you can directly incorporate the MessageList component into your Application.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The Message Bubble structure can typically be broken down into the following views:
1. **Leading view**: This is where the sender's avatar is displayed. It's typically on the left of the Message Bubble for messages from others and on the right for messages from the current user.
2. **Header view**: This displays the sender's name and is especially useful in group chats where multiple users are sending messages.
3. **Reply view**: This view can be used to extend the Message Bubble with additional elements. It's typically placed above the Content view.
4. **Content view**: This is the core of the Message Bubble where the message content (text, images, videos, etc.) is displayed.
5. **Bottom view**: This view can be used to extend the Message Bubble with additional elements, such as link previews or a 'load more' button for long messages. It's typically placed beneath the Content view.
6. **Thread view**: This is where the thread reply icon and reply counts are displayed. It's located below the footer view.
7. **Footer view**: This is where the reactions are displayed. It's located at the bottom of the Message Bubble.
8. **Status Info view**: This is where the timestamp of the message and its delivery or read status are displayed. It's located inside the Message Bubble just below the content view.
***
### Properties
MessageTemplate provides you with methods that allow you to alter various properties of the Message Bubble. These properties include aspects such as the `type` and `category` of a message, the appearance and behavior of the header, content, and footer sections of the message bubble,
1. **type**
Using `type` you can set the type of CometChatMessage, This will map your MessageTemplate to the corresponding CometChatMessage. You can set the MessageTemplates Type using the following code snippet.
2. **category**
Using `category` you can set the category of a MessageTemplate. This will create a MessageTemplate with the specified category and link it with a CometChatMessage of the same category.
Please refer to our guide on [Message Categories](/sdk/javascript/message-structure-and-hierarchy) for a deeper understanding of message categories.
3. **headerView**
The `headerView` method allows you to assign a custom header view to the Message Bubble. By default, it is configured to display the sender's name.
4. **contentView**
The `contentView` method allows you to assign a custom content view to the Message Bubble. By default, it displays the Text Bubble, Image Bubble, File Bubble, Audio Bubble, or Video Bubble depending on the message type.
5. **footerView**
The `footerView` method allows you to assign a custom Footer view to the Message Bubble. By default it shows thr reactions for the message bubble.
6. **bottomView**
The `bottomView` method allows you to assign a custom Bottom view to the Message Bubble. By defuault is has buttons such as link previews or a 'load more' button for long messages.
7. **bubbleView**
The `bubbleView` method allows you to assign a custom Bubble view to the Message Bubble. By default, headerView, contentView, statusInfoView and footerView together form a message bubble.
8. **statusInfoView**
The `statusInfoView` method allows you to assign a custom status info view to the Message Bubble. By default, it displays the receipt and timestamp.
9. **options**
The `options` lets you set the list of actions that a user can perform on a message. This includes actions like reacting to, editing, or deleting a message.
***
## Customization
Let's dive into how you can use the [properties](#properties) of MessageTemplate to customize an existing template or add a new one to the [MessageList](/ui-kit/react/message-list) component.
The first step is to fetch the list of existing templates when you want to modify or add to them. This can be done using the getAllMessageTemplates() method from the DataSource of the CometChatUIKit class.
```javascript
let definedTemplates = CometChatUIKit.getDataSource().getAllMessageTemplates();
```
### Existing Templates
You will need to first get the MessageTemplate object for the type of message you want to customize. You will be customizing the text message bubble here. The code snippet to get the Text MessageTemplate is as follows.
This layout is structured into three key sections:
1. **Sidebar (Conversation List)** – Displays active conversations, including users and groups.
2. **Message View** – Shows chat messages for the selected conversation in real-time.
3. **Message Composer** – Provides an input field for typing and sending messages, along with support for media, emojis, and reactions.
***
## **Step-by-Step Guide**
### **Step 1: Create Sidebar**
Let's create the `Sidebar` component which will render different conversations.
#### **Folder Structure**
Create a `CometChatSelector` folder inside your `src/app` directory and add the following files:
```swift
src/app/
│── CometChatSelector/
│ ├── CometChatSelector.tsx
│ ├── CometChatSelector.css
```
#### **Download the Icon**
These icons are available in the **CometChat UI Kit assets folder**. You can find them at:\
🔗 [GitHub Assets Folder](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app/src/assets)
*/}
***
## **Prerequisites**
Before installing the **CometChat UI Kit for React**, you must first **create a CometChat application** via the **[CometChat Dashboard](https://app.cometchat.com/)**. The dashboard provides all the essential chat service components, including:
* **User Management**
* **Group Chat & Messaging**
* **Voice & Video Calling**
* **Real-time Notifications**
> To initialize the **UI Kit**, you will need the following credentials from your **CometChat application**:
>
> 1. **App ID**
> 2. **Auth Key**
> 3. **Region**
>
> Ensure you have these details ready before proceeding with the installation and configuration.
***
## **Register & Set Up CometChat**
Follow these steps to **register on CometChat** and **set up your development environment**.
### **Step 1: Register on CometChat**
To use **CometChat UI Kit**, you first need to register on the **CometChat Dashboard**.
🔗 **[Click here to Sign Up](https://app.cometchat.com/login)**
### **Step 2: Get Your Application Keys**
After registering, create a **new app** and retrieve your **authentication details**:
1. Navigate to **Application**, then select the **Credentials** section.
2. Note down the following keys:
* **App ID**
* **Auth Key**
* **Region**
**Recommended for:**
* Desktop-first applications
* Apps requiring a **rich user experience** with seamless navigation
* Platforms supporting both **individual and group messaging**
* **Mobile-friendly** apps needing a **tap-to-open message view**
[
**Recommended for:**
* **Support chat applications** – Direct user-agent communication.
* **Apps focusing on direct messaging** – No distractions from other conversations.
* **Community or group chat applications** – A structured way to interact in groups.
* **Mobile-first applications** – Designed for compact and dedicated messaging experiences.
[
**Recommended for:**
* **Apps requiring structured navigation** – Clearly separate chat, calls, and settings.
* **Multi-feature chat apps** – Supporting different functionalities in an organized way.
* **Mobile-first applications** – Ideal for apps needing tab-based UI for easy access to features.
* **Support & enterprise chat solutions** – Perfect for help desks, business chat platforms, and customer support apps.
[
### **Key Components**
1. **Chat Header** – Displays recipient details and optional call/video call buttons.
2. **Message View** – Shows real-time chat history.
3. **Message Input Box** – Enables users to send messages, media, and reactions.
***
## **Step-by-Step Guide**
### **Step 1: Implement the Chat Header**
* Display **profile picture, name, and online status**.
* Add **voice and video call buttons** (optional).
```html
This layout consists of:
1. **Sidebar (Conversation List)** – Displays recent conversations with active users and groups.
2. **Message View** – Shows the selected chat with real-time messages.
3. **Message Input Box** – Allows users to send messages seamlessly.
***
## **Step-by-Step Guide**
### **Step 1: Create a Tab Component**
To manage navigation, let's build a **`CometChatTabs`** component. This component will render different tabs and allow switching between sections dynamically.
#### **Folder Structure**
Create a `CometChatTabs` folder inside your `src` directory and add the following files:
```php
public/
├── assets # These are the images you need to save
│ ├── chats.svg
│ ├── calls.svg
│ ├── users.svg
│ ├── groups.svg
src/
│── CometChatTabs/
│ ├── CometChatTabs.tsx
│ ├── CometChatTabs.css
```
#### **Download the Icons**
These icons are available in the **CometChat UI Kit assets folder**. You can find them at:\
🔗 [GitHub Assets Folder](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app/src/assets)
***
#### **Implementation**
The `Outgoing Call` is comprised of the following components:
| Components | Description |
| ---------------- | ------------------------------------------------------------------------------------------------------------------- |
| CometChat Button | This component represents a button with optional icon and text. |
| CometChat Avatar | This component component displays an image or user's avatar with fallback to the first two letters of the username. |
## Usage
### Integration
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
***
## **Try Live Demo**
**Experience the CometChat UI Kit in action:**
This layout is structured into three key sections:
1. **Sidebar (Conversation List)** – Displays active conversations, including users and groups.
2. **Message View** – Shows chat messages for the selected conversation in real-time.
3. **Message Composer** – Provides an input field for typing and sending messages, along with support for media, emojis, and reactions.
***
## **Step-by-Step Guide**
### **Step 1: Create Sidebar**
Let's create the `Sidebar` component which will render different conversations.
#### **Folder Structure**
Create a `CometChatSelector` folder inside your `src` directory and add the following files:
```
src/
│── CometChatSelector/
│ ├── CometChatSelector.tsx
│ ├── CometChatSelector.css
```
*/}
***
## **Prerequisites**
Before installing the **CometChat UI Kit for React**, you must first **create a CometChat application** via the **[CometChat Dashboard](https://app.cometchat.com/)**. The dashboard provides all the essential chat service components, including:
* **User Management**
* **Group Chat & Messaging**
* **Voice & Video Calling**
* **Real-time Notifications**
> To initialize the **UI Kit**, you will need the following credentials from your **CometChat application**:
>
> 1. **App ID**
> 2. **Auth Key**
> 3. **Region**
>
> Ensure you have these details ready before proceeding with the installation and configuration.
***
## **Register & Set Up CometChat**
Follow these steps to **register on CometChat** and **set up your development environment**.
### **Step 1: Register on CometChat**
To use **CometChat UI Kit**, you first need to register on the **CometChat Dashboard**.
🔗 **[Click here to Sign Up](https://app.cometchat.com/login)**
### **Step 2: Get Your Application Keys**
After registering, create a **new app** and retrieve your **authentication details**:
1. Navigate to **Application**, then select the **Credentials** section.
2. Note down the following keys:
* **App ID**
* **Auth Key**
* **Region**
**Recommended for:**
* Desktop-first applications
* Apps requiring a **rich user experience** with seamless navigation
* Platforms supporting both **individual and group messaging**
* **Mobile-friendly** apps needing a **tap-to-open message view**
[
**Recommended for:**
* **Support chat applications** – Direct user-agent communication.
* **Apps focusing on direct messaging** – No distractions from other conversations.
* **Community or group chat applications** – A structured way to interact in groups.
* **Mobile-first applications** – Designed for compact and dedicated messaging experiences.
[
**Recommended for:**
* **Apps requiring structured navigation** – Clearly separate chat, calls, and settings.
* **Multi-feature chat apps** – Supporting different functionalities in an organized way.
* **Mobile-first applications** – Ideal for apps needing tab-based UI for easy access to features.
* **Support & enterprise chat solutions** – Perfect for help desks, business chat platforms, and customer support apps.
[
***
***
## **Prerequisites**
Before installing the **CometChat UI Kit for React**, you must first **create a CometChat application** via the **[CometChat Dashboard](https://app.cometchat.com/)**. The dashboard provides all the essential chat service components, including:
* **User Management**
* **Group Chat & Messaging**
* **Voice & Video Calling**
* **Real-time Notifications**
> To initialize the **UI Kit**, you will need the following credentials from your **CometChat application**:
>
> 1. **App ID**
> 2. **Auth Key**
> 3. **Region**
>
> Ensure you have these details ready before proceeding with the installation and configuration.
***
## **Register & Set Up CometChat**
Follow these steps to **register on CometChat** and **set up your development environment**.
### **Step 1: Register on CometChat**
To use **CometChat UI Kit**, you first need to register on the **CometChat Dashboard**.
🔗 **[Click here to Sign Up](https://app.cometchat.com/login)**
### **Step 2: Get Your Application Keys**
After registering, create a **new app** and retrieve your **authentication details**:
1. Navigate to **Application**, then select the **Credentials** section.
2. Note down the following keys:
* **App ID**
* **Auth Key**
* **Region**
**Recommended for:**
* Desktop-first applications
* Apps requiring a **rich user experience** with seamless navigation
* Platforms supporting both **individual and group messaging**
* **Mobile-friendly** apps needing a **tap-to-open message view**
[Integrate Conversation List + Message](./react-router-conversation)
***
#### **2️⃣ One-to-One/Group Chat**
**Best for:** Apps that require a **focused, direct messaging experience** without a sidebar.
**Features:**
* **Dedicated chat window** – Ideal for one-on-one or group messaging.
* **No conversation list** – Users directly enter the chat without navigating through a list.
* **Supports both One-to-One and Group Chats** – Easily configurable with minor code modifications.
* **Optimized for mobile** – Full-screen chat experience without distractions.
* **Seamless real-time communication** – Auto-updates messages for a smooth experience.
* **Ideal for support chat or community-based messaging.**
**Recommended for:**
* **Support chat applications** – Direct user-agent communication.
* **Apps focusing on direct messaging** – No distractions from other conversations.
* **Community or group chat applications** – A structured way to interact in groups.
* **Mobile-first applications** – Designed for compact and dedicated messaging experiences.
[Integrate One-to-One/Group Chat](./react-router-one-to-one-chat)
***
#### **3️⃣ Tab-Based Chat Experience**
**Best for:** Apps that need a **structured, multi-feature navigation system** for seamless interaction between **chats, calls, users, and settings**.
**Features:**
* **Tab Navigation** – Easily switch between **Chat, Call Logs, Users, and Settings**.
* **Dedicated Chat Window** – Full-screen messaging experience for focused communication.
* **No Sidebar** – Unlike multi-panel UI, this design prioritizes individual interactions.
* **Unified Experience** – Users can seamlessly manage conversations, call history, and settings from a single interface.
* **Scalable for future features** – Easily extend to include more functionalities such as notifications or contact management.
* **Optimized for both desktop and mobile** – Ensures a smooth experience across different screen sizes.
**Recommended for:**
* **Apps requiring structured navigation** – Clearly separate chat, calls, and settings.
* **Multi-feature chat apps** – Supporting different functionalities in an organized way.
* **Mobile-first applications** – Ideal for apps needing tab-based UI for easy access to features.
* **Support & enterprise chat solutions** – Perfect for help desks, business chat platforms, and customer support apps.
[Integrate Tab-Based Chat](./react-router-tab-based-chat)
***
## **Build Your Own Chat Experience**
**Best for:** Developers who need complete control over their chat interface, allowing customization of components, themes, and features to align with their app’s design and functionality. Whether you're enhancing an existing chat experience or building from scratch, this approach provides the flexibility to tailor every aspect to your needs.
**Recommended for:**
* Apps that require **a fully customized chat experience**.
* Developers who want to **extend functionalities and modify UI components**.
* Businesses integrating chat seamlessly into **existing platforms**.
**Key Areas to Explore:**
* **[React Sample App](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app)** – Fully functional sample applications to accelerate your development.
* **[Core Features](./core-features)** – Learn about messaging, real-time updates, and other essential capabilities.
* **[Components](./components-overview)** – Utilize prebuilt UI elements or customize them to fit your design.
* **[Themes](./theme)** – Adjust colors, fonts, and styles to match your branding.
* **[Build Your Own UI](./../../../sdk/javascript/overview)** – Prefer a custom UI over our UI Kits? Explore our SDKs to create a tailored chat experience.
***
## **Next Steps**
Now that you’ve selected your **chat experience**, proceed to the **integration guide**:
* **[Integrate Conversation List + Message](/ui-kit/react/react-router-conversation)**
* **[Integrate One-to-One Chat](/ui-kit/react/react-router-one-to-one-chat)**
* **[Integrate Tab-Based Chat](/ui-kit/react/react-router-tab-based-chat)**
* **[Advanced Customizations](/ui-kit/react/theme)**
***
# Building A One To One/Group Chat Experience
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/ui-kit/react/react-router-one-to-one-chat
The **One-to-One Chat** feature provides a streamlined **direct messaging interface**, making it ideal for **support chats, dating apps, and private messaging platforms**. This setup eliminates distractions by focusing solely on a **dedicated chat window**.
***
## **User Interface Preview**
### **Key Components**
1. **Chat Header** – Displays recipient details and optional call/video call buttons.
2. **Message View** – Shows real-time chat history.
3. **Message Input Box** – Enables users to send messages, media, and reactions.
***
## **Step-by-Step Guide**
### **Step 1: Implement the Chat Header**
* Display **profile picture, name, and online status**.
* Add **voice and video call buttons** (optional).
```html
This layout consists of:
1. **Sidebar (Conversation List)** – Displays recent conversations with active users and groups.
2. **Message View** – Shows the selected chat with real-time messages.
3. **Message Input Box** – Allows users to send messages seamlessly.
***
## **Step-by-Step Guide**
### **Step 1: Create a Tab Component**
To manage navigation, let's build a **`CometChatTabs`** component. This component will render different tabs and allow switching between sections dynamically.
#### **Folder Structure**
Create a `CometChatTabs` folder inside your `src` directory and add the following files:
```php
public/
├── assets # These are the images you need to save
│ ├── chats.svg
│ ├── calls.svg
│ ├── users.svg
│ ├── groups.svg
src/app/
│── CometChatTabs/
│ ├── CometChatTabs.tsx
│ ├── CometChatTabs.css
```
#### **Download the Icons**
These icons are available in the **CometChat UI Kit assets folder**. You can find them at:\
🔗 [GitHub Assets Folder](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app/src/assets)
***
#### **Implementation**
This layout consists of:
1. **Sidebar (Conversation List)** – Displays recent conversations with active users and groups.
2. **Message View** – Shows the selected chat with real-time messages.
3. **Message Input Box** – Allows users to send messages seamlessly.
***
## **Step-by-Step Guide**
### **Step 1: Create a Tab Component**
To manage navigation, let's build a **`CometChatTabs`** component. This component will render different tabs and allow switching between sections dynamically.
#### **Folder Structure**
Create a `CometChatTabs` folder inside your `src` directory and add the following files:
```python
src/
│── CometChatTabs/
│ ├── assets # These are the images you need to save
│ │ ├── chats.svg
│ │ ├── calls.svg
│ │ ├── users.svg
│ │ ├── groups.svg
│ ├── CometChatTabs.tsx
│ ├── CometChatTabs.css
```
#### **Download the Icons**
These icons are available in the **CometChat UI Kit assets folder**. You can find them at:\
🔗 [GitHub Assets Folder](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app/src/assets)
***
#### **Implementation**
The customized message search interface is displayed below.
Use the following code to achieve the customization shown above.
The customized message leading view interface is displayed below.
Use the following code to achieve the customization shown above.
The customized message title view interface is displayed below.
Use the following code to achieve the customization shown above.
The customized message subtitle view interface is displayed below.
Use the following code to achieve the customization shown above.
The customized message trailing view interface is displayed below.
Use the following code to achieve the customization shown above.
## Usage
Here are the steps to create a `ShortCutFormatter` for CometChat using the CometChatTextFormatter:
1. Firstly, you need to import `CometChatTextFormatter` from the CometChat UI Kit react library.
```javascript
import { CometChatTextFormatter } from "@cometchat/chat-uikit-react";
```
2. Now, extend the `CometChatTextFormatter` class to create your custom text formatter class. In this case, let's create a `HashTagTextFormatter`.
```java
class ShortCutFormatter extends CometChatTextFormatter {
...
}
```
3. Set up the `trackCharacter` and define any necessary private fields.
```javascript
this.setTrackingCharacter("!");
```
4. Implement the `onKeyDown` method to handle key events and trigger actions based on defined shortcuts.
```javascript
onKeyDown(event: KeyboardEvent) {
// Your implementation
}
```
5. Implement any additional methods required for your custom formatter, such as opening and closing dialogs, handling button clicks, and formatting text.
```typescript
openDialog(buttonText: string) {
// Your implementation
}
closeDialog() {
// Your implementation
}
handleButtonClick = () => {
// Your implementation
};
getFormattedText(text: string): string {
return text;
}
private getTextBeforeCaret(caretPosition: number): string {
// Your implementation
}
```
## Example
Below is an example demonstrating how to use a custom formatter class in components such as [CometChatConversations](/ui-kit/react/conversations), [CometChatMessageList](/ui-kit/react/message-list), [CometChatMessageComposer](/ui-kit/react/message-composer).
```python
--cometchat-primary-color: #6852d6;
--cometchat-extended-primary-color-50: #f9f8fd;
--cometchat-extended-primary-color-100: #edeafa;
--cometchat-extended-primary-color-200: #dcd7f6;
--cometchat-extended-primary-color-300: #ccc4f1;
--cometchat-extended-primary-color-400: #bbb1ed;
--cometchat-extended-primary-color-500: #aa9ee8;
--cometchat-extended-primary-color-600: #9a8be4;
--cometchat-extended-primary-color-700: #8978df;
--cometchat-extended-primary-color-800: #7965db;
--cometchat-extended-primary-color-900: #5d49be;
```
***
#### **Dark Mode**
```python
--cometchat-primary-color: #6852d6;
--cometchat-extended-primary-color-50: #15102b;
--cometchat-extended-primary-color-100: #1d173c;
--cometchat-extended-primary-color-200: #251e4d;
--cometchat-extended-primary-color-300: #2e245e;
--cometchat-extended-primary-color-400: #362b6f;
--cometchat-extended-primary-color-500: #3e3180;
--cometchat-extended-primary-color-600: #473892;
--cometchat-extended-primary-color-700: #4f3ea3;
--cometchat-extended-primary-color-800: #5745b4;
--cometchat-extended-primary-color-900: #7460d9;
```
### **Extended Primary Colors**
#### **Light Mode**
#### **Dark Mode**
# Message Bubble Styling
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/ui-kit/react/theme/message-bubble-styling
## Introduction
We offer customizable message bubble styling to enhance user experience and match your app’s design. With distinct classes for incoming and outgoing messages, you can easily define colors, borders, and other styles. Each message type, from text to multimedia, has predefined classes for default styling, and developers can further customize using CSS.
## Incoming & Outgoing Messages
Incoming and outgoing messages have different styling by default, allowing users to visually separate their own messages from others’. Here, we show both the default view and examples of customizations for these message bubbles.
Shown below is the default chat interface.
***
### Styling
#### Outgoing Message Bubbles
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css app.css
.cometchat .cometchat-message-bubble-outgoing .cometchat-message-bubble__body {
--cometchat-primary-color: #f76808;
--cometchat-extended-primary-color-900: #fbaa75;
}
```
***
#### Incoming Message Bubbles
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css app.css
.cometchat .cometchat-message-bubble-incoming .cometchat-message-bubble__body {
--cometchat-neutral-color-300: #f76808;
}
```
***
#### All Message Bubbles
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css app.css
.cometchat .cometchat-message-bubble .cometchat-message-bubble__body {
--cometchat-neutral-color-300: #f76808;
--cometchat-primary-color: #f76808;
--cometchat-extended-primary-color-900: #fbaa75;
}
```
***
## Message Types
CometChat UI Kit includes classes for various message types. Below are examples of default & customised views for each message type, along with the relevant CSS code snippets so that you can quickly up to the mark with CSS customization.
***
### Text Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Text Message Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__text-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Text Message Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__text-message {
--cometchat-neutral-color-300: #feede1;
}
```
***
### Image Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Image Message Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__image-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Image Message Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__image-message {
--cometchat-neutral-color-300: #feede1;
}
```
***
### Video Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Video Message Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__video-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Video Message Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__video-message {
--cometchat-neutral-color-300: #feede1;
}
```
***
### Audio Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Audio Message Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__audio-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Audio Message Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__audio-message {
--cometchat-primary-color: #f76808;
--cometchat-neutral-color-300: #feede1;
}
```
***
### File Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing File Message Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__file-message {
--cometchat-primary-color: #f76808;
}
/* Incoming File Message Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__file-message {
--cometchat-primary-color: #f76808;
--cometchat-neutral-color-300: #feede1;
}
```
***
### Delete Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Delete Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__delete-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Delete Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__delete-message {
--cometchat-neutral-color-300: #feede1;
}
```
***
### Action Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
.cometchat .cometchat-message-bubble__body .cometchat-action-bubble {
--cometchat-primary-color: #f76808;
background-color: #feede1;
--cometchat-text-color-secondary: #f76808;
--cometchat-icon-color-secondary: #f76808;
--cometchat-border-color-default: #f76808;
}
```
***
### Direct Call Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Direct Call Message Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__meeting-message {
--cometchat-primary-color: #f76808;
--cometchat-extended-primary-color-800: #fbaa75;
}
/* Incoming Direct Call Message Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__meeting-message {
--cometchat-primary-color: #f76808;
--cometchat-neutral-color-300: #feede1;
}
```
***
### Default Call Message Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
.cometchat .cometchat-message-bubble__body .cometchat-action-bubble {
--cometchat-primary-color: #f76808;
background-color: #feede1;
--cometchat-text-color-secondary: #f76808;
--cometchat-icon-color-secondary: #f76808;
--cometchat-border-color-default: #f76808;
}
```
***
### Extensions
#### Collaborative Whiteboard Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Collaborative Whiteboard Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__whiteboard-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Collaborative Whiteboard Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__whiteboard-message {
--cometchat-primary-color: #f76808;
--cometchat-primary-button-background: #f76808;
--cometchat-neutral-color-300: #feede1;
}
```
***
#### Collaborative Document Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Collaborative Document Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__document-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Collaborative Document Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__document-message {
--cometchat-primary-color: #f76808;
--cometchat-primary-button-background: #f76808;
--cometchat-neutral-color-300: #feede1;
}
```
***
#### Polls Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Poll Message Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__poll-message {
--cometchat-primary-color: #f76808;
--cometchat-extended-primary-color-700: #fbaa75;
}
/* Incoming Poll Message Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__poll-message {
--cometchat-primary-color: #f76808;
--cometchat-neutral-color-300: #feede1;
}
```
***
#### Stickers Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Sticker Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__sticker-message {
--cometchat-primary-color: #f76808;
}
/* Incoming Sticker Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__sticker-message {
--cometchat-neutral-color-300: #feede1;
}
```
***
#### Link Preview Bubble
Shown below is the default chat interface.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
```css App.css
/* Outgoing Link Preview Bubble */
.cometchat
.cometchat-message-bubble-outgoing
.cometchat-message-bubble__body.cometchat-message-bubble__text-message {
--cometchat-primary-color: #f76808;
--cometchat-extended-primary-color-900: #fbaa75;
}
/* Incoming Link Preview Bubble */
.cometchat
.cometchat-message-bubble-incoming
.cometchat-message-bubble__body.cometchat-message-bubble__text-message {
--cometchat-neutral-color-400: #fbaa75;
--cometchat-neutral-color-300: #feede1;
}
```
***
# Thread Header
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/ui-kit/react/thread-header
## Overview
CometChatThreadHeader is a Component that displays the parent message & number of replies of thread.
## Usage
### Integration
The following code snippet illustrates how you can directly incorporate the CometChatThreadHeader component into your Application.
## Usage
`CometChatUrlsFormatter` utilizes regular expressions to identify URLs and applies styles to make them visually distinct as clickable links. Here's an example of how to extend the `CometChatTextFormatter` to create a URL text formatter:
The Users component is composed of the following BaseComponents:
| Components | Description |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------ |
| CometChatList | A reusable container component having title, search box, customisable background and a list view. |
| CometChatListItem | A component that renders data obtained from a User object on a Tile having a title, subtitle, leading and trailing view. |
***
## Usage
### Integration
The following code snippet illustrates how you can directly incorporate the Users component into your Application.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
Use the following code to achieve the customization shown above.
The customized chat interface is displayed below.
Use the following code to achieve the customization shown above.
## Tile mode
1. **custom-tile-main-video-container** This is the main video container. It is the div that has the main speaker video, for tile mode.
As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
1. Message
2. Custom
3. Action
4. Call
Each category can be further be classified into types.
A message belonging to the category `message` can be classified into either 1 of the below types:
1. text - A plain text message
2. image- An image message
3. video- A video message
4. audio- An audio message
5. file- A file message
## Custom
In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
## Action
Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types:
1. groupMember - action performed on a group member.
2. message - action performed on a message.
Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below:
1. joined - when a group member joins a group
2. left - when a group member leaves a group
3. kicked - when a group member is kicked from the group
4. banned - when a group member is banned from the group
5. unbanned - when a group member is unbanned from the group
6. added - when a user is added to the group
7. scopeChanged - When the scope of a group member is changed.
For the type `message`, the action can be either one of the below:
1. edited - when a message is edited.
2. deleted - when a message is deleted.
## Call
Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types
1. audio
2. video
The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values:
1. initiated - when a is initiated to a user/group
2. ongoing - when the receiver of the call has accepted the call
3. canceled - when the call has been canceled by the initiator of the call
4. rejected - when the call has been rejected by the receiver of the call
5. unanswered - when the call was not answered by the receiver.
6. busy - when the receiver of the call was busy on another call.
7. ended - when the call was successfully completed and ended by either the initiator or receiver.
# Messaging
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/javascript/3.0/messaging
Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history.
At the minimum, you must add code for [sending messages](/sdk/javascript/3.0/messaging-send-message) and [receiving messages](/sdk/javascript/3.0/messaging-receive-message).
Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/javascript/3.0/messaging-typing-indicators) and [delivery & read receipts](/sdk/javascript/3.0/messaging-receipts).
# Additional Message Filtering
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/javascript/3.0/messaging-additional-message-filtering
The `MessagesRequest` class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the `MessagesRequest` class.
The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class.
The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched.
Steps to generate an object of the MessagesRequest class:
1. Create an object of the `MessagesRequestBuilder` class.
2. Set all the parameters you wish to set.
3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class.
Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object.
1. fetchNext() - Calling this method will return the messages after the specified parameters.
2. fetchPrevious() - Calling this method will give you messages before the specified parameters.
Since messages are obtained in a paginated manner, a maximum of 100 messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages.
Now that you are clear how to use the `MessagesRequest` class, below are the various options available:
## Number of messages fetched
*In other words, how do I set the number of messages fetched in a single iteration*
To achieve this, you can use the `setLimit()` method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is 100.
Loading....
) } ```Loading....
) } ```
**Mode: `TILE`**
**Mode: `SPOTLIGHT`**
### Guidelines for Customizing the Grid Layout
* **CSS Classes:**
* Please ensure that you only apply CSS classes specified in this documentation. Introducing CSS classes not covered here may cause unexpected UI issues.
* **Grid Container Resizing:**
* Avoid resizing the grid container. Altering the grid container’s dimensions can negatively impact the grid layout, leading to undesirable visual distortions.
By following these recommendations, you can maintain a stable and visually consistent grid layout.
# Default Call
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/javascript/default-call
This section will provide information on how a complete calling workflow can be set up using CometChat. We've built the complete workflow to help your users make calls, receive calls as well as accept/reject calls.
Let us assume Alex to be the call initiator and Bob is the receiver.
1. Alex initiates the call to Bob using the [initiateCall()](#initiate-call) method.
2. Bob now has two choices:
* Accept the call from Alex using the [acceptCall()](#accept-the-incoming-call) method.
* Reject the call from Alex using the [rejectCall()](#reject-the-incoming-call) method passing the status as `rejected`.
5. In the meantime, Alex has the option to cancel the call he initiated to Bob using the [rejectCall()](#cancel-the-outgoing-call) method passing the status as `cancelled`.
6. If Bob accepts the call from Alex, both Alex and Bob need to call the [startSession()](/sdk/javascript/direct-call#start-call-session) method. Alex in the **onOutgoingCallAccepted()** method of the `CallListener` and Bob in the success obtained from the **acceptCall()** method and both will be connected to each other.
## Initiate Call
The `initiateCall()` method sends a call request to a user or a group.
The user who ended the call
# Resources
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/javascript/resources-overview
We have a number of resources that will help you while integrating CometChat in your app.
You can begin with the [all real-time listeners](/sdk/javascript/all-real-time-listeners) guide.
If you're upgrading from v2, we recommend reading our [Upgrading from v3](/sdk/javascript/upgrading-from-v3) guide.
# Retrieve Conversations
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/javascript/retrieve-conversations
Conversations provide the last messages for every one-on-one and group conversation the logged-in user is a part of. This makes it easy for you to build a **Recent Chat** list.
## Retrieve List of Conversations
*In other words, as a logged-in user, how do I retrieve the latest conversations that I've been a part of?*
To fetch the list of conversations, you can use the `ConversationsRequest` class. To use this class i.e. to create an object of the `ConversationsRequest` class, you need to use the `ConversationsRequestBuilder` class. The `ConversationsRequestBuilder` class allows you to set the parameters based on which the conversations are to be fetched.
The `ConversationsRequestBuilder` class allows you to set the below parameters:
### Set Limit
This method sets the limit i.e. the number of conversations that should be fetched in a single iteration.
## Tile mode
1. **custom-tile-main-video-container** This is the main video container. It is the div that has the main speaker video, for tile mode.
As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
1. Message
2. Custom
3. Action
4. Call
Each category can be further be classified into types.
A message belonging to the category `message` can be classified into either 1 of the below types:
1. text - A plain text message
2. image- An image message
3. video- A video message
4. audio- An audio message
5. file- A file message
## Custom
In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
## Action
Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types:
1. groupMember - action performed on a group member.
2. message - action performed on a message.
Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below:
1. joined - when a group member joins a group
2. left - when a group member leaves a group
3. kicked - when a group member is kicked from the group
4. banned - when a group member is banned from the group
5. unbanned - when a group member is unbanned from the group
6. added - when a user is added to the group
7. scopeChanged - When the scope of a group member is changed.
For the type `message`, the action can be either one of the below:
1. edited - when a message is edited.
2. deleted - when a message is deleted.
## Call
Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types
1. audio
2. video
The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values:
1. initiated - when a is initiated to a user/group
2. ongoing - when the receiver of the call has accepted the call
3. canceled - when the call has been canceled by the initiator of the call
4. rejected - when the call has been rejected by the receiver of the call
5. unanswered - when the call was not answered by the receiver.
6. busy - when the receiver of the call was busy on another call.
7. ended - when the call was successfully completed and ended by either the initiator or receiver.
# Messaging
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/javascript/2.0/messaging
Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history.
At the minimum, you must add code for [sending messages](/sdk/javascript/2.0/messaging-send-message) and [receiving messages](/sdk/javascript/2.0/messaging-receive-message).
Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/javascript/2.0/messaging-typing-indicators) and [delivery & read receipts](/sdk/javascript/2.0/messaging-receipts).
# Additional Message Filtering
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/javascript/2.0/messaging-additional-message-filtering
The `MessagesRequest` class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the `MessagesRequest` class.
The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class.
The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched.
Steps to generate an object of the MessagesRequest class:
1. Create an object of the `MessagesRequestBuilder` class.
2. Set all the parameters you wish to set.
3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class.
Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object.
1. fetchNext() - Calling this method will return the messages after the specified parameters.
2. fetchPrevious() - Calling this method will give you messages before the specified parameters.
Since messages are obtained in a paginated manner, a maximum of 100 messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages.
Now that you are clear how to use the `MessagesRequest` class, below are the various options available:
## Number of messages fetched
*In other words, how do I set the number of messages fetched in a single iteration*
To achieve this, you can use the `setLimit()` method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is 100.
Upgrading from v1.x to v2 is fairly simple. Below are the major changes that are released as a part of CometChat Pro v2:
## Initialization
The `CometChat.init()` method now takes an additional parameter. This parameter is an object of the `AppSettings` class. This object can be created by using the `AppSettingsBuilder` class. The `AppSettings` class provides the CometChat SDK with the below 2 details:
1. **Region of your app**: The region of your app is the code of the region your app is hosted in. Currently, this can only hold one of the below two values: a. **eu** - If your app is hosted in Europe b. **us** - If your app is hosted in the United States of America.
2. [Presence Subscribtion](/sdk/javascript/2.0/user-presence)
The user who ended the call
As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
1. Message
2. Custom
3. Action
4. Call
5. Interactive
Each category can be further be classified into types.
\#Message A message belonging to the category `message` can be classified into either 1 of the below types:
1. text - A plain text message
2. image- An image message
3. video- A video message
4. audio- An audio message
5. file- A file message
## Custom
In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
## Interactive
An InteractiveMessage is a specialized object that encapsulates an interactive unit within a chat message, such as an embedded form that users can fill out directly within the chat interface. This enhances user engagement by making the chat experience more interactive and responsive to user input.
form- for interactive form card- for interactive card customInteractive- for custom interaction messages
# Retrieve Conversations
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/retrieve-conversations
Conversations provide the last messages for every one-on-one and group conversation the logged-in user is a part of. This makes it easy for you to build a **Recent Chat** list.
## Retrieve List of Conversations
*In other words, as a logged-in user, how do I retrieve the latest conversations that I've been a part of?*
To fetch the list of conversations, you can use the `ConversationsRequest` class. To use this class i.e. to create an object of the `ConversationsRequest` class, you need to use the `ConversationsRequestBuilder` class. The `ConversationsRequestBuilder` class allows you to set the parameters based on which the conversations are to be fetched.
The `ConversationsRequestBuilder` class allows you to set the below parameters:
### Set Limit
This method sets the limit i.e. the number of conversations that should be fetched in a single iteration.
As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
1. Message
2. Custom
3. Action
4. Call
Each category can be further be classified into types.
## Message
A message belonging to the category `message` can be classified into either 1 of the below types:
1. text - A plain text message
2. image- An image message
3. video- A video message
4. audio- An audio message
5. file- A file message
## Custom
In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
## Action
Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types:
1. groupMember - action performed on a group member.
2. message - action performed on a message.
Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below:
1. joined - when a group member joins a group
2. left - when a group member leaves a group
3. kicked - when a group member is kicked from the group
4. banned - when a group member is banned from the group
5. unbanned - when a group member is unbanned from the group
6. added - when a user is added to the group
7. scopeChanged - When the scope of a group member is changed.
For the type `message`, the action can be either one of the below:
1. edited - when a message is edited.
2. deleted - when a message is deleted.
## Call
Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types
1. audio
2. video
The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values:
1. initiated - when a is initiated to a user/group
2. ongoing - when the receiver of the call has accepted the call
3. canceled - when the call has been canceled by the initiator of the call
4. rejected - when the call has been rejected by the receiver of the call
5. unanswered - when the call was not answered by the receiver.
6. busy - when the receiver of the call was busy on another call.
7. ended - when the call was successfully completed and ended by either the initiator or receiver.
# Messaging
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/2.0/messaging
Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history.
At the minimum, you must add code for [sending messages](/sdk/react-native/2.0/messaging-send-message) and [receiving messages](/sdk/react-native/2.0/messaging-receive-messages).
Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/react-native/2.0/messaging-typing-indicators) and [delivery & read receipts](/sdk/react-native/2.0/messaging-receipts).
# Receive Messages
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/2.0/messaging-receive-messages
Receiving messages with CometChat has two parts:
1. Adding a listener to receive [real-time messages](/sdk/react-native/2.0/messaging-receive-messages#real-time-messages) when your app is running
2. Calling a method to retrieve [missed messages](/sdk/react-native/2.0/messaging-receive-messages#missed-messages) when your app was not running
## Real-Time Messages
*In other words, as a recipient, how do I receive messages when my app is running?*
To receive real-time incoming messages, you need to register the MessageListener wherever you wish to receive the incoming messages. You can use the addMessageListener() method to do so.
# Calling V3
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/3.0/calling-v3
Calling is a core feature of CometChat. Calling allows users to connect over voice/video calls.
## Prerequisites
1. CometChat Core SDK installed.
2. Performed the steps mentioned in the [Setup](/sdk/react-native/3.0/setup#calling-component-configuration) guide.
CometChat allows two mechanisms for calling:
1. **Direct Calling**
2. **Default Calling**
## Direct Calling
Direct Calling allows you to start the call/conference sessions directly with the session Id of your choice. All the users joining the same session Id are connected to the same call/conference. For more information on Direct Calling, please visit the [Direct Calling](/sdk/react-native/3.0/calling-direct-calling).
## Default Calling
The second approach that CometChat SDK allows is to implement the entire calling flow where one user initiates a call/conference. The other user/users who want to be a part of the call accept the call. All the users that accept the call are connected to the same session. The users also have an option to reject the call. For more information on Default Calling, please visit the [Default Calling](/sdk/react-native/3.0/calling-default-calling).
As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories
1. Message
2. Custom
3. Action
4. Call
Each category can be further be classified into types.
\#Message A message belonging to the category `message` can be classified into either 1 of the below types:
1. text - A plain text message
2. image- An image message
3. video- A video message
4. audio- An audio message
5. file- A file message
## Custom
In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`.
## Action
Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types:
1. groupMember - action performed on a group member.
2. message - action performed on a message.
Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below:
1. joined - when a group member joins a group
2. left - when a group member leaves a group
3. kicked - when a group member is kicked from the group
4. banned - when a group member is banned from the group
5. unbanned - when a group member is unbanned from the group
6. added - when a user is added to the group
7. scopeChanged - When the scope of a group member is changed.
For the type `message`, the action can be either one of the below:
1. edited - when a message is edited.
2. deleted - when a message is deleted.
## Call
Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types
1. audio
2. video
The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values:
1. initiated - when a is initiated to a user/group
2. ongoing - when the receiver of the call has accepted the call
3. canceled - when the call has been canceled by the initiator of the call
4. rejected - when the call has been rejected by the receiver of the call
5. unanswered - when the call was not answered by the receiver.
6. busy - when the receiver of the call was busy on another call.
7. ended - when the call was successfully completed and ended by either the initiator or receiver.
# Messaging
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/3.0/messaging
Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history.
At the minimum, you must add code for [sending messages](/sdk/react-native/3.0/messaging-send-message) and [receiving messages](/sdk/react-native/3.0/messaging-receive-messages).
Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/react-native/3.0/messaging-typing-indicators) and [delivery & read receipts](/sdk/react-native/3.0/messaging-receipts).
# Additional Message Filtering
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/3.0/messaging-additional-message-filtering
The `MessagesRequest` class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the `MessagesRequest` class.
The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class.
The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched.
Steps to generate an object of the MessagesRequest class:
1. Create an object of the `MessagesRequestBuilder` class.
2. Set all the parameters you wish to set.
3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class.
Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object.
1. fetchNext() - Calling this method will return the messages after the specified parameters.
2. fetchPrevious() - Calling this method will give you messages before the specified parameters.
Since messages are obtained in a paginated manner, a maximum of 100 messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages.
Now that you are clear how to use the `MessagesRequest` class, below are the various options available:
## Number of messages fetched
*In other words, how do I set the number of messages fetched in a single iteration*
To achieve this, you can use the `setLimit()` method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is 100.
# Resources
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/3.0/resources
We have a number of resources that will help you while integrating CometChat in your app.
You can begin with the [all real-time listeners](/sdk/react-native/3.0/resources-all-real-time-listeners) guide.
If you're upgrading from v2, we recommend reading our [upgrading from v2](/sdk/react-native/3.0/resources-upgrading-from-v2) guide.
# All Real Time Listeners
Source: https://cometchat-22654f5b-docs-restapi-chatapi-quotedmessages.mintlify.app/sdk/react-native/3.0/resources-all-real-time-listeners
CometChat provides 4 listeners viz.
1. [User Listener](/sdk/react-native/3.0/resources-all-real-time-listeners#user-listener)
2. [Group Listener](/sdk/react-native/3.0/resources-all-real-time-listeners#group-listener)
3. [Message Listener](/sdk/react-native/3.0/resources-all-real-time-listeners#message-listener)
4. [Call Listener](/sdk/react-native/3.0/resources-all-real-time-listeners#call-listener)
## User Listener
The `UserListener` class provides you with live events related to users. Below are the callback methods provided by the `UserListener` class.
| Method | Information |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **onUserOnline(User user)** | This method is triggered when a user comes online and is available to chat. The details of the user can be obtained from the user object received as the method parameter. |
| **onUserOffline(User user)** | This method is triggered when a user goes offline. The details of the user can be obtained from the User object received as the parameter. |
To add the `UserListener`, you need to use the `addUserListener()` method provided by the `CometChat` class.
Select the downloaded GoogleService-Info.plist file from your computer, and ensure the "Copy items if needed" checkbox is enabled.
**Configure Firebase in iOS:**
To allow Firebase on iOS to use the credentials, the Firebase iOS SDK must be configured during the bootstrap phase of your application.
To do this, open your /ios/\{projectName}/AppDelegate.m file, and add the following:
At the top of the file, import the Firebase SDK:
Lastly, Open your projects /ios/Podfile and add any of the globals shown below to the top of the file:
| App State | Behaviour |
| ----------------- | --------------------------------------- |
| App in foreground | Connected with WebSocket |
| App in background | Immediately disconnected with WebSocket |
| 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. |
## Managing Manually
The CometChat SDK also allows you to modify the above default behaviour of the SDK and take the control of the web-socket connection into your own hands. In order to achieve this, you need to follow the below steps:
## Enable Manual Mode
While calling the init() function on the app startup, you need to inform the SDK that you will be managing the web socket connect. You can do so by using the `autoEstablishSocketConnection()` method provided by the `AppSettingsBuilder` class. This method takes a boolean value as an input. If set to true , the SDK will manage the web-socket connection internally based on the default behaviour mentioned above. If set to false , the web socket connection can will not be managed by the SDK and you will have to handle it manually. You can refer to the below code snippet for the same:
Select the downloaded GoogleService-Info.plist file from your computer, and ensure the "Copy items if needed" checkbox is enabled.
**Configure Firebase in iOS:**
To allow Firebase on iOS to use the credentials, the Firebase iOS SDK must be configured during the bootstrap phase of your application.
To do this, open your /ios/\{projectName}/AppDelegate.m file, and add the following:
At the top of the file, import the Firebase SDK:
Lastly, Open your projects /ios/Podfile and add any of the globals shown below to the top of the file: