Skip to main content
Quick Reference for AI Agents & Developers
// Fetch call logs
const loggedInUser = await CometChat.getLoggedinUser();
const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
  .setLimit(30)
  .setAuthToken(loggedInUser.getAuthToken())
  .setCallCategory("call")  // "call" or "meet"
  .build();
const callLogs = await callLogRequest.fetchNext();

// Filter options
.setCallType("video")  // "video" or "audio"
.setCallStatus("missed")  // "ongoing", "busy", "rejected", "cancelled", "ended", "missed"
.setCallDirection("incoming")  // "incoming" or "outgoing"
.setHasRecording(true)
.setUid("user_uid")
.setGuid("group_guid")

// Get specific call details
const details = await CometChatCalls.getCallDetails(sessionId, authToken);
Available via: SDK | REST API | Dashboard
Access comprehensive call history to display past calls, track communication patterns, and retrieve call recordings.

Overview

Call logs provide detailed information about past calls including:
  • Call duration and timestamps
  • Participants involved
  • Call type (audio/video)
  • Call status (completed, missed, rejected)
  • Recording availability

Fetching Call Logs

Use CallLogRequestBuilder to fetch call logs with various filters:
const loggedInUser = await CometChat.getLoggedinUser();

const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
  .setLimit(30)
  .setAuthToken(loggedInUser.getAuthToken())
  .setCallCategory("call")
  .build();

callLogRequest.fetchNext().then(
  (callLogs) => {
    console.log("Call logs:", callLogs);
  },
  (error) => {
    console.log("Failed to fetch call logs:", error);
  }
);

Builder Options

MethodDescription
setLimit(number)Number of call logs to fetch per request
setAuthToken(string)Auth token of the logged-in user (required)
setCallCategory(string)Filter by category: "call" or "meet"
setCallType(string)Filter by type: "video" or "audio"
setCallStatus(string)Filter by status: "ongoing", "busy", "rejected", "cancelled", "ended", "missed"
setCallDirection(string)Filter by direction: "incoming" or "outgoing"
setHasRecording(boolean)Filter calls that have recordings
setUid(string)Filter by specific user UID
setGuid(string)Filter by specific group GUID

Filter Examples

const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
  .setLimit(30)
  .setAuthToken(authToken)
  .setCallStatus("missed")
  .build();

Pagination

Fetch Next

Retrieve the next batch of call logs:
callLogRequest.fetchNext().then(
  (callLogs) => {
    console.log("Next batch:", callLogs);
    // Append to existing list
  },
  (error) => {
    console.log("Error:", error);
  }
);

Fetch Previous

Retrieve the previous batch of call logs:
callLogRequest.fetchPrevious().then(
  (callLogs) => {
    console.log("Previous batch:", callLogs);
    // Prepend to existing list
  },
  (error) => {
    console.log("Error:", error);
  }
);

Get Call Details

Retrieve detailed information about a specific call session:
const sessionId = "SESSION_ID";
const authToken = loggedInUser.getAuthToken();

CometChatCalls.getCallDetails(sessionId, authToken).then(
  (callLogs) => {
    console.log("Call details:", callLogs);
    // Access participants, duration, recordings, etc.
  },
  (error) => {
    console.log("Failed to get call details:", error);
  }
);

Call Log Properties

Each call log object contains:
PropertyDescription
sessionIdUnique identifier for the call session
initiatorUser who initiated the call
receiverUser or group that received the call
callTypeType of call (audio or video)
callStatusFinal status of the call
callDirectionDirection (incoming or outgoing)
startedAtTimestamp when call started
endedAtTimestamp when call ended
durationCall duration in seconds
hasRecordingWhether the call has a recording
participantsList of participants in the call

Complete Example

class CallLogManager {
  constructor() {
    this.callLogRequest = null;
    this.callLogs = [];
  }

  async initialize() {
    const loggedInUser = await CometChat.getLoggedinUser();
    
    this.callLogRequest = new CometChatCalls.CallLogRequestBuilder()
      .setLimit(20)
      .setAuthToken(loggedInUser.getAuthToken())
      .setCallCategory("call")
      .build();
  }

  async loadMore() {
    try {
      const logs = await this.callLogRequest.fetchNext();
      this.callLogs = [...this.callLogs, ...logs];
      return logs;
    } catch (error) {
      console.error("Failed to load call logs:", error);
      return [];
    }
  }

  async getCallDetails(sessionId) {
    const loggedInUser = await CometChat.getLoggedinUser();
    try {
      return await CometChatCalls.getCallDetails(
        sessionId,
        loggedInUser.getAuthToken()
      );
    } catch (error) {
      console.error("Failed to get call details:", error);
      return null;
    }
  }

  formatDuration(seconds) {
    const mins = Math.floor(seconds / 60);
    const secs = seconds % 60;
    return `${mins}:${secs.toString().padStart(2, "0")}`;
  }
}

// Usage
const callLogManager = new CallLogManager();
await callLogManager.initialize();
const logs = await callLogManager.loadMore();

Next Steps