Mendapatkan detail tentang emoji kustom

Panduan ini menjelaskan cara menggunakan metode get pada resource CustomEmoji Google Chat API untuk mendapatkan detail tentang emoji kustom.

Emoji kustom hanya tersedia untuk akun Google Workspace, dan administrator Anda harus mengaktifkan emoji kustom untuk organisasi Anda. Untuk informasi selengkapnya, lihat Mempelajari emoji kustom di Google Chat dan Mengelola izin emoji kustom.

Prasyarat

Node.js

Mendapatkan detail tentang emoji kustom

Untuk mendapatkan detail tentang emoji kustom dengan autentikasi pengguna, teruskan hal berikut dalam permintaan Anda:

  • Tentukan cakupan otorisasi chat.customemojis.
  • Panggil metode GetCustomEmoji.
  • Dalam isi permintaan, tetapkan name ke nama resource emoji kustom yang akan didapatkan.

Contoh berikut mendapatkan detail emoji kustom.

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);

Untuk menjalankan contoh ini, ganti berikut ini:

  • EMOJI_NAME: nama unik untuk emoji kustom Anda, di kolom emoji_name. Anda bisa mendapatkan ID dengan memanggil metode ListCustomEmoji(), atau dari isi respons yang ditampilkan setelah membuat emoji kustom secara asinkron dengan Chat API.