Skip to main content

Integrate with chat

When you integrate with the Chat SDK, the recommended approach is:

  1. Listen for NCCallLog callbacks after the call ends.
  2. Map NCCallLog to your own message model or conversation summary model.
  3. Insert or update the message through the Chat SDK or ChatUI SDK so the conversation view refreshes.

Callbacks for conversation UI

NCCallEventHandler currently exposes two call log related events:

CallbackDescription
onLocalCallLogReceived(NCCallLocalCallLogReceivedEvent)Locally generated call summary. Most useful as a fallback for local NCCallType.SINGLE conversation display.
onServerCallLogReceived(NCCallServerCallLogReceivedEvent)Server-generated call log. Best for final conversation display and history sync.

Useful NCCallLog fields

NCCallLog currently exposes these commonly used fields for building conversation messages:

  • getCallId()
  • getCallType()
  • getMediaType()
  • getCallerUserId()
  • getParticipants()
  • getDuration()
  • getEndReason()
  • getCallDirection()
  • getStartTime()
  • getEndTime()
Java
NCCallEngine.getInstance().setCallEventHandler(new NCCallEventHandler() {
@Override
public void onCallReceived(NCCallReceivedEvent event) {
}

@Override
public void onCallConnected(NCCallConnectedEvent event) {
}

@Override
public void onLocalCallLogReceived(NCCallLocalCallLogReceivedEvent event) {
insertCallSummaryMessage(event.getCallLog());
}

@Override
public void onServerCallLogReceived(NCCallServerCallLogReceivedEvent event) {
upsertCallHistoryMessage(event.getCallLog());
}

// Implement other callbacks as needed
});

Map NCCallLog to a chat message

The following example converts a call log into a text summary for a conversation:

Java
private void insertCallSummaryMessage(NCCallLog callLog) {
String summary = buildSummary(callLog);

// Replace this with your Chat SDK or ChatUI SDK message write logic
// For example, create a custom message, a text message, or update the recent conversation summary
chatRepository.insertCallSummary(
callLog.getCallId(),
summary,
callLog.getEndTime()
);
}

private String buildSummary(NCCallLog callLog) {
String mediaText =
callLog.getMediaType() == NCCallMediaType.AUDIO_VIDEO ? "Video call" : "Audio call";

if (callLog.getDuration() > 0) {
return mediaText + " " + callLog.getDuration() + " seconds";
}

return mediaText + ", ended: " + callLog.getEndReason().name();
}

Recommendations

  • For immediate in-conversation display, prefer onLocalCallLogReceived(...).
  • For cross-device sync or final state correction, prefer onServerCallLogReceived(...).
  • If your conversation UI needs to distinguish incoming, outgoing, or group calls, combine getCallDirection() with getCallType().