// Add a reaction. Returns the reaction that was created.
const FReaction Reaction = Channel->SendReaction(Message, TEXT("love"));
// Add a reaction with a score, for cumulative reactions
Channel->SendReaction(Message, TEXT("clap"), 10);
// Replace all existing reactions from this user with the new one
Channel->SendReaction(Message, TEXT("love"), 1, true);
// Custom data on a reaction is not supported by the Unreal SDK. Let us know if you
// need it: https://github.com/GetStream/stream-chat-unreal/issuesReactions
Stream Chat supports message reactions such as likes, hearts, and custom reaction types. Users can react to messages, and reactions can include custom data and scores for cumulative reactions.
Sending a Reaction
Add a reaction to a message using the sendReaction method. Each user can have one reaction of each type per message.
Reaction Parameters
| Name | Type | Description | Default | Optional |
|---|---|---|---|---|
| message_id | string | ID of the message to react to | ||
| type | string | Reaction type. Each user can have one reaction of each type per message. | ||
| score | integer | Score for cumulative reactions | 1 | ✓ |
| user_id | string | User ID (required for server-side calls) | ✓ | |
| enforce_unique | boolean | If true, replaces all existing reactions from this user with the new one | false | ✓ |
| skip_push | boolean | If true, do not send a push notification | false | ✓ |
| emoji_code | string | Unicode emoji for push notification display | ✓ | |
| custom data | object | Custom fields for the reaction | ✓ |
Custom data for reactions is limited to 1KB.
Removing a Reaction
Remove a reaction by specifying the message ID and reaction type.
// DeleteReaction takes the reaction itself rather than its type, so look up this
// user's reaction of that type on the message first.
const TOptional<FReaction> OwnReaction =
Message.Reactions.GetOwnReaction(TEXT("love"), UUserManager::Get());
if (OwnReaction.IsSet())
{
Channel->DeleteReaction(Message, OwnReaction.GetValue());
}Retrieving Reactions
Reactions are included in the message object. Messages returned by the API include the 10 most recent reactions.
Reaction Fields in Messages
| Field | Type | Description |
|---|---|---|
| reaction_counts | object | Count of reactions per type. Example: {"love": 3, "fire": 2} |
| reaction_scores | object | Sum of scores per type. Equals counts for standard reactions; differs for cumulative reactions. |
| reaction_groups | object | Detailed statistics per type including count, sum_scores, first_reaction_at, last_reaction_at |
| latest_reactions | array | The 10 most recent reactions with type, user_id, and created_at |
| own_reactions | array | The current user's reactions on this message |
Use reaction_groups instead of reaction_counts for if you're building a custom implementation. The reaction_groups field provides additional metadata including timestamps and is the recommended approach.
To retrieve more than 10 reactions, use pagination.
Paginating Reactions
Retrieve reactions with pagination using limit and offset parameters.
| Parameter | Maximum Value |
|---|---|
| limit | 300 |
| offset | 1000 |
// Each message already carries a snapshot of its reactions, grouped by type.
for (const TPair<FName, FReactionGroup>& Group : Message.Reactions.GetReactionGroups())
{
const FName Type = Group.Key;
const int32 Count = Group.Value.Count;
const int32 TotalScore = Group.Value.TotalScore;
// The most recent reactions of this type that we hold locally. Note that Count may
// exceed LatestReactions.Num(), which is what pagination below is for.
for (const FReaction& Reaction : Group.Value.LatestReactions)
{
const FString ReactingUserId = Reaction.User->Id;
}
}
// Did the current user react with this type?
const bool bLiked = Message.Reactions.GetOwnReaction(TEXT("love"), UUserManager::Get()).IsSet();
// Get the first 10 reactions from the API
Channel->GetReactions(
Message,
{10}, // FPaginationOptions: Limit, Offset
[](const TArray<FReaction>& Reactions)
{
// Do something with Reactions
});
// Get reactions 11-13
Channel->GetReactions(
Message,
{3, 10},
[](const TArray<FReaction>& Reactions)
{
// Do something with Reactions
});Querying Reactions
Filter reactions by type or user on a specific message. This endpoint requires the user to have read permission on the channel when called client-side.
// Querying reactions with a filter is not yet available in the Unreal SDK.
// Please let us know if you'd like this feature implemented: https://github.com/GetStream/stream-chat-unreal/issues
// Use Channel->GetReactions to page through a message's reactions instead.Cumulative Reactions
Cumulative reactions allow users to react multiple times to the same message, with the total score tracked. This is useful for features like Medium's "clap" functionality.
Set a score value when sending the reaction. The API returns:
sum_scores: Total score across all users- Individual user scores
// User claps 5 times
Channel->SendReaction(Message, TEXT("clap"), 5);
// Same user claps 20 more times (total becomes 25)
Channel->SendReaction(Message, TEXT("clap"), 25);