संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस गाइड में बताया गया है कि Google Chat API के Reaction रिसॉर्स पर create() तरीके का इस्तेमाल करके, किसी मैसेज पर प्रतिक्रिया कैसे जोड़ी जाती है. जैसे, 👍, 🚲, और 🌞.
Reaction रिसॉर्स, एक इमोजी को दिखाता है. लोग इस इमोजी का इस्तेमाल करके, किसी मैसेज पर प्रतिक्रिया दे सकते हैं. जैसे, 👍, 🚲, और 🌞.
ज़रूरी शर्तें
Node.js
आपके पास Business या Enterprise वर्शन वाला Google Workspace खाता होना चाहिए. साथ ही, आपके पास Google Chat को ऐक्सेस करने की अनुमति होनी चाहिए.
किसी मैसेज पर प्रतिक्रिया देने के लिए, अपने अनुरोध में यह जानकारी शामिल करें:
chat.messages.reactions.create, chat.messages.reactions या chat.messages अनुमति का स्कोप तय करें.
CreateReaction() तरीके को कॉल करें. इसमें parent को उस मैसेज के संसाधन के नाम के तौर पर पास करें जिस पर प्रतिक्रिया देनी है. साथ ही, reaction को Reaction के इंस्टेंस के तौर पर पास करें. इसमें unicode फ़ील्ड, यूनिकोड स्ट्रिंग से दिखाया गया स्टैंडर्ड इमोजी होता है.
यहां दिए गए उदाहरण में, 😀 इमोजी का इस्तेमाल करके किसी मैसेज पर प्रतिक्रिया दी गई है:
import{createClientWithUserCredentials}from'./authentication-utils.js';constUSER_AUTH_OAUTH_SCOPES=['https://www.googleapis.com/auth/chat.messages.reactions.create'];// This sample shows how to create reaction to a message with user credentialasyncfunctionmain(){// Create a clientconstchatClient=awaitcreateClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);// Initialize request argument(s)constrequest={// Replace SPACE_NAME and MESSAGE_NAME here.parent:'spaces/SPACE_NAME/messages/MESSAGE_NAME',reaction:{// A standard emoji represented by a unicode string.emoji:{unicode:'😀'},},};// Make the requestconstresponse=awaitchatClient.createReaction(request);// Handle the responseconsole.log(response);}main().catch(console.error);
इस सैंपल को चलाने के लिए, इन्हें बदलें:
SPACE_NAME: स्पेस के name का आईडी.
आईडी पाने के लिए, ListSpaces() तरीके का इस्तेमाल करें या स्पेस के यूआरएल से आईडी पाएं.
MESSAGE_NAME: मैसेज के name से मिला आईडी.
Chat API की मदद से एसिंक्रोनस तरीके से मैसेज बनाने के बाद, आपको जवाब के मुख्य हिस्से से आईडी मिल सकता है. इसके अलावा, मैसेज बनाते समय असाइन किए गए कस्टम नाम से भी आईडी मिल सकता है.
Chat API, Reaction का एक इंस्टेंस दिखाता है. इसमें बनाई गई प्रतिक्रिया के बारे में जानकारी होती है.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-09-10 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThis guide demonstrates how to add emoji reactions (👍, 🚲, 🌞) to Google Chat messages using the \u003ccode\u003ecreate()\u003c/code\u003e method of the Google Chat API.\u003c/p\u003e\n"],["\u003cp\u003eIt requires a Google Workspace account, a configured Google Cloud project with the Chat API enabled, and the Node.js Cloud Client Library.\u003c/p\u003e\n"],["\u003cp\u003eTo add a reaction, call the \u003ccode\u003eCreateReaction()\u003c/code\u003e method, providing the message's resource name and the desired emoji's unicode representation.\u003c/p\u003e\n"],["\u003cp\u003eA sample Node.js code snippet is included, illustrating the process of creating a reaction using user credentials.\u003c/p\u003e\n"],["\u003cp\u003eYou need to replace placeholders for space and message names within the code with your specific values to execute the sample successfully.\u003c/p\u003e\n"]]],["To add a reaction to a message using the Google Chat API, utilize the `CreateReaction()` method. Specify the message's resource name as the `parent` and provide a `Reaction` instance with a Unicode emoji string in the `unicode` field. Ensure you have the `chat.messages.reactions.create`, `chat.messages.reactions`, or `chat.messages` authorization scope. You must have a Google Workspace account, a configured Google Cloud project, and have set up the Node.js environment, including OAuth client ID credentials. The API returns the created `Reaction` details.\n"],null,[]]