### Clone and Install Dependencies Source: https://www.cometchat.com/docs/ai-agents/mastra-knowlege-agent-pdf Clone the example repository and install Node.js dependencies. ```bash git clone https://github.com/cometchat/ai-agent-mastra-examples.git cd ai-agent-mastra-examples/mastra-knowledge-agent-pdf npm install ``` -------------------------------- ### Run Development Server (Create React App) Source: https://www.cometchat.com/docs/ui-kit/react/react-conversation Command to start the development server for a Create React App project. Ensure you have installed dependencies with `npm install`. ```bash npm start ``` -------------------------------- ### Complete Integration Example Source: https://www.cometchat.com/docs/ui-kit/ios/compact-message-composer A comprehensive example demonstrating the setup and integration of the CometChatCompactMessageComposer within a UIKit view controller. ```APIDOC ## Complete Integration Example ### Description This example shows how to initialize, configure, and lay out the `CometChatCompactMessageComposer` within a `UIViewController`. ### Setup 1. Initialize `CometChatCompactMessageComposer`. 2. Set the user and controller. 3. Customize placeholder and typing events. 4. Define send button and error callbacks. 5. Add the composer to the view hierarchy and set constraints. ``` -------------------------------- ### Project Setup with npm Source: https://www.cometchat.com/docs/ai-agents/cometchat-ag-ui-express Installs necessary dependencies for an Express.js AG-UI agent project. Ensure Node.js (v16+) and npm/pnpm are installed. ```bash # Create project directory mkdir my-ag-ui-agent cd my-ag-ui-agent # Initialize package.json npm init -y # Install dependencies npm install express @ag-ui/core openai uuid cors dotenv npm install -D typescript @types/node @types/express ts-node nodemon ``` -------------------------------- ### Minimal CometChatMessageList Initialization Source: https://www.cometchat.com/docs/ui-kit/ios/message-list Demonstrates the basic initialization and setup of CometChatMessageList for a user. This provides a minimal working example. ```swift import CometChatUIKitSwift import CometChatSDK let messageList = CometChatMessageList() messageList.set(user: user) ``` -------------------------------- ### Complete Example: Generate and Join Session (Swift) Source: https://www.cometchat.com/docs/calls/ios/join-session Demonstrates the complete flow of generating a call token and then immediately using it to join a session. Includes error handling for both steps. ```swift let sessionId = "SESSION_ID" // Step 1: Generate token CometChatCalls.generateToken(sessionID: sessionId, onSuccess: { [weak self] token in guard let self = self, let token = token else { return } // Step 2: Join with token let sessionSettings = CometChatCalls.sessionSettingsBuilder .setDisplayName("John Doe") .setType(.video) .build() CometChatCalls.joinSession( callToken: token, callSetting: sessionSettings, container: self.callViewContainer, onSuccess: { message in print("Joined session successfully") }, onError: { error in print("Failed to join: \(error?.errorDescription ?? "")") } ) }, onError: { error in print("Token generation failed: \(error?.errorDescription ?? "")") }) ``` -------------------------------- ### Initiate Chat Integration in IDE Source: https://www.cometchat.com/docs/ui-kit/android/overview After installing the CometChat Skills CLI, use this command within your IDE to start the chat integration process. The skill will detect your project structure and guide you through setup. ```bash /cometchat add chat to my app ``` -------------------------------- ### Complete Example: Generate and Join Session (Objective-C) Source: https://www.cometchat.com/docs/calls/ios/join-session Demonstrates the complete flow of generating a call token and then immediately using it to join a session. Includes error handling for both steps. ```objectivec NSString *sessionId = @"SESSION_ID"; // Step 1: Generate token [CometChatCalls generateTokenWithSessionID:sessionId onSuccess:^(NSString * token) { // Step 2: Join with token SessionSettings *sessionSettings = [[[[CometChatCalls sessionSettingsBuilder] setDisplayName:@"John Doe"] setType:CallTypeVideo] build]; ``` -------------------------------- ### Custom Empty State with Call to Action Source: https://www.cometchat.com/docs/ui-kit/react-native/conversations Implement a custom view for when there are no conversations. This allows for displaying a message and a button to guide the user, for example, to start a new conversation. ```tsx import { CometChatConversations } from "@cometchat/chat-uikit-react-native"; import { View, Text, TouchableOpacity } from "react-native"; function EmptyStateConversations() { return ( ( No conversations yet console.log("Start conversation")}> Start a conversation )} /> ); } ``` -------------------------------- ### Build and Start Production Mode Source: https://www.cometchat.com/docs/ai-agents/cometchat-ag-ui-express Use this command to build the project for production and start the server. ```bash npm run build && npm start ``` -------------------------------- ### Get Unread Message Count for a Group (Callback Listener) Source: https://www.cometchat.com/docs/sdk/flutter/receive-messages An example of using a callback listener to get the unread message count for a specific group, handling success and error scenarios. The success callback provides a map of group GUIDs to their unread counts. ```dart private String GUID = "cometchat-guid-1" CometChat.getUnreadMessageCountForGroup(guid: GUID,hideMessagesFromBlockedUsers: hideBlockedUser, onSuccess: (Map map) { }, onError: (CometChatException e) { }); ``` -------------------------------- ### Get Group Response (JSON) Source: https://www.cometchat.com/docs/rest-api/groups/get This is an example of a successful JSON response when retrieving group details. It contains information such as the group's GUID, name, description, and member count. ```json { "data": { "guid": "project-group", "name": "Project Group", "description": "project related discussions between members", "icon": "https://assets.cometchat.io/sampleapp/v2/groups/cometchat-guid-1.webp", "type": "public", "scope": "admin", "membersCount": 1, "joinedAt": 1638440784, "conversationId": "group_project-group", "hasJoined": true, "createdAt": 1638440784, "owner": "cometchat-uid-4", "tags": [ "friends", "project" ] } } ``` -------------------------------- ### Complete Call Activity Example Source: https://www.cometchat.com/docs/calls/android/custom-participant-list This comprehensive example demonstrates setting up a call activity, including initializing the call session, setting up the UI for the participant list and search, handling participant events, and joining a call session. It requires `CallSession`, `ParticipantAdapter`, and `CometChatCalls` to be properly implemented. ```java protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_call); callSession = CallSession.getInstance(); setupUI(); setupParticipantListener(); joinCall(); } private void setupUI() { // Setup RecyclerView RecyclerView recyclerView = findViewById(R.id.participantRecyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); participantAdapter = new ParticipantAdapter(new ParticipantAdapter.OnActionListener() { @Override public void onMuteClick(Participant participant) { callSession.muteParticipant(participant.getUid()); } @Override public void onPauseVideoClick(Participant participant) { callSession.pauseParticipantVideo(participant.getUid()); } @Override public void onPinClick(Participant participant) { if (participant.isPinned()) { callSession.unPinParticipant(); } else { callSession.pinParticipant(participant.getUid()); } } }); recyclerView.setAdapter(participantAdapter); // Setup search EditText searchInput = findViewById(R.id.searchInput); searchInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { participantAdapter.filter(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} }); // Setup buttons findViewById(R.id.toggleParticipantListButton).setOnClickListener(v -> toggleParticipantPanel()); findViewById(R.id.closeButton).setOnClickListener(v -> toggleParticipantPanel()); } private void setupParticipantListener() { callSession.addParticipantEventListener(this, new ParticipantEventListener() { @Override public void onParticipantListChanged(List participants) { runOnUiThread(() -> { participantAdapter.updateParticipants(participants); TextView countView = findViewById(R.id.participantCount); countView.setText("Participants (" + participants.size() + ")"); }); } @Override public void onParticipantJoined(Participant participant) { Toast.makeText(CallActivity.this, participant.getName() + " joined", Toast.LENGTH_SHORT).show(); } @Override public void onParticipantLeft(Participant participant) { Toast.makeText(CallActivity.this, participant.getName() + " left", Toast.LENGTH_SHORT).show(); } }); } private void joinCall() { SessionSettings sessionSettings = new CometChatCalls.SessionSettingsBuilder() .hideParticipantListButton(true) .setTitle("Team Meeting") .build(); FrameLayout callContainer = findViewById(R.id.callContainer); CometChatCalls.joinSession( "SESSION_ID", sessionSettings, callContainer, this, new CometChatCalls.CallbackListener() { @Override public void onSuccess(Void unused) { Log.d(TAG, "Joined call successfully"); } @Override public void onError(CometChatException e) { Log.e(TAG, "Failed to join: " + e.getMessage()); Toast.makeText(CallActivity.this, "Failed to join call", Toast.LENGTH_SHORT).show(); } } ); } private void toggleParticipantPanel() { LinearLayout panel = findViewById(R.id.participantPanel); isParticipantPanelVisible = !isParticipantPanelVisible; panel.setVisibility(isParticipantPanelVisible ? View.VISIBLE : View.GONE); } ``` -------------------------------- ### Get Virgil Token and Identity in Swift Source: https://www.cometchat.com/docs/fundamentals/end-to-end-encryption This Swift code example shows how to obtain the Virgil token and identity for E3Kit setup. It uses completion handlers for managing the asynchronous operation's success or failure. ```swift CometChat.callExtension(slug: "e2ee", type: .get, endPoint: "/v1/virgil-jwt", body: nil, onSuccess: { (response) in // virgilToken, identity }) { (error) in // Some error occured } } ``` -------------------------------- ### Navigate to Sample App Directory Source: https://www.cometchat.com/docs/ui-kit/react/link/sample Navigate to the sample-app directory within the cloned repository. ```bash cd cometchat-uikit-react/sample-app ``` -------------------------------- ### Complete Example: Generate and Join Session (Kotlin) Source: https://www.cometchat.com/docs/calls/android/join-session Demonstrates the complete flow of generating a call token and then immediately joining a session using that token in Kotlin. ```kotlin val sessionId = "SESSION_ID" val callViewContainer = findViewById(R.id.call_view_container) // Step 1: Generate token CometChatCalls.generateToken(sessionId, object : CometChatCalls.CallbackListener() { override fun onSuccess(token: GenerateToken) { // Step 2: Join with token val sessionSettings = CometChatCalls.SessionSettingsBuilder() .setDisplayName("John Doe") .setType(SessionType.VIDEO) .build() CometChatCalls.joinSession(token, sessionSettings, callViewContainer, object : CometChatCalls.CallbackListener() { override fun onSuccess(callSession: CallSession) { Log.d(TAG, "Joined session successfully") } override fun onError(e: CometChatException) { Log.e(TAG, "Failed to join: ${e.message}") } } ) } override fun onError(e: CometChatException) { Log.e(TAG, "Token generation failed: ${e.message}") } }) ``` -------------------------------- ### Migration Example: Get Conversation Source: https://www.cometchat.com/docs/rest-api/conversations/get-conversation This example demonstrates how to migrate from the deprecated GET /conversations/{conversationId} endpoint to the new type-specific endpoints for fetching user or group conversations. ```bash GET /conversations/{conversationId} GET /users/{uid}/conversation GET /groups/{guid}/conversation ``` -------------------------------- ### Complete Session Settings Example Source: https://www.cometchat.com/docs/calls/javascript/session-settings An example demonstrating how to configure various session settings, including UI visibility and timeouts. ```APIDOC ## Complete Example ```javascript const callSettings = { // Session configuration sessionType: "VIDEO", layout: "TILE", startAudioMuted: false, startVideoPaused: false, autoStartRecording: false, // Timeout settings idleTimeoutPeriodBeforePrompt: 60000, idleTimeoutPeriodAfterPrompt: 120000, // UI visibility hideControlPanel: false, hideLeaveSessionButton: false, hideToggleAudioButton: false, hideToggleVideoButton: false, hideRecordingButton: true, hideScreenSharingButton: false, hideChangeLayoutButton: false, hideVirtualBackgroundButton: false, hideNetworkIndicator: false, }; ``` ``` -------------------------------- ### Install React Navigation Dependencies for Expo Source: https://www.cometchat.com/docs/ui-kit/react-native/expo-tab-based-chat Install the required React Navigation packages to enable tab-based navigation in your Expo project. Ensure these dependencies are installed before proceeding with the UI setup. ```bash npx expo install @react-navigation/native @react-navigation/bottom-tabs @react-navigation/native-stack react-native-screens ``` -------------------------------- ### Clone and Run Sample App Source: https://www.cometchat.com/docs/ui-kit/flutter/link/sample Clone the repository, navigate to the sample app directory, get dependencies, and run the app. Enter your CometChat credentials on first launch. ```bash git clone https://github.com/cometchat/cometchat-uikit-flutter.git cd cometchat-uikit-flutter/examples/sample_app flutter pub get flutter run ``` -------------------------------- ### Run Development Server (Create React App) Source: https://www.cometchat.com/docs/chat-builder/react/integration Start your application using the 'npm start' command for Create React App projects. ```bash npm start ``` -------------------------------- ### Complete Example Source: https://www.cometchat.com/docs/calls/flutter/join-session A comprehensive example demonstrating the process of generating a call token and then using it to join a session. ```APIDOC ## Complete Example: Join Session with Token ### Description This example illustrates the complete workflow of generating a call token and subsequently using it to join a CometChat call session. ### Code ```dart String sessionId = "SESSION_ID"; // Step 1: Generate token CometChatCalls.generateToken( sessionId: sessionId, onSuccess: (CallToken token) { // Step 2: Join with token final sessionSettings = (SessionSettingsBuilder() ..setDisplayName("John Doe") ..setType(SessionType.video)) .build(); CometChatCalls.joinSession( callToken: token, sessionSettings: sessionSettings, onSuccess: (Widget? callWidget) { debugPrint("Joined session successfully"); // Place callWidget in your widget tree to render the call UI }, onError: (CometChatCallsException e) { debugPrint("Failed to join: ${e.message}"); }, ); }, onError: (CometChatCallsException e) { debugPrint("Token generation failed: ${e.message}"); }, ); ``` ``` -------------------------------- ### Get Group Source: https://www.cometchat.com/docs/llms.txt Retrieves details of a group for a given GUID. ```APIDOC ## Get Group ### Description Retrieves details of a specific group. ### Method GET ### Endpoint /v2/groups/{group_guid} ``` -------------------------------- ### Complete Example with Idle Timeout Configuration and Event Handling Source: https://www.cometchat.com/docs/calls/react-native/idle-timeout A comprehensive example demonstrating how to initialize a call, configure idle timeout settings, and set up event listeners for session timeouts and call endings. ```APIDOC ## Complete Example ```tsx import React, { useEffect, useCallback } from 'react'; import { Alert } from 'react-native'; import { CometChatCalls } from '@cometchat/calls-sdk-react-native'; interface CallScreenProps { sessionId: string; onCallEnd: () => void; } function CallScreen({ sessionId, onCallEnd }: CallScreenProps) { const handleSessionTimeout = useCallback(() => { Alert.alert( 'Session Ended', 'The call has ended due to inactivity.', [ { text: 'OK', onPress: onCallEnd, }, ] ); }, [onCallEnd]); useEffect(() => { const unsubscribe = CometChatCalls.addEventListener( 'onSessionTimedOut', handleSessionTimeout ); return () => unsubscribe(); }, [handleSessionTimeout]); useEffect(() => { async function initializeCall() { try { const { token } = await CometChatCalls.generateToken(sessionId); const listener = new CometChatCalls.OngoingCallListener({ onSessionTimeout: handleSessionTimeout, onCallEnded: onCallEnd, }); const settings = new CometChatCalls.CallSettingsBuilder() .setIdleTimeoutPeriod(180) // 3 minutes .setCallEventListener(listener) .build(); // Render call component with token and settings } catch (error) { console.error('Failed to initialize call:', error); } } initializeCall(); }, [sessionId, handleSessionTimeout, onCallEnd]); // ... render call UI return null; } export default CallScreen; ``` ``` -------------------------------- ### Integration Example Source: https://www.cometchat.com/docs/ui-kit/react-native/ai-assistant-chat-history This example demonstrates how to integrate the CometChatAIAssistantChatHistory component into a React Native application. It shows the basic setup with required props and event handlers. ```APIDOC ## Integration Example ### Description Integrate the `CometChatAIAssistantChatHistory` component into your React Native application to display AI chat history. Ensure the user object has the `@agentic` role. ### Code ```typescript import React from 'react'; import { View } from 'react-native'; import { CometChatAIAssistantChatHistory } from '@cometchat/chat-uikit-react-native'; import { CometChat } from '@cometchat/chat-sdk-react-native'; const YourComponent = () => { const user = new CometChat.User({ uid: "userId", name: "User Name", role: "@agentic" // User role must be @agentic to use AI Assistant features }); return ( { // Handle close action }} onMessageClicked={(message) => { // Handle message click }} onNewChatButtonClick={() => { // Handle new chat button click }} onError={(error) => { // Handle error }} /> ); }; export default YourComponent; ``` ``` -------------------------------- ### Programmatic Setup in Fragment (Java) Source: https://www.cometchat.com/docs/ui-kit/android/outgoing-call Demonstrates how to instantiate and configure the CometChatOutgoingCall component programmatically within a Fragment using Java. ```APIDOC ## Programmatic Setup in Fragment (Java) ```java CometChatOutgoingCall cometchatOutgoingCall; @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { cometchatOutgoingCall = new CometChatOutgoingCall(requireContext()); cometchatOutgoingCall.setCall(call); // Required — set the Call object return cometchatOutgoingCall; } ``` ``` -------------------------------- ### Setup CallKeep Options Source: https://www.cometchat.com/docs/notifications/push-notifications-extension-legacy Configure CallKeep with platform-specific options for iOS and Android, including foreground service settings for Android. This setup should be done at the start of your application. ```javascript const options = { ios: { appName: 'My app name', }, android: { alertTitle: 'Permissions required', alertDescription: 'This application needs to access your phone accounts', cancelButton: 'Cancel', okButton: 'ok', imageName: 'phone_account_icon', foregroundService: { channelId: 'com.company.my', channelName: 'Foreground service for my app', notificationTitle: 'My app is running on background', notificationIcon: 'Path to the resource icon of the notification', }, }, }; RNCallKeep.setup(options); RNCallKeep.setAvailable(true); let callKeep = new CallKeepHelper(); ``` -------------------------------- ### Complete Custom Control Panel Example Source: https://www.cometchat.com/docs/calls/javascript/custom-control-panel An HTML and JavaScript example demonstrating a fully custom control panel with buttons for audio, video, screen sharing, and leaving the session, along with event listeners to update UI states. ```html
``` -------------------------------- ### Get Contact Details OpenAPI Specification Source: https://www.cometchat.com/docs/rest-api/notifications-apis/push/get-contact-details This OpenAPI specification defines the GET /notifications/v1/contact-details endpoint. It includes details on parameters, responses, and an example of the expected JSON output. ```yaml openapi: 3.0.0 info: title: Chat APIs description: Manage messages, users, groups for a particular app using our Chat API. version: '3.0' servers: - url: https://{appId}.api-{region}.cometchat.io/v3 variables: appId: default: appId description: (Required) App ID region: enum: - us - eu - in default: us description: Select Region security: [] tags: - name: API Keys description: The API keys are used to authorise the APIs - name: Roles description: The roles are used to give user access rights - name: Users description: The REST collection for users. - name: Auth Tokens description: The auth tokens are used to login end users using client SDKs. - name: Blocked Users description: The REST collections for blocked users. - name: Friends description: List,add and remove friends by passing UID in path variables - name: Groups description: The REST collections for groups. - name: Banned Users description: Ban and Unban user by passing other UID in path variables. - name: Group Members description: The REST collections for group members. - name: Messages description: The REST collections for messages. - name: Conversations description: The REST collections for conversations. - name: Restrict Features description: Allows Restricting Features - name: Metrics description: Allows accessing Data Metrics - name: Triggers description: Allows adding triggers to a webhook. - name: Webhooks description: Allows accessing Webhooks. - name: Notifications description: Allows configuring Notifications core. paths: /notifications/v1/contact-details: get: tags: - Notifications summary: Get contact details description: >- Fetches the contact details like Email ID and Phone number for a given user. operationId: notifications-get-contact-details parameters: - $ref: '#/components/parameters/requiredonBehalfOf' responses: '200': description: A list of push notification's settings content: application/json: schema: properties: data: type: object meta: type: object type: object example: data: email: someone@example.com phno: '+919591128691' security: - apiKey: [] components: parameters: requiredonBehalfOf: name: onBehalfOf in: header description: UID of the user on whose behalf the action is performed. required: true schema: type: string securitySchemes: apiKey: type: apiKey description: API Key with fullAccess scope(i.e. Rest API Key from the Dashboard). name: apikey in: header ``` -------------------------------- ### Install UI Kit Elements and SDK Source: https://www.cometchat.com/docs/ui-kit/vue/integration Install the necessary UI Kit elements, resources, and shared modules along with the JavaScript chat SDK. This is an alternative installation method. ```bash npm install @cometchat/uikit-elements @cometchat/uikit-resources @cometchat/uikit-shared @cometchat/chat-sdk-javascript ``` -------------------------------- ### Open a chat or start a call Source: https://www.cometchat.com/docs/widget/webflow/integration Use these helpers to initiate a chat with a specific user or group, or to start a call. Replace `UID` and `GUID` with actual IDs from your CometChat application. ```APIDOC ## Open a chat or start a call Use these helpers when you want the widget to jump straight to a person/group or begin a call. Drop the snippet inside your custom script and replace `UID`/`GUID` with real IDs from your CometChat app. ```js // Open chat with a specific person CometChatApp.chatWithUser("UID"); // Open chat with a specific group CometChatApp.chatWithGroup("GUID"); // Start a call with a person or a group CometChatApp.callUser("UID"); CometChatApp.callGroup("GUID"); // Toggle extra UI bits CometChatApp.showGroupActionMessages(true); // Show join/leave messages CometChatApp.showDockedUnreadCount(true); // Show unread badge on docked bubble ``` ``` -------------------------------- ### Complete Session Join Example Source: https://www.cometchat.com/docs/calls/javascript/join-session A full example demonstrating the two-step process of generating a token and then joining the session with configured settings. Ensure all participants use the same session ID. ```javascript const sessionId = "SESSION_ID"; const container = document.getElementById("call-container"); // Step 1: Generate token try { const tokenResult = await CometChatCalls.generateToken(sessionId); // Step 2: Configure session settings const callSettings = { sessionType: "VIDEO", layout: "TILE", startAudioMuted: false, startVideoPaused: false, }; // Step 3: Join session const joinResult = await CometChatCalls.joinSession( tokenResult.token, callSettings, container ); if (joinResult.error) { console.error("Failed to join session:", joinResult.error); } else { console.log("Joined session successfully"); } } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Programmatic Setup in Activity (Java) Source: https://www.cometchat.com/docs/ui-kit/android/outgoing-call Shows how to instantiate and configure the CometChatOutgoingCall component programmatically in an Activity using Java. ```APIDOC ## Programmatic Setup in Activity (Java) ```java CometChatOutgoingCall cometchatOutgoingCall; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); cometchatOutgoingCall = new CometChatOutgoingCall(this); cometchatOutgoingCall.setCall(call); // Required — set the Call object setContentView(cometchatOutgoingCall); } ``` ``` -------------------------------- ### Get Online Group Member Count Source: https://www.cometchat.com/docs/sdk/android/retrieve-groups Use `getOnlineGroupMemberCount()` to get the count of online members for specific groups. Pass a list of group GUIDs and a `CallbackListener` to process the results. ```java List guids = new ArrayList<>(); guids.add("cometchat-guid-1"); guids.add("cometchat-guid-11"); CometChat.getOnlineGroupMemberCount(guids, new CometChat.CallbackListener>() { @Override public void onSuccess(HashMap stringIntegerHashMap) { Log.d(TAG, "Online count fetched successfully " + stringIntegerHashMap.toString()); } @Override public void onError(CometChatException e) { Log.d(TAG, e.getMessage()); } }); ``` ```kotlin val guids: MutableList = ArrayList() guids.add("cometchat-guid-1") guids.add("cometchat-guid-11") CometChat.getOnlineGroupMemberCount(guids, object : CallbackListener>() { override fun onSuccess(stringIntegerHashMap: HashMap) { Log.d(TAG, "Online count fetched successfully $stringIntegerHashMap") } override fun onError(e: CometChatException) { Log.d(TAG, e.message!!) } }) ``` -------------------------------- ### Get Online Group Member Count - JavaScript Source: https://www.cometchat.com/docs/sdk/javascript/retrieve-groups Use `getOnlineGroupMemberCount()` to get the number of online members in specified groups. It returns an object with GUIDs as keys and online member counts as values. ```javascript let guids = ["cometchat-guid-1"]; CometChat.getOnlineGroupMemberCount(guids).then( groupMemberCount => { console.log("Total online user for specified groups:", groupMemberCount); }, error => { console.log("Online group member count fetching failed with error:", error); }); ``` -------------------------------- ### Install Dependencies Source: https://www.cometchat.com/docs/ai-agents/mastra-orchestrator-agent Run this command to install project dependencies. ```bash npm install ``` -------------------------------- ### Get Online Group Member Count - TypeScript Source: https://www.cometchat.com/docs/sdk/javascript/retrieve-groups Use `getOnlineGroupMemberCount()` to get the number of online members in specified groups. It returns an object with GUIDs as keys and online member counts as values. ```typescript let guids: String[] = ["cometchat-guid-1"]; CometChat.getOnlineGroupMemberCount(guids).then( (groupMemberCount: Object) => { console.log("Total online user for specified groups:", groupMemberCount); }, (error: CometChat.CometChatException) => { console.log("Online group member count fetching failed with error:", error); } ); ``` -------------------------------- ### Complete Example: Generate and Join Session Source: https://www.cometchat.com/docs/calls/flutter/join-session A comprehensive example demonstrating the full flow of generating a call token and then immediately using it to join a session with specified settings. ```dart String sessionId = "SESSION_ID"; // Step 1: Generate token CometChatCalls.generateToken( sessionId: sessionId, onSuccess: (CallToken token) { // Step 2: Join with token final sessionSettings = (SessionSettingsBuilder() ..setDisplayName("John Doe") ..setType(SessionType.video)) .build(); CometChatCalls.joinSession( callToken: token, sessionSettings: sessionSettings, onSuccess: (Widget? callWidget) { debugPrint("Joined session successfully"); // Place callWidget in your widget tree to render the call UI }, onError: (CometChatCallsException e) { debugPrint("Failed to join: ${e.message}"); }, ); }, onError: (CometChatCallsException e) { debugPrint("Token generation failed: ${e.message}"); }, ); ``` -------------------------------- ### Get Online Group Member Count Source: https://www.cometchat.com/docs/sdk/android/retrieve-groups Use `getOnlineGroupMemberCount()` to get the count of online members for specific groups. This method takes a list of group GUIDs and returns a HashMap with the count for each group. ```APIDOC ## Get Online Group Member Count Use `getOnlineGroupMemberCount()` to get the count of online members for specific groups. ### Method `CometChat.getOnlineGroupMemberCount(List guids, CometChat.CallbackListener> listener)` ### Parameters #### Path Parameters - **guids** (List) - Required - A list of GUIDs for the groups to fetch online member counts. ### Response #### Success Response - **HashMap** - A HashMap with the GUID of the group as the key and the online member count for that group as the value. ### Request Example (Java) ```java List guids = new ArrayList<>(); guids.add("cometchat-guid-1"); guids.add("cometchat-guid-11"); CometChat.getOnlineGroupMemberCount(guids, new CometChat.CallbackListener>() { @Override public void onSuccess(HashMap stringIntegerHashMap) { Log.d(TAG, "Online count fetched successfully " + stringIntegerHashMap.toString()); } @Override public void onError(CometChatException e) { Log.d(TAG, e.getMessage()); } }); ``` ### Request Example (Kotlin) ```kotlin val guids: MutableList = ArrayList() guids.add("cometchat-guid-1") guids.add("cometchat-guid-11") CometChat.getOnlineGroupMemberCount(guids, object : CallbackListener>() { override fun onSuccess(stringIntegerHashMap: HashMap) { Log.d(TAG, "Online count fetched successfully $stringIntegerHashMap") } override fun onError(e: CometChatException) { Log.d(TAG, e.message!!) } }) ``` ``` -------------------------------- ### Initialize Project with CocoaPods Source: https://www.cometchat.com/docs/sdk/ios/setup Use this command to initialize a Podfile in your project directory if you don't have one. ```bash $ pod init ``` -------------------------------- ### Get SendGrid Credentials OpenAPI Spec Source: https://www.cometchat.com/docs/rest-api/notifications-apis/email/get-sendgrid-credentials This OpenAPI specification defines the GET endpoint for retrieving SendGrid credentials. It outlines the request path, parameters, and the structure of the successful response, including example credentials. ```yaml openapi: 3.0.0 info: title: Chat APIs description: Manage messages, users, groups for a particular app using our Chat API. version: '3.0' servers: - url: https://{appId}.api-{region}.cometchat.io/v3 variables: appId: default: appId description: (Required) App ID region: enum: - us - eu - in default: us description: Select Region security: [] tags: - name: API Keys description: The API keys are used to authorise the APIs - name: Roles description: The roles are used to give user access rights - name: Users description: The REST collection for users. - name: Auth Tokens description: The auth tokens are used to login end users using client SDKs. - name: Blocked Users description: The REST collections for blocked users. - name: Friends description: List,add and remove friends by passing UID in path variables - name: Groups description: The REST collections for groups. - name: Banned Users description: Ban and Unban user by passing other UID in path variables. - name: Group Members description: The REST collections for group members. - name: Messages description: The REST collections for messages. - name: Conversations description: The REST collections for conversations. - name: Restrict Features description: Allows Restricting Features - name: Metrics description: Allows accessing Data Metrics - name: Triggers description: Allows adding triggers to a webhook. - name: Webhooks description: Allows accessing Webhooks. - name: Notifications description: Allows configuring Notifications core. paths: /notifications/email/v1/providers/sendgrid: get: tags: - Notifications summary: Get SendGrid credentials description: Fetches the SendGrid credentials stored for the app. operationId: notifications-email-list-sendgrid-details responses: '200': description: A list of push notification's settings content: application/json: schema: properties: data: type: array items: type: object meta: type: object type: object example: data: sendGridApiKey: SG.9ipFP4b17yT-Fff2GGrH8FF0GqdkBohXAEI4GnTSj9Q= sendGridTemplateID: d-8284bb9646a040499d5cfa28d272a094 sendGridUnsubscribeGroupID: '33832' senderEmail: noreply@em123.example.com senderName: Emailer security: - apiKey: [] components: securitySchemes: apiKey: type: apiKey description: API Key with fullAccess scope(i.e. Rest API Key from the Dashboard). name: apikey in: header ``` -------------------------------- ### Complete Call Settings Example Source: https://www.cometchat.com/docs/calls/react-native/session-settings A comprehensive example demonstrating how to build call settings with various configurations, including layout, call type, participant controls, and event listeners. ```APIDOC ## Complete Call Settings Example ### Description Build comprehensive call settings with multiple configurations. ### Example ```tsx import { CometChatCalls } from '@cometchat/calls-sdk-react-native'; function createCallSettings(isAudioOnly: boolean = false) { const callListener = new CometChatCalls.OngoingCallListener({ onUserJoined: (user) => { console.log('User joined:', user.name); }, onUserLeft: (user) => { console.log('User left:', user.name); }, onCallEnded: () => { console.log('Call ended'); }, onError: (error) => { console.error('Call error:', error.errorDescription); }, }); return new CometChatCalls.CallSettingsBuilder() .enableDefaultLayout(true) .setIsAudioOnlyCall(isAudioOnly) .setMode(CometChatCalls.CALL_MODE.DEFAULT) .showEndCallButton(true) .showMuteAudioButton(true) .showPauseVideoButton(!isAudioOnly) .showSwitchCameraButton(!isAudioOnly) .showAudioModeButton(true) .startWithAudioMuted(false) .startWithVideoMuted(false) .setDefaultAudioMode(CometChatCalls.AUDIO_MODE.SPEAKER) .showRecordingButton(true) .setIdleTimeoutPeriod(180) .setCallEventListener(callListener) .build(); } // Create video call settings const videoCallSettings = createCallSettings(false); // Create audio call settings const audioCallSettings = createCallSettings(true); ``` ``` -------------------------------- ### Get Rule Revisions OpenAPI Specification Source: https://www.cometchat.com/docs/rest-api/moderation-apis/get-rule-revisions This OpenAPI specification defines the GET /moderation/rules/{ruleId}/revisions endpoint. It outlines the request parameters, response structure, and example payloads for retrieving rule revisions. ```yaml openapi: 3.0.0 info: title: Chat APIs description: Manage messages, users, groups for a particular app using our Chat API. version: '3.0' servers: - url: https://{appId}.api-{region}.cometchat.io/v3 variables: appId: default: appId description: (Required) App ID region: enum: - us - eu - in default: us description: Select Region security: [] tags: - name: API Keys description: The API keys are used to authorise the APIs - name: Roles description: The roles are used to give user access rights - name: Users description: The REST collection for users. - name: Auth Tokens description: The auth tokens are used to login end users using client SDKs. - name: Blocked Users description: The REST collections for blocked users. - name: Friends description: List,add and remove friends by passing UID in path variables - name: Groups description: The REST collections for groups. - name: Banned Users description: Ban and Unban user by passing other UID in path variables. - name: Group Members description: The REST collections for group members. - name: Messages description: The REST collections for messages. - name: Conversations description: The REST collections for conversations. - name: Restrict Features description: Allows Restricting Features - name: Metrics description: Allows accessing Data Metrics - name: Triggers description: Allows adding triggers to a webhook. - name: Webhooks description: Allows accessing Webhooks. - name: Notifications description: Allows configuring Notifications core. paths: /moderation/rules/{ruleId}/revisions: get: tags: - Moderation summary: Get Rule Revisions description: Fetches a rule's revisions. operationId: list-rule-revisions parameters: - $ref: 8efc526a-ccfa-4521-8b5f-bdc33f742abc - $ref: afccec09-e9c7-416b-af47-1d5bf49594d7 - $ref: cb381726-7bf7-43ae-a0e4-fe8d72e0da47 - $ref: d12a8f8e-2630-46ab-bd42-7bf4b8158315 responses: '200': description: List Rule revisions content: application/json: schema: properties: data: properties: '': $ref: '#/components/schemas/webhookSchema' type: object meta: properties: '': $ref: '#/components/schemas/metaSchema' type: object type: object example: data: - id: moderation-test name: Video Moderation description: AI-powered video moderation to detect unsafe content. enabled: true conditions: - id: 1 isKeywordsReferencePresent: false isMediaPresent: false entity: message operand: text category: word operator: equals value: - paris action: - blockMessage active: true createdAt: 1720011899 updatedAt: 1720011905 revisionId: 253179cf5f665257_moderation-test_2 - id: moderation-test name: Video Moderation description: AI-powered video moderation to detect unsafe content. enabled: true conditions: - id: 1 isKeywordsReferencePresent: false isMediaPresent: true entity: message operand: image category: word operator: contains value: - violence_greaterThan_30 message: - >- Image contains violence with confidence greater than 30 action: - blockMessage active: false createdAt: 1720011899 updatedAt: 1720011899 revisionId: 253179cf5f665257_moderation-test_1 meta: current: limit: 10 count: 2 components: schemas: webhookSchema: description: Response data properties: id: type: string name: type: string webhookURL: ``` -------------------------------- ### Programmatic Setup in Fragment (Kotlin) Source: https://www.cometchat.com/docs/ui-kit/android/outgoing-call Demonstrates how to instantiate and configure the CometChatOutgoingCall component programmatically within a Fragment using Kotlin. ```APIDOC ## Programmatic Setup in Fragment (Kotlin) ```kotlin private lateinit var cometchatOutgoingCall: CometChatOutgoingCall override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { cometchatOutgoingCall = CometChatOutgoingCall(requireContext()) cometchatOutgoingCall.setCall(call) // Required — set the Call object return cometchatOutgoingCall } ``` ``` -------------------------------- ### App Initialization Source: https://www.cometchat.com/docs/calls/javascript/ionic-integration Example of how to initialize the CometChat Calls SDK and log in a user when the Ionic application starts. ```APIDOC ## App Initialization ### Description This code snippet demonstrates how to integrate the `CometChatCallsService` into the main `AppComponent` to ensure the SDK is initialized and the user is logged in upon application startup. ### Usage Inject `CometChatCallsService` into your `AppComponent` and call `initAndLogin` within the `ngOnInit` lifecycle hook. Replace `"cometchat-uid-1"` with the actual authenticated user ID from your application's authentication system. ``` -------------------------------- ### Listen for Participant Screen Sharing Events Source: https://www.cometchat.com/docs/calls/react-native/participant-management Get notified when a participant starts or stops sharing their screen. ```tsx CometChatCalls.addEventListener('onParticipantStartedScreenShare', (participant) => { console.log(`${participant.name} started screen sharing`); }); CometChatCalls.addEventListener('onParticipantStoppedScreenShare', (participant) => { console.log(`${participant.name} stopped screen sharing`); }); ``` -------------------------------- ### Start Dev Server Source: https://www.cometchat.com/docs/ai-agents/mastra-orchestrator-agent Use this command to start the development server for the orchestrator agent. ```bash npx mastra dev ``` ```bash npm run dev ``` -------------------------------- ### Navigate to Project Directory Source: https://www.cometchat.com/docs/widget/html-bootstrap-jquery Change into the cloned project directory to access its files and configurations. ```bash cd CometChatWorkspace ```