This guide explains how to use the
create
method on the CustomEmoji
resource of the Google Chat API to create a new
custom emoji in a Google Workspace organization.
Custom emojis are only available for Google Workspace accounts, and your administrator must turn custom emoji on for your organization. For more information, see Learn about custom emoji in Google Chat and Manage custom emoji permissions.
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
credentials.json
to your local directory.
- Choose an authorization scope that supports user authentication.
Create a custom emoji
To create a custom emoji with user authentication, pass the following in your request:
- Specify the
chat.customemojis
authorization scope. - Call the
CreateCustomEmoji
method. - In the request body, provide a
CustomEmoji
resource, setting theemojiName
(a unique identifier you choose for the emoji) andpayload
(image content you choose for the emoji).
The following example creates a custom emoji:
Node.js
To run this sample, replace the following:
FILENAME
: A filename of the image.EMOJI_NAME
: A unique name for your custom emoji, like:smiley-face:
.
The Chat API returns an instance of
CustomEmoji
that details the custom emoji that was created.