पसंद के मुताबिक इमोजी बनाना

इस गाइड में, Google Chat API के CustomEmoji संसाधन पर create तरीके का इस्तेमाल करके, Google Workspace संगठन में नई कस्टम इमोजी बनाने का तरीका बताया गया है.

पसंद के मुताबिक बनाए गए इमोजी सिर्फ़ Google Workspace खातों के लिए उपलब्ध हैं. साथ ही, यह ज़रूरी है कि आपके एडमिन ने आपके संगठन के लिए, पसंद के मुताबिक बनाए गए इमोजी की सुविधा चालू की हो. ज़्यादा जानकारी के लिए, Google Chat में पसंद के मुताबिक बनाए गए इमोजी के बारे में जानें और पसंद के मुताबिक बनाए गए इमोजी इस्तेमाल करने की अनुमतियां मैनेज करना लेख पढ़ें.

ज़रूरी शर्तें

Node.js

  • आपके पास Business या Enterprise वर्शन वाला Google Workspace खाता होना चाहिए. साथ ही, आपके पास Google Chat को ऐक्सेस करने की अनुमति होनी चाहिए.

पसंद के मुताबिक इमोजी बनाना

उपयोगकर्ता की पुष्टि करके कस्टम इमोजी बनाने के लिए, अपने अनुरोध में यह जानकारी शामिल करें:

  • chat.customemojis ऑथराइज़ेशन का स्कोप तय करें.
  • CreateCustomEmoji तरीके को कॉल करें.
  • अनुरोध के मुख्य हिस्से में, CustomEmoji रिसॉर्स दें. साथ ही, emojiName (इमोजी के लिए चुना गया यूनीक आइडेंटिफ़ायर) और payload (इमोजी के लिए चुना गया इमेज कॉन्टेंट) सेट करें.

यहां दिए गए उदाहरण में, पसंद के मुताबिक इमोजी बनाने का तरीका बताया गया है:

Node.js

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

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

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

  // TODO(developer) Replace FILENAME here.
  const filename = 'FILENAME'
  // Read Custom emoji file content into base64 encoded string
  const fileContent = fs.readFileSync(filename, {encoding: 'base64'})

  // Initialize request argument(s)
  const request = {
    custom_emoji: {
      // TODO(developer): Replace EMOJI_NAME here.
      emoji_name: "EMOJI_NAME",
      payload: {
        file_content: fileContent,
        filename: filename,
      }
    }
  };

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

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

main().catch(console.error);

इस सैंपल को चलाने के लिए, इन्हें बदलें:

  • FILENAME: इमेज का फ़ाइल नाम.
  • EMOJI_NAME: आपके कस्टम इमोजी का यूनीक नाम, जैसे कि :smiley-face:.

Chat API, CustomEmoji का एक इंस्टेंस दिखाता है. इसमें बनाए गए कस्टम इमोजी के बारे में जानकारी होती है.