# Reaction (/en/realtime-media/im/build/build-core-messaging/reaction)

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

<_PlatformTabsGroup groupMode="structured" canonicalPlatform="web" platforms="[&#x22;android&#x22;,&#x22;ios&#x22;,&#x22;flutter&#x22;,&#x22;react-native&#x22;,&#x22;windows&#x22;,&#x22;unity&#x22;,&#x22;web&#x22;]" showTabs="true">
  <_PlatformPanel platform="android">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="android" />

    Emojis are widely used in real-time chats because they allow users to express their feelings in a direct and vivid way. In Chat, "reactions" allow users to quickly react to a message using emojis in one-to-one chats and chat groups. In group chats, reactions can also be used to cast a vote, for example, by calculating the number of different emojis attached to the message.

    The following illustration shows the implementation of adding a reaction to a message, how a conversation looks with reactions, and what retrieving a list of reactions (with related information) looks like.

    ![1655257598155](https://web-cdn.agora.io/docs-files/1655257598155)

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

    The SDK provides the following APIs to implement reaction functionalities:

    * `asyncAddReaction`: Adds a reaction to the specified message.
    * `asyncRemoveReaction`: Removes the reaction from the specified message.
    * `asyncGetReactionList`: Retrieves a list of reactions from the server.
    * `asyncGetReactionDetail`: Retrieves the details of the reaction from the server.
    * `ChatMessage.getMessageReaction`: Retrieves a list of reactions from the `ChatMessage` objects in the local database.

    ## Prerequisites [#prerequisites]

    Before proceeding, ensure that your environment meets the following requirements:

    * The project integrates a version of the Chat SDK later than v1.0.3 and has implemented the [basic real-time chat functionalities](../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../limitations).

    <CalloutContainer type="info">
      <CalloutDescription>
        The reaction feature is supported by all types of [Pricing Plans](../../reference/pricing-plan-details) and is enabled by default once you have enabled Chat in [Agora Console](https://console.agora.io/v2).
      </CalloutDescription>
    </CalloutContainer>

    ## Implementation [#implementation]

    This section introduces how to implement reaction functionalities in your project.

    ### Add a reaction [#add-a-reaction]

    Call `asyncAddReaction` to add a reaction to the specified message. In a one-to-one conversation, the peer user receives the `onReactionChanged` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the new reaction, user ID of the user that adds the reaction, and the addition operation).

    For a reaction, a user can add only once, or the error 1301 is reported for repeated addition.

    ```java
    // Add a reaction
    ChatClient.getInstance().chatManager().asyncAddReaction(message.getMsgId(), reaction, new CallBack() {
                @Override
                public void onSuccess() {

                }
                @Override
                public void onError(int error, String errorMsg) {

                }
                @Override
                public void onProgress(int i, String s) {
                }
            });
    // Listen for the state of the reaction.
    public class MyClass implements MessageListener {
        private void init() {
            ChatClient.getInstance().chatManager().addMessageListener(this);
        }
        @Override
        public void onReactionChanged(List list) {

        }
    }
    ```

    ### Remove a reaction [#remove-a-reaction]

    Call `asyncRemoveReaction` to remove the specified reaction. In a one-to-one conversation, the peer user receives the `onReactionChanged` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the removed reaction, user ID of the user that removes the reaction, and the removal operation).

    ```java
    // Remove the reaction.
    ChatClient.getInstance().chatManager().asyncRemoveReaction(message.getMsgId(), reaction, new CallBack() {
                @Override
                public void onSuccess() {

                }
                @Override
                public void onError(int error, String errorMsg) {

                }
                @Override
                public void onProgress(int i, String s) {
                }
            });
    // Listen for reaction state change.
    public class MyClass implements MessageListener {
        private void init() {
            ChatClient.getInstance().chatManager().addMessageListener(this);
        }
        @Override
        public void onReactionChanged(List list) {

        }
    }
    ```

    ### Retrieve a list of reactions [#retrieve-a-list-of-reactions]

    Call `asyncGetReactionList` to retrieve a list of reactions of messages from the server. This method also returns the basic information of the reactions, including the content of the reaction, the number of users that added or removed the reaction, and a list of the first three user IDs that added or removed the reaction.

    ```java
    ChatClient.getInstance().chatManager().asyncGetReactionList(msgIdList, ChatMessage.ChatType.Chat, groupId, new ValueCallBack>>() {
                @Override
                public void onSuccess(Map> stringListMap) {

                }
                @Override
                public void onError(int i, String s) {

                }
       });
    ```

    ### Retrieve the details of the reaction [#retrieve-the-details-of-the-reaction]

    Call `asyncGetReactionDetail` to get the detailed information of the reaction from the server. The detailed information includes the reaction content, the number of users that added or removed the reaction, and the complete list of user IDs that added or removed the reaction.

    ```java
    ChatClient.getInstance().chatManager().asyncGetReactionDetail(mMsgId, emojiconId, pageCurosr, 30, new ValueCallBack>() {
                        @Override
                        public void onSuccess(CursorResult messageReactionCursorResult) {

                        }
                        @Override
                        public void onError(int i, String s) {

                        }
                    });
    ```

    ## Next steps [#next-steps]

    Reactions are also supported in the [Chat UIKit](../../get-started-uikit), which contains a wider range of emojis. You can also use the Chat SDK to implement reactions in your project.

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="ios">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="ios" />

    Emojis are widely used in real-time chats because they allow users to express their feelings in a direct and vivid way. In Chat, "reactions" allow users to quickly react to a message using emojis in one-to-one chats and chat groups. In group chats, reactions can also be used to cast a vote, for example, by calculating the number of different emojis attached to the message.

    The following illustration shows the implementation of adding a reaction to a message, how a conversation looks with reactions, and what retrieving a list of reactions (with related information) looks like.

    ![1655257598155](https://web-cdn.agora.io/docs-files/1655257598155)

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

    The SDK provides the following APIs to implement reaction functionalities:

    * `addReaction`: Adds a reaction to the specified message.
    * `removeReaction`: Removes the reaction from the specified message.
    * `getReactionList`: Retrieves a list of reactions from the server.
    * `getReactionDetail`: Retrieves the details of the reaction from the server.
    * `AgoraChatMessage.reactionlist`: Retrieves a list of reactions from the `AgoraChatMessage` objects in the local database.

    ## Prerequisites [#prerequisites-1]

    Before proceeding, ensure that your environment meets the following requirements:

    * The project integrates a version of the Chat SDK later than v1.0.3 and has implemented the [basic real-time chat functionalities](../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../limitations).

    <CalloutContainer type="info">
      <CalloutDescription>
        The reaction feature is supported by all types of [Pricing Plans](../../reference/pricing-plan-details) and is enabled by default once you have enabled Chat in [Agora Console](https://console.agora.io/v2).
      </CalloutDescription>
    </CalloutContainer>

    ## Implementation [#implementation-1]

    This section introduces how to implement reaction functionalities in your project.

    ### Add a reaction [#add-a-reaction-1]

    Call `addReaction` to add a reaction to the specified message. In a one-to-one conversation, the peer user receives the `messageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (reaction ID, user ID of the user that adds the reaction, and the addition operation).

    For a reaction, a user can add only once, or the error 1301 is reported for repeated addition.

    ```objc
    // Add a reaction
    [AgoraChatClient.sharedClient.chatManager addReaction:"reaction" toMessage:"messageId" completion:^(AgoraChatError * _Nullable error) {
      refreshBlock(error, changeSelectedStateHandle);
    }];
    // Listen for the state of the reaction.
    - (void)messageReactionDidChange:(NSArray *)changes
    {

    }
    ```

    ### Remove a reaction [#remove-a-reaction-1]

    Call `removeReaction` to remove the specified reaction. In a one-to-one conversation, the peer user receives the `messageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the removed reaction, user ID of the user that removes the reaction, and the removal operation).

    ```objc
    // Remove the reaction.
    [AgoraChatClient.sharedClient.chatManager removeReaction:"reaction" fromMessage:"messageId" completion:^(AgoraChatError * _Nullable error) {
      refreshBlock(error, changeSelectedStateHandle);
    }];
    // Listen for reaction state change.
    - (void)messageReactionDidChange:(NSArray *)changes
    {

    }
    ```

    ### Retrieve a list of reactions [#retrieve-a-list-of-reactions-1]

    Call `getReactionList` to retrieve a list of reactions of messages from the server. This method also returns the basic information of the reactions, including the content of the reaction, the number of users that added or removed the reaction, and a list of the first three user IDs that added or removed the reaction.

    ```objc
    [AgoraChatClient.sharedClient.chatManager getReactionList:@["messageId"] groupId:@"groupId" chatType:AgoraChatTypeChat completion:^(NSDictionary * _Nonnull, AgoraChatError * _Nullable) {

    }];
    ```

    ### Retrieve the details of the reaction [#retrieve-the-details-of-the-reaction-1]

    Call `getReactionDetail` to get the detailed information of the reaction from the server. The detailed information includes the reaction content, the number of users that added or removed the reaction, and the complete list of user IDs that added or removed the reaction.

    ```objc
    [AgoraChatClient.sharedClient.chatManager getReactionDetail:@"messageId" reaction:@"reaction" cursor:nil pageSize:30 completion:^(AgoraChatMessageReaction * _Nonnull, NSString * _Nullable cursor, AgoraChatError * _Nullable) {

    }];
    ```

    ## Next steps [#next-steps-1]

    Reactions are also supported in the [Chat UIKit](../../get-started-uikit), which contains a wider range of emojis. You can also use the Chat SDK to implement reactions in your project.

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="flutter">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="flutter" />

    Emojis are widely used in real-time chats because they allow users to express their feelings in a direct and vivid way. In Chat, "reactions" allow users to quickly react to a message using emojis in one-to-one chats and chat groups. In group chats, reactions can also be used to cast a vote, for example, by calculating the number of different emojis attached to the message.

    The following illustration shows the implementation of adding a reaction to a message, how a conversation looks with reactions, and what retrieving a list of reactions (with related information) looks like.

    ![1655257598155](https://web-cdn.agora.io/docs-files/1655257598155)

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

    The SDK provides the following APIs to implement reaction functionalities:

    * `addReaction`: Adds a reaction to the specified message.
    * `removeReaction`: Removes the reaction from the specified message.
    * `fetchReactionList`: Retrieves a list of reactions from the server.
    * `fetchReactionDetail`: Retrieves the details of the reaction from the server.

    ## Prerequisites [#prerequisites-2]

    Before proceeding, ensure that your environment meets the following requirements:

    * The project integrates a version of the Chat SDK later than v1.0.3 and has implemented the [basic real-time chat functionalities](../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../limitations).

    <CalloutContainer type="info">
      <CalloutDescription>
        The reaction feature is supported by all types of [Pricing Plans](../../reference/pricing-plan-details) and is enabled by default once you have enabled Chat in [Agora Console](https://console.agora.io/v2).
      </CalloutDescription>
    </CalloutContainer>

    ## Implementation [#implementation-2]

    This section introduces how to implement reaction functionalities in your project.

    ### Add a reaction [#add-a-reaction-2]

    Call `addReaction` to add a reaction to the specified message. In a one-to-one conversation, the peer user receives the `onMessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (reaction ID, user ID of the user that adds the reaction, and the addition operation).

    For a reaction, a user can add only once, or the error 1301 is reported for repeated addition.

    ```dart
    // reaction: Reaction ID
    // msgId: The message ID
    // Adds a reaction to the specified message
    ChatClient.getInstance()
      .chatManager.addReaction(reaction, msgId)
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    ### Remove a reaction [#remove-a-reaction-2]

    Call `removeReaction` to remove the specified reaction. In a one-to-one conversation, the peer user receives the `onMessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the removed reaction, user ID of the user that removes the reaction, and the removal operation).

    ```dart
    try {
      await ChatClient.getInstance.chatManager.addReaction(
        messageId: messageId,
        reaction: reaction,
      );
    } on ChatError catch (e) {
    }
    ```

    ### Retrieve a list of reactions [#retrieve-a-list-of-reactions-2]

    Call `getReactionList` to retrieve a list of reactions of messages from the server. This method also returns the basic information of the reactions, including the content of the reaction, the number of users that added or removed the reaction, and a list of the first three user IDs that added or removed the reaction.

    ```dart
    try {
      Map> map =
          await ChatClient.getInstance.chatManager.fetchReactionList(
        messageIds: messageIds,
        chatType: ChatType.GroupChat,
        groupId: groupId,
      );
    } on ChatError catch (e) {
    }
    ```

    You can also use the `reactionList` member in `ChatMessage` to quickly retrieve the reactions of the specified message.

    ```dart
    try {
        List reactions = await msg.reactionList();
    }on ChatError catch (e) {
    }
    ```

    ### Retrieve the details of the reaction [#retrieve-the-details-of-the-reaction-2]

    Call `fetchReactionDetail` to get the detailed information of the reaction from the server. The detailed information includes the reaction content, the number of users that added or removed the reaction, and the complete list of user IDs that added or removed the reaction.

    ```dart
    try {
      ChatCursorResult result =
          await ChatClient.getInstance.chatManager.fetchReactionDetail(
        messageId: messageId,
        reaction: reaction,
      );
    } on ChatError catch (e) {
    }
    ```

    ### Listen for reaction status [#listen-for-reaction-status]

    Use `onMessageReactionDidChange` to listen for changes or status of the reaction.

    ```dart
        // Adds the chat event handler.
        ChatClient.getInstance.chatManager.addEventHandler(
          "UNIQUE_HANDLER_ID",
          ChatEventHandler(
            onMessageReactionDidChange: (events) {},
          ),
        );

        ...

        // Removes the chat event handler.
        ChatClient.getInstance.chatManager.removeEventHandler("UNIQUE_HANDLER_ID");
    }
    ```

    ## Next steps [#next-steps-2]

    Reactions are also supported in the [Chat UIKit](../../get-started-uikit), which contains a wider range of emojis. You can also use the Chat SDK to implement reactions in your project.

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="react-native">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="react-native" />

    Emojis are widely used in real-time chats because they allow users to express their feelings in a direct and vivid way. In Chat, "reactions" allow users to quickly react to a message using emojis in one-to-one chats and chat groups. In group chats, reactions can also be used to cast a vote, for example, by calculating the number of different emojis attached to the message.

    The following illustration shows the implementation of adding a reaction to a message, how a conversation looks with reactions, and what retrieving a list of reactions (with related information) looks like.

    ![1655257598155](https://web-cdn.agora.io/docs-files/1655257598155)

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

    The SDK provides the following APIs to implement reaction functionalities:

    * `addReaction`: Adds a reaction to the specified message.
    * `removeReaction`: Removes the reaction from the specified message.
    * `getReactionList`: Retrieves a list of reactions from the server.
    * `fetchReactionDetail`: Retrieves the details of the reaction from the server.

    ## Prerequisites [#prerequisites-3]

    Before proceeding, ensure that your environment meets the following requirements:

    * The project integrates a version of the Chat SDK later than v1.0.3 and has implemented the [basic real-time chat functionalities](../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../limitations).

    <CalloutContainer type="info">
      <CalloutDescription>
        The reaction feature is supported by all types of [Pricing Plans](../../reference/pricing-plan-details) and is enabled by default once you have enabled Chat in [Agora Console](https://console.agora.io/v2).
      </CalloutDescription>
    </CalloutContainer>

    ## Implementation [#implementation-3]

    This section introduces how to implement reaction functionalities in your project.

    ### Add a reaction [#add-a-reaction-3]

    Call `addReaction` to add a reaction to the specified message. In a one-to-one conversation, the peer user receives the `onMessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (reaction ID, user ID of the user that adds the reaction, and the addition operation).

    For a reaction, a user can add only once, or the error 1301 is reported for repeated addition.

    ```typescript
    // reaction: Reaction ID
    // msgId: The message ID
    // Adds a reaction to the specified message
    ChatClient.getInstance()
      .chatManager.addReaction(reaction, msgId)
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    ### Remove a reaction [#remove-a-reaction-3]

    Call `removeReaction` to remove the specified reaction. You can also listen for the reaction change in `onMessageReactionDidChange`. In a one-to-one conversation, the peer user receives the `onMessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the removed reaction, user ID of the user that removes the reaction, and the removal operation).

    ```typescript
    // reaction: Reaction ID
    // msgId: The message ID
    ChatClient.getInstance()
      .chatManager.removeReaction(reaction, msgId)
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    ### Retrieve a list of reactions [#retrieve-a-list-of-reactions-3]

    Call `getReactionList` to retrieve a list of reactions of messages from the server. This method also returns the basic information of the reactions, including the content of the reaction, the number of users that added or removed the reaction, and a list of the first three user IDs that added or removed the reaction.

    ```typescript
    // msgId: The message ID
    ChatClient.getInstance()
      .chatManager.getReactionList(msgId)
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    You can also use the `reactionList` member in `ChatMessage` to quickly retrieve the reactions of the specified message.

    ```typescript
    const msg = ChatMessage.createTextMessage(targetId, content);
    msg.reactionList
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    ### Retrieve the details of the reaction [#retrieve-the-details-of-the-reaction-3]

    Call `fetchReactionDetail` to get the detailed information of the reaction from the server. The detailed information includes the reaction content, the number of users that added or removed the reaction, and the complete list of user IDs that added or removed the reaction.

    ```typescript
    // reaction: Reaction ID
    // msgId: The message ID
    // pageSize: The number of reactions returned for each method call. The value range is [1,50]
    // cursor: The position from which to get the reaction detail. Pass `null` or an empty string for the first method call.
    ChatClient.getInstance()
      .chatManager.fetchReactionDetail(msgId, reaction, cursor, pageSize)
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    ### Listen for reaction status [#listen-for-reaction-status-1]

    Use `onMessageReactionDidChange` to listen for changes or status of the reaction.

    ```typescript
    // listens for reaction updates
    class ChatMessageEvent implements ChatMessageEventListener {
      onMessageReactionDidChange(_list: ChatMessageReactionEvent[]): void {
        throw new Error("Method not implemented.");
      }
      // Add other callbacks according to your business logic
    }
    // Adds the message status listener
    const listener = new ChatMessageEvent();
    ChatClient.getInstance().chatManager.addMessageListener(listener);
    // Removes the listener
    ChatClient.getInstance().chatManager.removeMessageListener(listener);
    // Removes all listeners
    ChatClient.getInstance().chatManager.removeAllMessageListener();
    ```

    ## Next steps [#next-steps-3]

    Reactions are also supported in the [Chat UIKit](../../get-started-uikit), which contains a wider range of emojis. You can also use the Chat SDK to implement reactions in your project.

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="windows">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="windows" />

    Emojis are widely used in real-time chats because they allow users to express their feelings in a direct and vivid way. In Chat, "reactions" allow users to quickly react to a message using emojis in one-to-one chats and chat groups. In group chats, reactions can also be used to cast a vote, for example, by calculating the number of different emojis attached to the message.

    The following illustration shows the implementation of adding a reaction to a message, how a conversation looks with reactions, and what retrieving a list of reactions (with related information) looks like.

    ![1655257598155](https://web-cdn.agora.io/docs-files/1655257598155)

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

    The SDK provides the following APIs to implement reaction functionalities:

    * `AddReaction`: Adds a reaction to the specified message.
    * `RemoveReaction`: Removes the reaction from the specified message.
    * `GetReactionList`: Retrieves a list of reactions from the server.
    * `GetReactionDetail`: Retrieves the details of the reaction from the server.
    * `Message.ReactionList`: Retrieves a list of reactions from the Message object.

    ## Prerequisites [#prerequisites-4]

    Before proceeding, ensure that your environment meets the following requirements:

    * The project integrates a version of the Chat SDK later than v1.0.3 and has implemented the [basic real-time chat functionalities](../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../limitations).

    <CalloutContainer type="info">
      <CalloutDescription>
        The reaction feature is supported by all types of [Pricing Plans](../../reference/pricing-plan-details) and is enabled by default once you have enabled Chat in [Agora Console](https://console.agora.io/v2).
      </CalloutDescription>
    </CalloutContainer>

    ## Implementation [#implementation-4]

    This section introduces how to implement reaction functionalities in your project.

    ### Add a reaction [#add-a-reaction-4]

    Call `AddReaction` to add a reaction to the specified message. In a one-to-one conversation, the peer user receives the `MessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (reaction ID, user ID of the user that adds the reaction, and the addition operation).

    For a reaction, a user can add only once, or the error 1301 is reported for repeated addition.

    ```csharp
    // Adds a reaction to the specified message
    SDKClient.Instance.ChatManager.AddReaction(msg_id, reaction, new CallBack(
         onSuccess: () =>
         {
             Debug.Log($"AddReaction success.");
         },
         onError: (code, desc) =>
         {
             Debug.Log($"AddReaction failed, code:{code}, desc:{desc}");
         }
    ));

    // Listens for the reaction changes.
    class ReactionManagerDelegate : IReactionManagerDelegate
    {
        public void MessageReactionDidChange(List list)
        {
            if (list.Count == 0) return;
            foreach(var it in list)
            {
                // Add the iteration logic here.
            }
        }
    }

    // Adds a listener for the reaction.
    ReactionManagerDelegate reactionManagerDelegate = new ReactionManagerDelegate();
    SDKClient.Instance.ChatManager.AddReactionManagerDelegate(reactionManagerDelegate);
    ```

    ### Remove a reaction [#remove-a-reaction-4]

    Call `RemoveReaction` to remove the specified reaction. In a one-to-one conversation, the peer user receives the `MessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the removed reaction, user ID of the user that removes the reaction, and the removal operation).

    ```csharp
    // Removes the reaction.
    SDKClient.Instance.ChatManager.RemoveReaction(msg_id, reaction, new CallBack(
         onSuccess: () =>
         {
             Debug.Log($"RemoveReaction success.");
         },
         onError: (code, desc) =>
         {
             Debug.Log($"RemoveReaction failed, code:{code}, desc:{desc}");
         }
    ));

    // Listens for the reaction changes.
    class ReactionManagerDelegate : IReactionManagerDelegate
    {
        public void MessageReactionDidChange(List list)
        {
            if (list.Count == 0) return;
            foreach(var it in list)
            {
                // Add the iteration logic here.
            }
        }
    }

    // Adds a listener for the reaction.
    ReactionManagerDelegate reactionManagerDelegate = new ReactionManagerDelegate();
    SDKClient.Instance.ChatManager.AddReactionManagerDelegate(reactionManagerDelegate);
    ```

    ### Retrieve a list of reactions [#retrieve-a-list-of-reactions-4]

    Call `GetReactionList` to retrieve a list of reactions of messages from the server. This method also returns the basic information of the reactions, including the content of the reaction, the number of users that added or removed the reaction, and a list of the first three user IDs that added or removed the reaction.

    ```csharp
    SDKClient.Instance.ChatManager.GetReactionList(messageIdList, chatType, groupId, new ValueCallBack>>(
    onSuccess: (dict) =>
    {
        // Iterates through the returned reaction dictionary.
        foreach (var it in dict)
        {
            // Iterates each list of reaction in the dictionary.
            List rl = it.Value;
            foreach (var lit in rl)
            {
                // Handles each reaction.
            }
        }
    },
    onError: (code, desc) =>
    {
        Debug.Log($"GetReactionList failed, code:{code}, desc:{desc}");
    }
    ));
    ```

    ### Retrieve the details of the reaction [#retrieve-the-details-of-the-reaction-4]

    Call `GetReactionDetail` to get the detailed information of the reaction from the server. The detailed information includes the reaction content, the number of users that added or removed the reaction, and the complete list of user IDs that added or removed the reaction.

    ```csharp
    SDKClient.Instance.ChatManager.GetReactionDetail(msg_id, reaction, cursor, pageSize, new ValueCallBack>(
    onSuccess: (ret) =>
    {
        Debug.Log($"GetReactionDetail success");
        if (ret.Data.Count > 0)
        {
            MessageReaction mr = ret.Data[0];
            // Handles the retrieved reaction.
        }
    },
    onError: (code, desc) =>
    {
        Debug($"GetReactionDetail failed, code:{code}, desc:{desc}");
    }
    ));
    ```

    ## Next steps [#next-steps-4]

    Reactions are also supported in the [Chat UIKit](../../get-started-uikit), which contains a wider range of emojis. You can also use the Chat SDK to implement reactions in your project.

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="unity">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="unity" />

    Emojis are widely used in real-time chats because they allow users to express their feelings in a direct and vivid way. In Chat, "reactions" allow users to quickly react to a message using emojis in one-to-one chats and chat groups. In group chats, reactions can also be used to cast a vote, for example, by calculating the number of different emojis attached to the message.

    The following illustration shows the implementation of adding a reaction to a message, how a conversation looks with reactions, and what retrieving a list of reactions (with related information) looks like.

    ![1655257598155](https://web-cdn.agora.io/docs-files/1655257598155)

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

    The SDK provides the following APIs to implement reaction functionalities:

    * `AddReaction`: Adds a reaction to the specified message.
    * `RemoveReaction`: Removes the reaction from the specified message.
    * `GetReactionList`: Retrieves a list of reactions from the server.
    * `GetReactionDetail`: Retrieves the details of the reaction from the server.
    * `Message.ReactionList`: Retrieves a list of reactions from the Message object.

    ## Prerequisites [#prerequisites-5]

    Before proceeding, ensure that your environment meets the following requirements:

    * The project integrates a version of the Chat SDK later than v1.0.3 and has implemented the [basic real-time chat functionalities](../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../limitations).

    <CalloutContainer type="info">
      <CalloutDescription>
        The reaction feature is supported by all types of [Pricing Plans](../../reference/pricing-plan-details) and is enabled by default once you have enabled Chat in [Agora Console](https://console.agora.io/v2).
      </CalloutDescription>
    </CalloutContainer>

    ## Implementation [#implementation-5]

    This section introduces how to implement reaction functionalities in your project.

    ### Add a reaction [#add-a-reaction-5]

    Call `AddReaction` to add a reaction to the specified message. In a one-to-one conversation, the peer user receives the `MessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (reaction ID, user ID of the user that adds the reaction, and the addition operation).

    For a reaction, a user can add only once, or the error 1301 is reported for repeated addition.

    ```csharp
    // Adds a reaction to the specified message
    SDKClient.Instance.ChatManager.AddReaction(msg_id, reaction, new CallBack(
         onSuccess: () =>
         {
             Debug.Log($"AddReaction success.");
         },
         onError: (code, desc) =>
         {
             Debug.Log($"AddReaction failed, code:{code}, desc:{desc}");
         }
    ));

    // Listens for the reaction changes.
    class ReactionManagerDelegate : IReactionManagerDelegate
    {
        public void MessageReactionDidChange(List list)
        {
            if (list.Count == 0) return;
            foreach(var it in list)
            {
                // Add the iteration logic here.
            }
        }
    }

    // Adds a listener for the reaction.
    ReactionManagerDelegate reactionManagerDelegate = new ReactionManagerDelegate();
    SDKClient.Instance.ChatManager.AddReactionManagerDelegate(reactionManagerDelegate);
    ```

    ### Remove a reaction [#remove-a-reaction-5]

    Call `RemoveReaction` to remove the specified reaction. In a one-to-one conversation, the peer user receives the `MessageReactionDidChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the removed reaction, user ID of the user that removes the reaction, and the removal operation).

    ```csharp
    // Removes the reaction.
    SDKClient.Instance.ChatManager.RemoveReaction(msg_id, reaction, new CallBack(
         onSuccess: () =>
         {
             Debug.Log($"RemoveReaction success.");
         },
         onError: (code, desc) =>
         {
             Debug.Log($"RemoveReaction failed, code:{code}, desc:{desc}");
         }
    ));

    // Listens for the reaction changes.
    class ReactionManagerDelegate : IReactionManagerDelegate
    {
        public void MessageReactionDidChange(List list)
        {
            if (list.Count == 0) return;
            foreach(var it in list)
            {
                // Add the iteration logic here.
            }
        }
    }

    // Adds a listener for the reaction.
    ReactionManagerDelegate reactionManagerDelegate = new ReactionManagerDelegate();
    SDKClient.Instance.ChatManager.AddReactionManagerDelegate(reactionManagerDelegate);
    ```

    ### Retrieve a list of reactions [#retrieve-a-list-of-reactions-5]

    Call `GetReactionList` to retrieve a list of reactions of messages from the server. This method also returns the basic information of the reactions, including the content of the reaction, the number of users that added or removed the reaction, and a list of the first three user IDs that added or removed the reaction.

    ```csharp
    SDKClient.Instance.ChatManager.GetReactionList(messageIdList, chatType, groupId, new ValueCallBack>>(
    onSuccess: (dict) =>
    {
        // Iterates through the returned reaction dictionary.
        foreach (var it in dict)
        {
            // Iterates each list of reaction in the dictionary.
            List rl = it.Value;
            foreach (var lit in rl)
            {
                // Handles each reaction.
            }
        }
    },
    onError: (code, desc) =>
    {
        Debug.Log($"GetReactionList failed, code:{code}, desc:{desc}");
    }
    ));
    ```

    ### Retrieve the details of the reaction [#retrieve-the-details-of-the-reaction-5]

    Call `GetReactionDetail` to get the detailed information of the reaction from the server. The detailed information includes the reaction content, the number of users that added or removed the reaction, and the complete list of user IDs that added or removed the reaction.

    ```csharp
    SDKClient.Instance.ChatManager.GetReactionDetail(msg_id, reaction, cursor, pageSize, new ValueCallBack>(
    onSuccess: (ret) =>
    {
        Debug.Log($"GetReactionDetail success");
        if (ret.Data.Count > 0)
        {
            MessageReaction mr = ret.Data[0];
            // Handles the retrieved reaction.
        }
    },
    onError: (code, desc) =>
    {
        Debug($"GetReactionDetail failed, code:{code}, desc:{desc}");
    }
    ));
    ```

    ## Next steps [#next-steps-5]

    Reactions are also supported in the [Chat UIKit](../../get-started-uikit), which contains a wider range of emojis. You can also use the Chat SDK to implement reactions in your project.

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="web">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="web" />

    Emojis are widely used in real-time chats because they allow users to express their feelings in a direct and vivid way. In Chat, "reactions" allow users to quickly react to a message using emojis in one-to-one chats and chat groups. In group chats, reactions can also be used to cast a vote, for example, by calculating the number of different emojis attached to the message.

    The following illustration shows the implementation of adding a reaction to a message, how a conversation looks with reactions, and what retrieving a list of reactions (with related information) looks like.

    * Adding a reaction

      ![1655257804635](https://web-cdn.agora.io/docs-files/1655257804635)

    * Retrieving a list of reactions

      ![1655257845986](https://web-cdn.agora.io/docs-files/1655257845986)

    This page shows how to use the Chat SDK to implement reactions in your project.

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

    The SDK provides the following APIs to implement reaction functionalities:

    * `addReaction`: Adds a reaction to the specified message.
    * `deleteReaction`: Removes the reaction from the specified message.
    * `getReactionlist`: Retrieves a list of reactions from the server.
    * `getReactionDetail`: Retrieves the details of the reaction from the server.
    * `getHistoryMessages`：Retrieves the reactions in historical messages from the server.

    ## Prerequisites [#prerequisites-6]

    Before proceeding, ensure that your environment meets the following requirements:

    * The project integrates a version of the Chat SDK later than v1.0.3 and has implemented the [basic real-time chat functionalities](../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../limitations).

    <CalloutContainer type="info">
      <CalloutDescription>
        The reaction feature is supported by all types of [Pricing Plans](../../reference/pricing-plan-details) and is enabled by default once you have enabled Chat in [Agora Console](https://console.agora.io/v2).
      </CalloutDescription>
    </CalloutContainer>

    ## Implementation [#implementation-6]

    This section introduces how to implement reaction functionalities in your project.

    ### Add a reaction [#add-a-reaction-6]

    Call `addReaction` to add a reaction to the specified message. In a one-to-one conversation, the peer user receives the `onReactionChange` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (reaction ID, user ID of the user that adds the reaction, and the addition operation).

    For a reaction, a user can add only once, or the error 1101 is reported for repeated addition.

    ```javascript
    // Add a reaction
    chatClient.addReaction({ messageId: "messageId", reaction: "reaction" });
    // Listen for the state of the reaction.
    chatClient.addEventHandler("handlerId", {
      onReactionChange: (reactionMsg) => {
        console.log(reactionMsg);
      },
    });
    ```

    ### Remove a reaction [#remove-a-reaction-6]

    Call `deleteReaction` to remove the specified reaction. In a one-to-one conversation, the peer user receives the `onReactionChanged` event. In a group conversation, other group members than the operator receive this event. This event contains the conversation ID, message ID, reaction list of the message, and reaction operation list (ID of the removed reaction, user ID of the user that removes the reaction, and the removal operation).

    ```javascript
    // Remove the reaction.
    chatClient.deleteReaction({ messageId: "messageId", reaction: "reaction" });
    // Listen for reaction state change.
    chatClient.addEventHandler("handlerId", {
      onReactionChange: (reactionMsg) => {
        console.log(reactionMsg);
      },
    });
    ```

    ### Retrieve a list of reactions [#retrieve-a-list-of-reactions-6]

    Call `getReactionlist` to retrieve a list of reactions of messages from the server. This method also returns the basic information of the reactions, including the content of the reaction, the number of users that added or removed the reaction, and a list of the first three user IDs that added or removed the reaction.

    ```javascript
    chatClient
      .getReactionlist({ chatType: "singleChat", messageId: "messageId" })
      .then((res) => {
        console.log(res);
      });
    ```

    ### Retrieve the details of the reaction [#retrieve-the-details-of-the-reaction-6]

    Call `getReactionDetail` to get the detailed information of the reaction from the server. The detailed information includes the reaction content, the number of users that added or removed the reaction, and the complete list of user IDs that added or removed the reaction.

    ```javascript
    chatClient
      .getReactionDetail({
        messageId: "messageId",
        reaction: "reaction",
        cursor: null,
        pageSize: 20,
      })
      .then((res) => {
        console.log(res);
      });
    ```

    ### Retrieve the reaction in the historical message from the server [#retrieve-the-reaction-in-the-historical-message-from-the-server]

    When calling `getHistoryMessages` to retrieve historical messages from the server, if the message has a reaction attached to it, the retrieved message body also contains the information of the reaction.

    ```javascript
    chatClient
      .getHistoryMessages({
        targetId: "targetId",
        chatType: "groupChat",
        pageSize: 20,
      })
      .then((messages) => {
        console.log(messages);
      });
    ```

    ## Next steps [#next-steps-6]

    Reactions are also supported in the [Chat UIKit](../../get-started-uikit), which contains a wider range of emojis. You can also use the Chat SDK to implement reactions in your project.

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>
</_PlatformTabsGroup>
