किसी मैसेज पर मिलने वाली प्रतिक्रियाओं की सूची बनाना

इस गाइड में, Google Chat API के Reaction संसाधन पर list() के तरीके का इस्तेमाल करके, किसी मैसेज पर प्रतिक्रियाओं की सूची बनाने का तरीका बताया गया है. जैसे, 👍, 🚲, और 🌞.

Reaction रिसॉर्स, किसी इमोजी को दिखाता है. इसका इस्तेमाल करके, लोग किसी मैसेज पर प्रतिक्रिया दे सकते हैं. जैसे, 👍, 🚲, और 🌞.

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

Node.js

  • आपके पास Google Chat का ऐक्सेस हो और आपके पास Google Workspace का Business या Enterprise वर्शन वाला खाता हो.

प्रतिक्रियाओं की सूची

किसी मैसेज पर मिले प्रतिक्रियाओं की सूची देखने के लिए, अपने अनुरोध में यह जानकारी दें:

  • अनुमति का स्कोप chat.messages.reactions.readonly, chat.messages.reactions, chat.messages.readonly या chat.messages डालें.
  • मैसेज के संसाधन के नाम के तौर पर parent को पास करके, ListReactions() वाला तरीका कॉल करें.

इस उदाहरण में, किसी मैसेज पर की गई प्रतिक्रियाओं की सूची दी गई है:

Node.js

chat/client-libraries/cloud/list-reactions-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

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

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

  // Initialize request argument(s)
  const request = {
    // Replace SPACE_NAME and MESSAGE_NAME here.
    parent: 'spaces/SPACE_NAME/messages/MESSAGE_NAME'
  };

  // Make the request
  const pageResult = chatClient.listReactionsAsync(request);

  // Handle the response. Iterating over pageResult will yield results and
  // resolve additional pages automatically.
  for await (const response of pageResult) {
    console.log(response);
  }
}

main().catch(console.error);

इस सैंपल को चलाने के लिए, इन चीज़ों को बदलें:

  • SPACE_NAME: स्पेस के name का आईडी. आईडी पाने के लिए, ListSpaces() तरीका अपनाएं या स्पेस के यूआरएल का इस्तेमाल करें.
  • MESSAGE_NAME: मैसेज के name से मिला आईडी. Chat API का इस्तेमाल करके, एसिंक्रोनस तरीके से मैसेज बनाने के बाद मिले रिस्पॉन्स बॉडी से आईडी हासिल किया जा सकता है. इसके अलावा, मैसेज बनाने के दौरान असाइन किए गए कस्टम नाम से भी आईडी हासिल किया जा सकता है.

Chat API, पेज के हिसाब से प्रतिक्रियाओं की सूची दिखाता है.