Room reactions

Users can send reactions to the entire chat room to show their sentiment as to what is happening. For example, agreeing with the content in a livestream using a thumbs up, or sending a heart when their team scores in a sports game.

Room reactions are ephemeral and not stored or aggregated by Ably. The intention being that they show the overall sentiment of a room at a point in time.

Subscribe to room reactions

Subscribe to room reactions by registering a listener. Use the reactions.subscribe() method in a room to receive reactions:

Room reaction event structure

The following is the structure of a room reaction event:

JSON

The following are the properties of a room reaction:

PropertyDescriptionType
typeThe type reaction of reaction, for example a 'like' or a heart emoji.String
headersOptional headers for adding additional information to a reaction.Object
metadataOptional metadata about the reaction, such as an animation or effect. This information is not read by Ably.Object
createdAtThe time the reaction was sent.Date
clientIdThe client identifier of the user that sent the reaction.String
isSelfWill be true for the user that sent the reaction.Boolean

Unsubscribe from room reactions

Use the unsubscribe() function returned in the subscribe() response to remove a room reaction listener:

Use the reactions.unsubscribeAll() method to remove all room reaction listeners in a room:

JavaScript

Send a room reaction

Use the reactions.send() method to send a room-level reaction. The most common way of using this method is to trigger it whenever a user clicks an emoji button in a room:

Select...