Get details about a custom emoji

This guide explains how to use the get method on the CustomEmoji resource of the Google Chat API to get details about a custom emoji.

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

Get details about a custom emoji

To get details about a custom emoji with user authentication, pass the following in your request:

  • Specify the chat.customemojis authorization scope.
  • Call the GetCustomEmoji method.
  • In the request body, set name to the resource name of the custom emoji to get.

The following example gets details of a custom emoji.

Node.js

chat/client-libraries/cloud/get-custom-emoji-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.customemojis'];

// This sample shows how to get custom emoji with user credential
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);

  // Initialize request argument(s)
  const request = {
    // TODO(developer): Replace EMOJI_NAME here
    name: 'customEmojis/EMOJI_NAME'
  };

  // Make the request
  const response = await chatClient.getCustomEmoji(request);

  // Handle the response
  console.log(response);
}

main().catch(console.error);

To run this sample, replace the following:

  • EMOJI_NAME: the unique name for your custom emoji, in the emoji_name field. You can obtain the ID by calling the ListCustomEmoji() method, or from the response body returned after creating a custom emoji asynchronously with the Chat API.