Implement call recording for voice and video calls using the CometChat JavaScript SDK, including start/stop controls, listeners, and accessing recordings from the Dashboard.
AI Integration Quick Reference
// Start recordingCometChatCalls.startRecording();// Stop recordingCometChatCalls.stopRecording();// Listen for recording events (in CallSettings)const callListener = new CometChatCalls.OngoingCallListener({ onRecordingStarted: (event) => console.log("Recording started", event.user), onRecordingStopped: () => console.log("Recording stopped"),});
Record voice and video calls for playback, compliance, or archival purposes. Recording is built on top of the Call Session — you add recording listeners to your call settings and optionally control recording programmatically.
Add onRecordingStarted and onRecordingStopped callbacks to your OngoingCallListener when building call settings. These fire for all participants when any user starts or stops recording.
TypeScript
JavaScript
TypeScript
// Add listeners onRecordingStarted and onRecordingStopped to the startCall methodconst defaultLayout = true;const audioOnly = false;const callListener = new CometChatCalls.OngoingCallListener({ onRecordingStarted: (event) => console.log("Listener => onRecordingStarted", event.user), onRecordingStopped: (event) => console.log("Listener => onRecordingStopped", event.user),});const callSettings = new CometChatCalls.CallSettingsBuilder() .enableDefaultLayout(defaultLayout) .setIsAudioOnlyCall(audioOnly) .setCallListener(callListener) .build();const htmlElement = document.getElementById("ELEMENT_ID");CometChatCalls.startSession(callToken, callSettings, htmlElement);
// Add listeners onRecordingStarted and onRecordingStopped to the startCall methodconst defaultLayout = true;const audioOnly = false;const callListener = new CometChatCalls.OngoingCallListener({ onRecordingStarted: (event) => console.log("Listener => onRecordingStarted", event.user), onRecordingStopped: () => console.log("Listener => onRecordingStopped"),});const callSettings = new CometChatCalls.CallSettingsBuilder() .enableDefaultLayout(defaultLayout) .setIsAudioOnlyCall(audioOnly) .setCallListener(callListener) .build();const htmlElement = document.getElementById("ELEMENT_ID");CometChatCalls.startSession(callToken, callSettings, htmlElement);
// Add listeners onRecordingStarted and onRecordingStopped to the startCall methodconst defaultLayout = true;const audioOnly = false;const callListener = new CometChatCalls.OngoingCallListener({ onRecordingStarted: (event) => console.log("Listener => onRecordingStarted", event.user), onRecordingStopped: () => console.log("Listener => onRecordingStopped"),});const callSettings = new CometChatCalls.CallSettingsBuilder() .enableDefaultLayout(defaultLayout) .setIsAudioOnlyCall(audioOnly) .setCallListener(callListener) .build();const htmlElement = document.getElementById("ELEMENT_ID");CometChatCalls.startSession(callToken, callSettings, htmlElement);
The onRecordingStarted callback receives an event object — see the OngoingCallListener reference for the full shape.The onRecordingStopped callback receives no arguments.
Always remove listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
If set to true it displays the Recording button in the button Layout. if set to false it hides the Recording button in the button Layout. Default value = false
If set to true call recording will start as soon as the call is started. if set to false call recording will not start as soon as the call is started. Default value = false