List reactions for a message (original) (raw)
This guide explains how to use thelist()method on the Reaction resource of the Google Chat API to list reactions for a messageโlike ๐, ๐ฒ, and ๐.
TheReaction resourcerepresents an emoji that people can use to react to a message, such as ๐, ๐ฒ, and ๐.
Prerequisites
Node.js
- A Business or EnterpriseGoogle Workspace account with access toGoogle Chat.
- Set up your environment:
- Create a Google Cloud project.
- Configure the OAuth consent screen.
- Enable and configure the Google Chat API with a name, icon, and description for your Chat app.
- Install the Node.js Cloud Client Library.
- Create OAuth client ID credentials for a desktop application. To run the sample in this guide, save the credentials as a JSON file named
credentials.jsonto your local directory.
For guidance, complete the steps for setting up your environment in this[quickstart](/workspace/chat/api/guides/quickstart/nodejs
#set-up-environment).
- Choose an authorization scope that supports user authentication.
To list the reactions for a message, pass the following in your request:
- Specify the
chat.messages.reactions.readonly,chat.messages.reactions,chat.messages.readonly, orchat.messagesauthorization scope. - Call theListReactions()method, passing the
parentas the resource name of the message.
The following example lists reactions for a specified message:
Node.js
To run this sample, replace the following:
SPACE_NAME: the ID from the space'sname. You can obtain the ID by calling theListSpaces()method or from the space's URL.MESSAGE_NAME: the ID from the message'sname. You can obtain the ID from the response body returned after creating a message asynchronously with the Chat API, or with thecustom nameassigned to the message at creation.
The Chat API returns apaginated list of reactions.