AI Integration Quick Reference
AI Integration Quick Reference
Overview
This section explains how to implement a complete calling workflow with ringing functionality, including incoming/outgoing call UI, call acceptance, rejection, and cancellation. Previously known as Default Calling.After the call is accepted, you need to start the call session. See the Call Session guide for details on starting and managing the actual call.
- Caller initiates a call using
initiateCall() - Receiver gets notified via
onIncomingCallReceived()callback - Receiver can either:
- Accept the call using
acceptCall() - Reject the call using
rejectCall()with statusCALL_STATUS_REJECTED
- Accept the call using
- Caller can cancel the call using
rejectCall()with statusCALL_STATUS_CANCELLED - Once accepted, both participants call
startSession()to join the call
Initiate Call
TheinitiateCall() method sends a call request to a user or a group. On success, the receiver gets an onIncomingCallReceived() callback.
- User Call (TypeScript)
- User Call (JavaScript)
- Group Call (TypeScript)
- Group Call (JavaScript)
On success, a
Call object is returned containing the call details including a unique sessionId required for starting the call session.
By default, an unanswered call automatically cancels after 45 seconds. You can customize this duration by passing an optional timeout parameter (in seconds) as the second argument to initiateCall().
- User Call (TypeScript)
- User Call (JavaScript)
- Group Call (TypeScript)
- Group Call (JavaScript)
Call Listeners
Register theCallListener to receive real-time call events. Each listener requires a unique listenerId string to prevent duplicate registrations and enable targeted removal.
- TypeScript
- JavaScript
Events
All call listener callbacks receive a
Call object.
Accept Call
When an incoming call is received viaonIncomingCallReceived(), use acceptCall() to accept it. On success, start the call session.
- TypeScript
- JavaScript
Reject Call
UserejectCall() to reject an incoming call. Set the status to CALL_STATUS_REJECTED.
- TypeScript
- JavaScript
Cancel Call
The caller can cancel an outgoing call before it’s answered usingrejectCall() with status CALL_STATUS_CANCELLED.
- TypeScript
- JavaScript
Start Call Session
Once the call is accepted, both participants need to start the call session. Caller flow: In theonOutgoingCallAccepted() callback, generate a token and start the session.
Receiver flow: In the acceptCall() success callback, generate a token and start the session.
- TypeScript
- JavaScript
End Call
To end an active call in the ringing flow, the process differs based on who ends the call. User who ends the call: When the user clicks the end call button, theonCallEndButtonPressed() callback is triggered. Inside this callback, call CometChat.endCall() to notify other participants. On success, call CometChat.clearActiveCall() and CometChatCalls.endSession() to release resources.
- TypeScript
- JavaScript
onCallEnded() callback):
- TypeScript
- JavaScript
Busy Call Handling
If the receiver is already on another call, you can reject the incoming call withCALL_STATUS_BUSY status.
- TypeScript
- JavaScript
Next Steps
Call Session
Manage call sessions, tokens, and settings
Call Logs
Retrieve and display call history
Recording
Record audio and video calls
Calling Setup
Install and initialize the Calls SDK