This guide explains how to use the
delete()
method on the Reaction
resource of the Google Chat API to delete a reaction from
a message—like 👍, 🚲, and 🌞. Deleting a reaction doesn't delete the message.
The
Reaction
resource
represents an emoji that people can use to react to a message, such as 👍, 🚲,
and 🌞.
Prerequisites
Node.js
- A Business or Enterprise Google Workspace account with access to Google 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
client_secrets.json
to your local directory.
- Choose an authorization scope that supports user authentication.
Delete a reaction
To delete a reaction from a message, pass the following in your request:
- Specify the
chat.messages.reactions
or thechat.messages
authorization scope. - Call the
DeleteReaction()
method, passing thename
as the resource name of the reaction to delete.
The following example deletes the 😀 reaction from a 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 the custom name assigned to the message at creation.REACTION_NAME
: the ID from the reaction'sname
. You can obtain the ID by calling theListReactions()
method, or from the response body returned after creating a reaction asynchronously with the Chat API.
If successful, the response body is empty, which indicates that the reaction is deleted.