Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Bu kılavuzda, bir mesaja 👍, 🚲 ve 🌞 gibi tepkiler eklemek için Google Chat API'nin Reaction kaynağındaki create() yönteminin nasıl kullanılacağı açıklanmaktadır.
Reaction kaynağı, kullanıcıların bir mesaja tepki vermek için kullanabileceği emojileri (ör. 👍, 🚲 ve 🌞) temsil eder.
Masaüstü uygulaması için
OAuth istemci kimliği kimlik bilgileri oluşturun. Bu kılavuzda yer alan örneği çalıştırmak için kimlik bilgilerini yerel dizininize client_secrets.json adlı bir JSON dosyası olarak kaydedin.
Rehberlik için bu hızlı başlangıç kılavuzundaki ortamınızı kurma adımlarını tamamlayın.
Bir mesaja tepki oluşturmak için isteğinizde aşağıdakileri iletin:
chat.messages.reactions.create, chat.messages.reactions veya chat.messages yetkilendirme kapsamını belirtin.
Tepki verilecek mesajın kaynak adı olarak parent ve unicode alanının bir unicode dizesi ile temsil edilen standart bir emoji olduğu Reaction örneği olarak reaction'i iliştirerek CreateReaction() yöntemini çağırın.
Aşağıdaki örnekte, bir mesaja 😀 emojisiyle tepki verilmektedir:
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);
Bu örneği çalıştırmak için aşağıdakileri değiştirin:
SPACE_NAME: Alanın name kimliği.
Kimliği, ListSpaces() yöntemini çağırarak veya alanın URL'sinden alabilirsiniz.
MESSAGE_NAME: İletinin name kimliği.
Kimliği, Chat API ile mesaj oluşturduktan sonra döndürülen yanıt gövdesinden veya mesaj oluşturulurken mesaja atanan özel addan alabilirsiniz.
Chat API, oluşturulan tepkinin ayrıntılarını içeren bir Reaction örneği döndürür.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-02-14 UTC."],[[["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"]]