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

> 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-3]

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

    ## Prerequisites [#prerequisites-3]

    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-3]

    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-3]

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

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

    ```typescript
    // Chat room members can call fetchChatRoomInfoFromServer to retrieve the basic attributes of the chat room.
    ChatClient.getInstance()
      .roomManager.fetchChatRoomInfoFromServer(roomId)
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });
    ```

    #### Change the chat room name or description [#change-the-chat-room-name-or-description-1]

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

    ```typescript
    // The chat room owner and admin call changeChatRoomSubject to change the chat room name.
    ChatClient.getInstance()
      .roomManager.changeChatRoomSubject(roomId, subject)
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });

    // The chat room owner and admin call changeChatroomDescription to modify the chat room description.
    ChatClient.getInstance()
      .roomManager.changeChatRoomDescription(roomId, desc)
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });
    ```

    #### Retrieve or change the chat room announcement [#retrieve-or-change-the-chat-room-announcement-1]

    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 `onAnnouncementChanged` callback.

    ```typescript
    // Chat room members can call fetchChatRoomAnnouncement to retrieve the chat room announcement.
    ChatClient.getInstance()
      .roomManager.fetchChatRoomAnnouncement(roomId)
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });

    // The chat room owner and admin can call updateChatRoomAnnouncement to set or update the chat room announcement.
    ChatClient.getInstance()
      .roomManager.updateChatRoomAnnouncement(roomId, announcement)
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });
    ```

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

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

    All chat room members can call `addAttributes` to set one or more custom attribute. 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 `onAttributesUpdated` callback.

    ```typescript
    // Sets custom attribute by specifying the chat room ID and the key-value maps of the attributes.
    ChatClient.getInstance()
      .roomManager.addAttributes({
        roomId,
        attributes,
        deleteWhenLeft,
        overwrite,
      })
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });
    ```

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

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

    ```typescript
    // Retrieves certain custom attributes by specifying chat room ID and attribute keys.
    // Retrieves all custom attributes if you pass an empty key.
    ChatClient.getInstance()
      .roomManager.fetchChatRoomAttributes(roomId, keys)
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });
    ```

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

    All 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 `onAttributesRemoved` callback.

    ```typescript
    // Removes custom attributes by specifying the chat room ID and the attribute key list.
    ChatClient.getInstance()
      .roomManager.removeAttributes({
        roomId,
        keys,
        forced,
      })
      .then((response) => {
        rollLog(`success: ${response}`);
      })
      .catch((error) => {
        rollLog(`fail: ${error}`);
      });
    ```

    ### Listen for chat room events [#listen-for-chat-room-events-1]

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

    
  
      
  
      
  
      
  
