getConversationSummary static method

Future<void> getConversationSummary(
  1. String receiverId,
  2. String receiverType, {
  3. Map? configuration,
  4. required dynamic onSuccess(
    1. String conversationSummary
    ),
  5. required dynamic onError(
    1. CometChatException excep
    ),
})

Get AI-generated summary of a conversation.

Migration Note: Migrated from platform channels to native Dart implementation. Uses AiRepository for AI-powered conversation summaries. Behavior and signature remain identical for backward compatibility.

Android Reference: CometChat.getConversationSummary(String receiverId, String receiverType, CallbackListener<String>)

Implementation

static Future<void> getConversationSummary(
  String receiverId,
  String receiverType, {
  Map? configuration,
  required Function(String conversationSummary) onSuccess,
  required Function(CometChatException e) onError,
}) async {
  try {
    // Validate parameters
    if (receiverId.isEmpty) {
      onError(
        CometChatException(
          ErrorCode.errorInvalidReceiverId,
          ErrorMessage.errorMessageInvalidReceiverId,
          ErrorMessage.errorMessageInvalidReceiverId,
        ),
      );
      return;
    }
    if (receiverType.isEmpty) {
      onError(
        CometChatException(
          ErrorCode.errorInvalidReceiverType,
          ErrorMessage.errorMessageInvalidReceiverType,
          ErrorMessage.errorMessageInvalidReceiverType,
        ),
      );
      return;
    }

    // Get SDK instance
    final sdk = SdkRegistry.getInstance();

    // Call native Dart AI repository
    final summary = await sdk.ai.getConversationSummary(
      receiverId,
      receiverType,
    );

    // Call success callback
    onSuccess(summary);
  } on SdkException catch (sdkEx) {
    // Convert SdkException to CometChatException
    final cometChatEx = CometChatException(
      sdkEx.code,
      sdkEx.details ?? sdkEx.message,
      sdkEx.message,
    );
    onError(cometChatEx);
  } catch (e) {
    onError(
      CometChatException(
        ErrorCode.errorUnhandledException,
        e.toString(),
        e.toString(),
      ),
    );
  }
}