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

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

Chat groups enable real-time messaging among multiple users.

    This page shows how to use the Agora Chat SDK to manage the attributes of the members of a chat group in your app.

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

    The Chat SDK provides the `ChatGroup`, `ChatGroupManager`, and `ChatGroupEventListener` classes for chat group management, which allows you to implement the following features:

    * Set custom attributes of a group member via key and value items.
    * Fetch group member custom attributes.
    * Listen for attribute changes of a group member.

    ## Prerequisites [#prerequisites-3]

    Before proceeding, ensure that you meet the following requirements:

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

    ## Implementation [#implementation-3]

    This section describes how to call the APIs provided by the Chat SDK to implement chat group features.

    ### Set custom attributes of a group member via key and value items [#set-custom-attributes-of-a-group-member-via-key-and-value-items-3]

    Each chat group member can set their own attributes. Chat group admins/owners can also modify all members' attributes. Each custom attribute should be in key-value format.

    Refer to the following sample code to set a custom attribute of a group member:

    ```typescript
    // groupId: The group ID.
    // member: The user ID of the group member.
    // attributes: The custom attributes to set.
    ChatClient.getInstance()
      .groupManager.setMemberAttribute(groupId, member, attributes)
      .then(() => {
        console.log("set group members attributes success.");
      })
      .catch((reason) => {
        console.log("set group members attributes fail.", reason);
      });

    ```

    ### Fetch group member custom attributes [#fetch-group-member-custom-attributes-3]

    Chat group members and group admins/owners can retrieve custom attributes of multiple group members by attribute key.

    Refer to the following sample code to use the attribute key to fetch custom attributes of multiple group members:

    ```typescript
    // groupId: The group ID.
    // members: The array of user IDs of group members.
    // attributeKeys: The array of keys of custom attributes to otain. If the array is empty or no key is passed in, all custom attributes of these members are obtained.
    ChatClient.getInstance()
      .groupManager.fetchMembersAttributes(groupId, members, attributeKeys)
      .then((result: Map>) => {
        console.log("get group members attributes success.", result);
      })
      .catch((reason) => {
        console.log("get group members attributes fail.", reason);
      });
    ```

    ### Listen for attribute changes of a group member [#listen-for-attribute-changes-of-a-group-member-3]

    `ChatGroupEventListener` class holds callbacks that can be used to monitor the change of any key-value items. When such a change occurs, an `onMemberAttributesChanged` callback will notify the Client SDK by returning chat group ID, UID, and key-value pairs of the changes.

    ```typescript
     onMemberAttributesChanged(params: {
        groupId: string;
        member: string;
        attributes: any;
        operator: string;
      }): void {
        console.log(`${QuickTestScreenBase.TAG}: onStateChanged:`, params);
        this.that.setState({
          recvResult: `onMemberAttributesChanged: ` + params,
        });
      }
    ```

    
  
      
  
      
  
      
  
