> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Conversation Summary

> Conversation Summary — CometChat documentation.

**Conversation Summary** enables the summarization of conversations using AI.

## Before you begin

1. Set up the AI settings through the CometChat dashboard as detailed in the [Overview section](/fundamentals/ai-user-copilot/overview).
2. Navigate to Chat > Features, under **AI User Copilot**, enable **Conversation Summary**.

   <Frame>
     <img src="https://mintcdn.com/cometchat-22654f5b/y8uIEcRYKgfQIY6z/images/9b8957a8-cometchat-ai-features-conversation-summary-e03289a4865ac61bfa870fc60b5e40ef.png?fit=max&auto=format&n=y8uIEcRYKgfQIY6z&q=85&s=934c88a53aaa1c710e387c07cc105185" width="1202" height="605" data-path="images/9b8957a8-cometchat-ai-features-conversation-summary-e03289a4865ac61bfa870fc60b5e40ef.png" />
   </Frame>
3. Implement the chat functionality in your applications using [CometChat's **v4** Chat SDKs](/sdk/javascript/overview).

## How does it work?

CometChat AI goes through the messages of a conversation to understand the context of a conversation & provide a short summary of the conversation.

The CometChat SDK has a method to fetch the conversation summary. It returns the conversation summary as a string.

The number of messages to be fetched to generate relevant summaries is configurable. By default the CometChat AI takes the latest `1000` messages. This can be configured to specific timestamps as well.

| Configuration | Value                                                  |
| ------------- | ------------------------------------------------------ |
| lastNMessages | This will fetch specific number of messages.           |
| fromTimestamp | This will fetch messages from a particular timestamp.  |
| toTimestamp   | This will fetch messages until a particular timestamp. |
| unreadOnly    | This will fetch only the unread messages.              |

<Note>
  While using any configuration mentioned above a maximum of **only** `1000` messages will be fetched.
</Note>

## Implementation

### SDKs

To implement Conversation Summary in the platform of your choice, you may utilize the following code samples:

<Tabs>
  <Tab title="JS/React Native/Ionic SDK">
    ```js theme={null}
    const receiverId = "UID/GUID";
    const receiverType = "user/group";
    const configuration = { lastNMessages: 100 };

    CometChat.getConversationSummary(receiverId, receiverType, configuration).then(
      (conversationSummary) => {
        console.log("Conversation Summary:", conversationSummary);
      },
      (error) => {
        console.log(
          "An error occurred while fetching conversation summary.",
          error
        );
      }
    );
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    String receiverId = 'UID/GUID';
    String receiverType = CometChatConstants.RECEIVER_TYPE_USER; //'user/group'
    JSONObject configuration =  new JSONObject();
    try {
        configuration.put("lastNMessages", 100);
    } catch (JSONException e) {
        throw new RuntimeException(e);
    }

    CometChat.getConversationSummary(receiverId, receiverType,c onfiguration, new CometChat.CallbackListener<String>() {
        @Override
        public void onSuccess(String s) {
            Logger.error(TAG, s);
        }

        @Override
        public void onError(CometChatException e) {
            Logger.error(TAG, e.getMessage());
        }
    });
    ```
  </Tab>

  <Tab title="Kotlin">
    ```kotlin theme={null}
    val receiverId = "UID/GUID"
    val receiverType = CometChatConstants.RECEIVER_TYPE_USER // 'user/group'
    val configuration = JSONObject()

    try {
        configuration.put("lastNMessages", 100)
    } catch (e: JSONException) {
        throw RuntimeException(e)
    }

    CometChat.getConversationSummary(receiverId, receiverType, configuration,
        object : CometChat.CallbackListener<String>() {
            override fun onSuccess(s: String) {
                Log.e(TAG, s)
            }

            override fun onError(e: CometChatException) {
                Log.e(TAG, e.localizedMessage)
            }
    })
    ```
  </Tab>

  <Tab title="Swift">
    ```swift theme={null}
    let receiverId = ""
    let receiverType = CometChat.ReceiverType.group
    let configuration = [ "lastNMessages": 100 ]

    CometChat.getConversationSummary(receiverId: receiverId, receiverType: receiverType, configuration: configuration) { summary in
        print("getConversationSummary success: \(summary)")
    } onError: { error in
        print("getConversationSummary error: \(error?.errorDescription)")
    }
    ```
  </Tab>

  <Tab title="Dart">
    ```dart theme={null}
    String receiveId = "";
    String receiverType = CometChatConversationType.user;
    Map configuration = { "lastNMessages": 100 };

    CometChat.getConversationSummary(receiveId, receiverType, configuration: configuration, onSuccess:(String summary) {
       debugPrint("getConversationSummary Success: $summary");
    }, onError: (CometChatException e) {
       debugPrint("getConversationSummary error: $e");
    });
    ```
  </Tab>
</Tabs>

### UI Kits

Assuming the necessary prerequisites are met, Conversation Summary functions seamlessly starting from v4 of the Chat UI Kits. The placement of the AI icon may vary based on the version. Clicking on the icon will display the Conversation Summary.
