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:
JavaScript
TypeScript
Async/Await
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);
}
);
const loggedInUser = await CometChat.getLoggedinUser();
const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
.setLimit(30)
.setAuthToken(loggedInUser.getAuthToken())
.setCallCategory("call")
.build();
callLogRequest.fetchNext().then(
(callLogs: any[]) => {
console.log("Call logs:", callLogs);
},
(error: any) => {
console.log("Failed to fetch call logs:", error);
}
);
const fetchCallLogs = async () => {
try {
const loggedInUser = await CometChat.getLoggedinUser();
const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
.setLimit(30)
.setAuthToken(loggedInUser.getAuthToken())
.setCallCategory("call")
.build();
const callLogs = await callLogRequest.fetchNext();
console.log("Call logs:", callLogs);
} catch (error) {
console.log("Failed to fetch call logs:", error);
}
};
Builder Options
| Method | Description |
|---|
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
Missed Calls
Video Calls Only
Calls with Recordings
Calls with User
const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
.setLimit(30)
.setAuthToken(authToken)
.setCallStatus("missed")
.build();
const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
.setLimit(30)
.setAuthToken(authToken)
.setCallType("video")
.build();
const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
.setLimit(30)
.setAuthToken(authToken)
.setHasRecording(true)
.build();
const callLogRequest = new CometChatCalls.CallLogRequestBuilder()
.setLimit(30)
.setAuthToken(authToken)
.setUid("user_123")
.build();
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);
}
);
callLogRequest.fetchNext().then(
(callLogs: any[]) => {
console.log("Next batch:", callLogs);
},
(error: any) => {
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);
}
);
callLogRequest.fetchPrevious().then(
(callLogs: any[]) => {
console.log("Previous batch:", callLogs);
},
(error: any) => {
console.log("Error:", error);
}
);
Get Call Details
Retrieve detailed information about a specific call session:
JavaScript
TypeScript
Async/Await
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);
}
);
const sessionId: string = "SESSION_ID";
const authToken: string = loggedInUser.getAuthToken();
CometChatCalls.getCallDetails(sessionId, authToken).then(
(callLogs: any[]) => {
console.log("Call details:", callLogs);
},
(error: any) => {
console.log("Failed to get call details:", error);
}
);
const getCallDetails = async () => {
try {
const loggedInUser = await CometChat.getLoggedinUser();
const sessionId = "SESSION_ID";
const authToken = loggedInUser.getAuthToken();
const callDetails = await CometChatCalls.getCallDetails(sessionId, authToken);
console.log("Call details:", callDetails);
} catch (error) {
console.log("Failed to get call details:", error);
}
};
Call Log Properties
Each call log object contains:
| Property | Description |
|---|
sessionId | Unique identifier for the call session |
initiator | User who initiated the call |
receiver | User or group that received the call |
callType | Type of call (audio or video) |
callStatus | Final status of the call |
callDirection | Direction (incoming or outgoing) |
startedAt | Timestamp when call started |
endedAt | Timestamp when call ended |
duration | Call duration in seconds |
hasRecording | Whether the call has a recording |
participants | List 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();
class CallLogManager {
private callLogRequest: any = null;
private callLogs: any[] = [];
async initialize(): Promise<void> {
const loggedInUser = await CometChat.getLoggedinUser();
this.callLogRequest = new CometChatCalls.CallLogRequestBuilder()
.setLimit(20)
.setAuthToken(loggedInUser.getAuthToken())
.setCallCategory("call")
.build();
}
async loadMore(): Promise<any[]> {
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: string): Promise<any | null> {
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: number): string {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return `${mins}:${secs.toString().padStart(2, "0")}`;
}
}
Next Steps