# Manage chat room attributes (/en/realtime-media/im/build/build-groups-rooms-and-threads/chat-room/manage-chatroom-attributes/unity)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Chat room attributes consist of basic attributes (such as room subject, room description, and room announcement) and custom attributes. When basic attributes cannot satisfy the business requirements, users can add custom attributes that are synchronized with all chat room members.
    Custom attributes can be used to store information such as chat room type, game roles, game status, and host positions. They are stored as key-value maps, and the updates of custom attributes are synchronized with all chat room members.

    This page shows how to use the Agora Chat SDK to manage basic and custom attributes of a chat room in your app.

    ## Understand the tech [#understand-the-tech-5]

    The Agora Chat SDK provides the `Room`, `IRoomManager`, and `IRoomManagerDelegate` classes for chat room management, which allow you to implement the following features:

    ## Prerequisites [#prerequisites-5]

    Before proceeding, ensure that you meet the following requirements:

    * You have initialized the Chat SDK. For details, see [SDK quickstart](../../../get-started-sdk).
    * You understand the call frequency limit of the Chat APIs supported by different pricing plans as described in [Limitations](../../limitations).
    * You understand the number of chat rooms supported by different pricing plans as described in [Pricing Plan Details](../../../reference/pricing-plan-details).

    ## Implementation [#implementation-5]

    This section introduces how to call the APIs provided by the Chat SDK to implement the features listed above.

    ### Manage basic chat room attributes [#manage-basic-chat-room-attributes-5]

    #### Retrieve basic chat room attributes [#retrieve-basic-chat-room-attributes-5]

    All chat room members can call `FetchRoomInfoFromServer` to retrieve the detailed information of the current chat room, including the subject, announcement, description, member type, and admin list.

    ```csharp
    // The chat room members can call FetchRoomInfoFromServer to get the information of the specified chat room.
    SDKClient.Instance.RoomManager.FetchRoomInfoFromServer(roomId, new ValueCallBack(
        onSuccess: (room) => {
        },
        onError: (code, desc) => {
        }
    ));
    ```

    #### Change chat room name or description [#change-chat-room-name-or-description-3]

    Only the chat room owner and admin can set and update the chat room name and description.

    ```csharp
    // The chat room owner and admin can call ChangeRoomName to change the chat room name.
    SDKClient.Instance.RoomManager.ChangeRoomName(roomId, name, new CallBack(
        onSuccess: () => {
        },
        onError: (code, desc) => {
        }
    ));

    // The chat room owner and admin can call ChangeRoomDescription to modify the chat room description.
    SDKClient.Instance.RoomManager.ChangeRoomDescription(roomId, newDesc, new CallBack(
        onSuccess: () => {
        },
        onError: (code, desc) => {
        }
    ));
    ```

    #### Retrieve or change chat room announcements [#retrieve-or-change-chat-room-announcements-2]

    All chat room members can retrieve the chat room announcement.

    Only the chat room owner and admin can set and update the announcement. Once the announcement is updated, all the other chat room members receive the `OnAnnouncementChangedFromRoom` callback.

    ```csharp
    // Chat room members can call FetchRoomAnnouncement to retrieve the chat room announcement.
    SDKClient.Instance.RoomManager.FetchRoomAnnouncement(roomId, new ValueCallBack(
        onSuccess: (announcement) => {
        },
        onError: (code, desc) => {
        }
    ));

    // The chat room owner and admin can call UpdateRoomAnnouncement to set or update the chat room announcement.
    SDKClient.Instance.RoomManager.UpdateRoomAnnouncement(roomId, announcement, new CallBack(
        onSuccess: () => {
        },
        onError: (code, desc) => {
        }
    ));
    ```

    ### Manage custom chat room attributes [#manage-custom-chat-room-attributes-5]

    #### Set one or more custom attributes [#set-one-or-more-custom-attributes-2]

    All chat room members can call `AddAttributes` to set one or more custom attributes. Use this method to add new custom attributes or update existing attributes that are set by yourself and others. After you successfully call this method, other members in the chat room receive an `OnChatroomAttributesChanged` callback.

    ```csharp
    // Sets custom attributes by specifying the chat room ID and key-value maps of the attributes.
    SDKClient.Instance.RoomManager.AddAttributes(roomId, kv, deleteWhenExit, forced, new CallBackResult(
        onSuccessResult: (Dictionary failInfo) => {
            if(failInfo.Count == 0)
            {
                //All custom attributes are successfully set.
            }
            else
            {
                //Failed to set certain custom attributes.
            }
        },
        onError: (code, desc) => {
        }
    ));
    ```

    #### Retrieve specified or all custom attributes [#retrieve-specified-or-all-custom-attributes-5]

    All chat room members can call `FetchAttributes` to retrieve the specified or all custom attributes of the chat room.

    ```csharp
    // Retrieves certain or all custom attributes by specifying chat room ID and attribute keys.
    SDKClient.Instance.RoomManager.FetchAttributes(roomId, keys, new ValueCallBack>(
        onSuccess: (Dictionary dict) => {
        },
        onError: (code, desc) => {
        }
    ));
    ```

    #### Remove one or more custom attributes [#remove-one-or-more-custom-attributes-3]

    Chat room members can call `RemoveAttributes` to remove one or more custom attributes that are set by themselves and others. After you successfully call this method, other members in the chat room receive an `OnChatroomAttributesRemoved` callback.

    ```csharp
    // Removes custom attributes by specifying the chat room ID and the attribute key list.
    SDKClient.Instance.RoomManager.RemoveAttributes(roomId, keys, forced, new CallBackResult(
        onSuccessResult: (Dictionary failInfo) => {
            if (failInfo.Count == 0)
            {
                // All the custom attributes are removed successfully.
            }
            else
            {
                // Certain custom attributes are not removed successfully.
            }
        },
        onError: (code, desc) => {
        }
    ));
    ```

    For details, see [Chat Room Events](manage-chatrooms#listen-for-chat-room-events).

    
  
      
  
