برای ایجاد واکنش به یک پیام، موارد زیر را در درخواست خود وارد کنید:
محدوده مجوز 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() یا از URL فضا بدست آورید.
MESSAGE_NAME : شناسه از name پیام. می توانید شناسه را از بدنه پاسخی که پس از ایجاد پیام به طور ناهمزمان با Chat API یا با نام سفارشی اختصاص داده شده به پیام در هنگام ایجاد، بازگردانده شده است، دریافت کنید.
Chat API نمونهای از Reaction را برمیگرداند که جزئیات واکنش ایجاد شده را نشان میدهد.
تاریخ آخرین بهروزرسانی 2025-02-14 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-02-14 بهوقت ساعت هماهنگ جهانی."],[[["This guide demonstrates how to add emoji reactions (👍, 🚲, 🌞) to Google Chat messages using the `create()` method of the Google Chat API."],["It requires a Google Workspace account, a configured Google Cloud project with the Chat API enabled, and the Node.js Cloud Client Library."],["To add a reaction, call the `CreateReaction()` method, providing the message's resource name and the desired emoji's unicode representation."],["A sample Node.js code snippet is included, illustrating the process of creating a reaction using user credentials."],["You need to replace placeholders for space and message names within the code with your specific values to execute the sample successfully."]]],["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"]]