تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يوضّح هذا الدليل كيفية استخدام الأسلوب
get()
في مورد Attachment من
Google Chat API للحصول على البيانات الوصفية عن مرفق الرسالة. الردّ هو
مثيل
لموردAttachment.
عندما يرسل المستخدم رسالة إلى تطبيقك، تُرسِل Google Chat
MESSAGE حدث تفاعل.
يتضمّن حدث التفاعل الذي يتلقّاه تطبيقك نص الطلب، وهو ملف حمولة
JSON يمثّل حدث التفاعل، بما في ذلك أي مرفقات. تختلف data في المرفق حسب ما إذا كان المرفق هو محتوى تم تحميله (ملف على الجهاز) أو ملف مخزّن على Drive. يمثّل
مورد Media
ملفًا تم تحميله إلى Google Chat، مثل الصور والفيديوهات والمستندات.
يمثّل
مورد Attachment
مثيلًا للوسائط، وهو ملف مرفق برسالة. يتضمّن Attachment
المورد البيانات الوصفية عن المرفق، مثل
مكان حفظه.
import{createClientWithAppCredentials}from'./authentication-utils.js';// This sample shows how to get attachment metadata with app credentialasyncfunctionmain(){// Create a clientconstchatClient=createClientWithAppCredentials();// Initialize request argument(s)constrequest={// Replace SPACE_NAME, MESSAGE_NAME, and ATTACHMENT_NAME herename:'spaces/SPACE_NAME/messages/MESSAGE_NAME/attachments/ATTACHMENT_NAME'};// Make the requestconstresponse=awaitchatClient.getAttachment(request);// Handle the responseconsole.log(response);}main().catch(console.error);
لتنفيذ هذا المثال، استبدِل spaces/SPACE_NAME/messages/
MESSAGE_NAME/attachments/ATTACHMENT_NAME باسم
مرفق الرسالة.
تُعرِض Chat API مثيلًا من
Attachment
الذي يوضّح البيانات الوصفية حول مرفق الرسالة المحدّد.
تاريخ التعديل الأخير: 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 explains how to retrieve metadata about a message attachment in Google Chat using the `get()` method."],["The `Attachment` resource represents an instance of a file attached to a message and includes metadata like its location."],["To get attachment metadata, you need to use the `chat.bot` authorization scope and call the `GetAttachment()` method with the attachment's name."],["Prerequisites include a Google Workspace account, a Google Cloud project, and Node.js setup with necessary libraries and credentials."]]],["The core actions involve retrieving metadata about a message attachment in Google Chat using the `get()` method. This requires the `chat.bot` authorization scope and calling `GetAttachment()`, providing the attachment's `name`. Before using the `get()` method, you must set up a Google Cloud project, configure the OAuth consent screen, and set up the Google Chat API. The `Attachment` resource represents the file, with metadata detailing its storage. The request triggers a response with `Attachment` details.\n"]]