พัฒนาด้วย Google Chat
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หน้านี้แสดงภาพรวมของ Google Chat API และแอป Google Chat
ภาพรวม Google Chat API
Chat API ประกอบด้วย
บริการ gRPC หรือทรัพยากรและเมธอด REST
ที่ให้สิทธิ์เข้าถึง Chat ซึ่งรวมถึงพื้นที่ทำงาน สมาชิกในพื้นที่ทำงาน
ข้อความ รีแอ็กชันต่อข้อความ ไฟล์แนบของข้อความ เหตุการณ์ในพื้นที่ทำงาน และสถานะการอ่านของผู้ใช้
แนวคิด
ส่วนต่อไปนี้จะกำหนดบริการ ทรัพยากร และเมธอดสำหรับ
Chat API
- พื้นที่ทำงาน
พื้นที่ทำงานเป็นพื้นที่ที่ผู้คนและแอปสามารถสนทนาและแชร์ไฟล์ได้ พื้นที่ทำงานมีหลายประเภท ข้อความส่วนตัว (DM) คือการสนทนาแบบ 1:1
ระหว่างผู้ใช้ 2 คนหรือผู้ใช้กับแอป Chat ส่วนแชทกลุ่ม
คือการสนทนาระหว่างผู้ใช้ 3 คนขึ้นไปกับ
แอป Chat พื้นที่ทำงานที่มีชื่อเป็นพื้นที่ถาวรที่ผู้ใช้ส่งข้อความ แชร์ไฟล์ และทำงานร่วมกันได้
การอ้างอิงแหล่งข้อมูล:
ดูตัวอย่างการใช้งานได้ที่
- สมาชิก
สมาชิกคือผู้ใช้และแอป Chat ที่เข้าร่วมหรือได้รับเชิญให้เข้าร่วมพื้นที่ทำงาน
การอ้างอิงแหล่งข้อมูล:
ดูตัวอย่างการใช้งานได้ที่
- ข้อความ
ข้อความประกอบด้วย
ข้อความ
และ
การ์ด
ที่โพสต์ในพื้นที่ทำงาน ข้อความสามารถมีไฟล์แนบได้
ผู้ใช้สามารถรีแอ็กต่อข้อความได้โดยการเพิ่มอีโมจิลงในข้อความ
การอ้างอิงแหล่งข้อมูล:
ดูตัวอย่างการใช้งานได้ที่
- รีแอ็กชัน
รีแอ็กชันแสดงถึงอีโมจิที่ผู้คนใช้เพื่อรีแอ็กกับข้อความ เช่น
👍, 🚲 และ 🌞
การอ้างอิงแหล่งข้อมูล:
ดูตัวอย่างการใช้งานได้ที่
- อีโมจิที่กำหนดเอง
อีโมจิที่กำหนดเองแสดงถึงอีโมจิที่กำหนดเองซึ่งสร้างและแชร์ภายใน
องค์กรใน Google Chat คุณสามารถใส่อีโมจิที่กำหนดเองในเนื้อหาของ
ข้อความหรือใช้เพื่อรีแอ็กกับข้อความได้
การอ้างอิงแหล่งข้อมูล:
ดูตัวอย่างการใช้งานได้ที่
- สื่อและไฟล์แนบ
สื่อหมายถึงไฟล์ที่อัปโหลดไปยัง Google Chat เช่น รูปภาพ วิดีโอ และ
เอกสาร
การอ้างอิงแหล่งข้อมูลสื่อ (ไม่พร้อมใช้งานใน RPC)
ไฟล์แนบคืออินสแตนซ์ของสื่อ (ไฟล์) ที่แนบกับข้อความ
การอ้างอิงแหล่งข้อมูล:
ดูตัวอย่างการใช้งานได้ที่
- กิจกรรมใน Space
กิจกรรมในพื้นที่ทำงานแสดงถึงการเปลี่ยนแปลงในพื้นที่ทำงานหรือทรัพยากรย่อย
ซึ่งรวมถึงสมาชิก ข้อความ และรีแอ็กชัน
การอ้างอิงแหล่งข้อมูล:
ดูตัวอย่างการใช้งานได้ที่
- สถานะการอ่านของผู้ใช้
สถานะการอ่านของผู้ใช้คือทรัพยากรแบบ Singleton ที่แสดงรายละเอียดเกี่ยวกับข้อความที่ผู้ใช้ที่ระบุอ่านล่าสุดในพื้นที่ทำงานของ Google Chat หรือเธรดข้อความ
ข้อมูลอ้างอิงทรัพยากรสถานะการอ่านของพื้นที่ทำงาน
การอ้างอิงทรัพยากรสถานะการอ่านของเธรด
ดูตัวอย่างการใช้งานได้ที่
- การตั้งค่าการแจ้งเตือนในพื้นที่ทำงานของผู้ใช้
การตั้งค่าการแจ้งเตือนพื้นที่ทำงานของผู้ใช้เป็นทรัพยากรแบบ Singleton ที่แสดงถึงการตั้งค่าการแจ้งเตือนของผู้ใช้ที่ระบุในพื้นที่ทำงาน Google Chat
การอ้างอิงแหล่งข้อมูล:
การตรวจสอบสิทธิ์
การเรียกใช้ Chat API ต้องมีการตรวจสอบสิทธิ์ เมธอด Chat API แต่ละรายการต้องมีการตรวจสอบสิทธิ์ผู้ใช้
(เพื่อดำเนินการหรือเข้าถึงข้อมูลในนามของผู้ใช้) หรือการตรวจสอบสิทธิ์แอป
(เพื่อดำเนินการหรือเข้าถึงข้อมูลในฐานะแอป Chat) บางวิธีรองรับทั้งการตรวจสอบสิทธิ์ผู้ใช้และการตรวจสอบสิทธิ์แอป
ดูข้อมูลเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์ใน Chat ได้ที่ภาพรวมการตรวจสอบสิทธิ์
ไลบรารีของไคลเอ็นต์
วิธีที่แนะนำสำหรับนักพัฒนาซอฟต์แวร์ส่วนใหญ่ในการเรียกใช้ Google Chat API
คือการใช้
ไลบรารีของไคลเอ็นต์ Cloud
ที่เรารองรับอย่างเป็นทางการสำหรับภาษาที่คุณต้องการ เช่น Python, Java หรือ Node.js
หากคุณเขียนโค้ดด้วย Google Apps Script ให้ใช้
บริการ Chat ขั้นสูง
แทนการติดตั้งไลบรารีของไคลเอ็นต์
สร้างแอปใน Chat
Chat API ช่วยให้คุณสร้างแอป Google Chat ที่นำบริการและทรัพยากรของคุณมาไว้ใน Google Chat ได้โดยตรง
คุณสร้างแอป Chat เพื่อทำสิ่งต่อไปนี้ได้
- ดึงข้อมูลตามการค้นหาข้อความที่มีโครงสร้างหรือข้อความอิสระที่ผู้ใช้ป้อน
- สร้างรายงานเหตุการณ์หรืออาร์ติแฟกต์อื่นๆ โดยใช้ข้อมูลที่ผู้ใช้ให้ไว้
- เพิ่มประสิทธิภาพการทำงานร่วมกันในทีม เช่น การจัด "หน่วยความจำของทีม" หรือการจัดตารางเวลา
ทรัพยากร
คุณออกแบบแอปแชทได้โดยใช้รูปแบบสถาปัตยกรรมที่หลากหลาย ซึ่งรวมถึงรูปแบบต่อไปนี้
- แอปแบบอินเทอร์แอกทีฟ: ตอบสนองต่อการโต้ตอบของผู้ใช้ เช่น การกล่าวถึงด้วย @หรือคำสั่งเครื่องหมายทับ
และแสดงข้อมูลหรือแนะนำผู้ใช้ผ่านเวิร์กโฟลว์ด้วย
การ์ดและกล่องโต้ตอบ
- แอปบรรทัดคำสั่งหรือ Webhook: ส่งข้อความเชิงรุก เช่น การปลุก
หรือการแจ้งเตือน จากระบบอื่นไปยังพื้นที่ทำงาน ผู้ใช้จะโต้ตอบกับแอปประเภทนี้โดยตรงไม่ได้
- แอปที่ขับเคลื่อนด้วยเหตุการณ์: ติดตามและตอบสนองต่อกิจกรรมในพื้นที่ทำงานของ Chat เช่น มีสมาชิกใหม่เข้าร่วม เมื่อมีการตอบสนองต่อ
เหตุการณ์ แอปจะส่งข้อความหรือดำเนินการอื่นได้
โปรดดูรายละเอียดเกี่ยวกับการออกแบบแอป Chat ที่หัวข้อ
เลือกสถาปัตยกรรมแอป Google Chat
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-04 UTC
[null,null,["อัปเดตล่าสุด 2025-08-04 UTC"],[[["\u003cp\u003eGoogle Chat apps integrate services directly into chats, enabling users to access information and take action without leaving the conversation.\u003c/p\u003e\n"],["\u003cp\u003eThese apps support various functionalities, including workflow management, data collection, and interactive elements like dialogs and slash commands.\u003c/p\u003e\n"],["\u003cp\u003eChoose from interactive, non-interactive, or event-driven architectures to build apps that cater to your specific needs and use cases.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Chat apps can be built using various platforms like AppSheet, Google Apps Script, and Dialogflow.\u003c/p\u003e\n"],["\u003cp\u003eAccess to user data beyond basic identity requires authentication and user consent, ensuring privacy and security.\u003c/p\u003e\n"]]],["Google Chat apps integrate services directly into conversations, allowing users to access information and perform actions without leaving the chat. These apps can send text or card messages within spaces or direct messages. They can be interactive, responding to mentions and commands, or non-interactive, sending messages without user interaction. Apps can retrieve information, file tickets, and coordinate team efforts. Developers can build these apps using diverse platforms, manage deployments, and publish them on the Google Workspace Marketplace.\n"],null,["# Develop with Google Chat\n\nThis page provides an overview of the Google Chat API and Google Chat apps.\n\nGoogle Chat API overview\n------------------------\n\nThe Chat API consists of\n[gRPC services or REST resources and methods](https://cloud.google.com/apis/docs/client-libraries-explained)\nthat grant access to Chat, including spaces, space members,\nmessages, message reactions, message attachments, space events, and user read\nstates.\n\n### Concepts\n\nThe following section defines the services, resources, and methods for the\nChat API:\n\n*Spaces*\n\n: *Spaces* are places where people and apps can converse and share files. There\n are several types of spaces. Direct messages (DMs) are 1:1 conversations\n between two users or a user and a Chat app. Group\n chats are conversations between three or more users and\n Chat apps. Named spaces are persistent places where people send\n messages, share files, and collaborate.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.Space)\n - [REST reference](/workspace/chat/api/reference/rest/v1/spaces)\n\n: For example usage, see:\n\n - [Create a space](/workspace/chat/create-spaces)\n - [Set up a space](/workspace/chat/set-up-spaces)\n - [Get a space](/workspace/chat/get-spaces)\n - [List spaces](/workspace/chat/list-spaces)\n - [Update a space](/workspace/chat/update-spaces)\n - [Delete a space](/workspace/chat/delete-spaces)\n - [Find a direct message (DM)](/workspace/chat/find-direct-message-in-spaces)\n\n*Members*\n\n: *Members* are users and Chat apps that have joined or are\n invited to a space.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.Membership)\n - [REST reference](/workspace/chat/api/reference/rest/v1/spaces.members)\n\n: For example usage, see:\n\n - [Create a membership](/workspace/chat/create-members)\n - [Get a membership](/workspace/chat/get-members)\n - [List memberships](/workspace/chat/list-members)\n - [Update a membership](/workspace/chat/update-members)\n - [Delete a membership](/workspace/chat/delete-members)\n\n*Messages*\n\n: *Messages* include\n [text](/workspace/chat/api/reference/rest/v1/spaces.messages)\n and\n [card](/workspace/chat/api/reference/rest/v1/cards)\n communications posted in spaces. Messages can have files attached to them.\n People can react to messages by appending emoji to them.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.Message)\n - [REST reference](/workspace/chat/api/reference/rest/v1/spaces.messages)\n\n: For example usage, see:\n\n - [Create a message](/workspace/chat/create-messages)\n - [Get a message](/workspace/chat/get-messages)\n - [List messages](/workspace/chat/list-messages)\n - [Update a message](/workspace/chat/update-messages)\n - [Delete a message](/workspace/chat/delete-messages)\n\n*Reactions*\n\n: *Reactions* represent the emoji people use to react to a message, such as\n 👍, 🚲, and 🌞.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.Reaction)\n - [REST reference](/workspace/chat/api/reference/rest/v1/spaces.messages.reactions)\n\n: For example usage, see:\n\n - [Create a reaction](/workspace/chat/create-reactions)\n - [List reactions](/workspace/chat/list-reactions)\n - [Delete a reaction](/workspace/chat/delete-reactions)\n\n*Custom emoji*\n\n: *Custom emoji* represent custom emoji created and shared within the\n organization in Google Chat. Custom emoji can be included in the content of\n a message or used to react to a message.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.CustomEmoji)\n - [REST reference](/workspace/chat/api/reference/rest/v1/customEmojis)\n\n: For example usage, see:\n\n - [Create a custom emoji](/workspace/chat/create-custom-emoji)\n - [Delete a custom emoji](/workspace/chat/delete-custom-emoji)\n - [Get details about a custom emoji](/workspace/chat/get-custom-emoji)\n - [List custom emojis in an organization](/workspace/chat/list-custom-emojis)\n\n*Media and attachments*\n\n: *Media* represents a file uploaded to Google Chat, like images, videos, and\n documents.\n\n: Media resource reference (Unavailable in RPC):\n\n - [REST reference](/workspace/chat/api/reference/rest/v1/media)\n\n: *Attachments* are instances of media (files) attached to messages.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.Attachment)\n - [REST reference](/workspace/chat/api/reference/rest/v1/spaces.messages.attachments)\n\n: For example usage, see:\n\n - [Upload media as an attachment](/workspace/chat/upload-media-attachments)\n - [Download media as an attachment](/workspace/chat/download-media-attachments)\n - [Get an attachment](/workspace/chat/get-media-attachments)\n\n*Space events*\n\n: *Space events* represent changes to a space or its\n child resources, including its members, messages, and reactions.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.SpaceEvent)\n - [REST reference](/workspace/chat/api/reference/rest/v1/spaces.spaceEvents)\n\n: For example usage, see:\n\n - [Get space read state](/workspace/chat/get-space-read-state)\n - [Update space read state](/workspace/chat/update-space-read-state)\n - [Get thread read state](/workspace/chat/get-thread-read-state)\n\n*User read states*\n\n: *User read states* are singleton resources that represent details about a\n specified user's last read message in a Google Chat space or a message\n thread.\n\n: Space read state resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.SpaceReadState)\n - [REST reference](/workspace/chat/api/reference/rest/v1/users.spaces)\n\n: Thread read state resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ThreadReadState)\n - [REST reference](/workspace/chat/api/reference/rest/v1/users.spaces.threads)\n\n: For example usage, see:\n\n - [Get space read state](/workspace/chat/get-space-read-state)\n - [Update space read state](/workspace/chat/update-space-read-state)\n - [Get thread read state](/workspace/chat/get-thread-read-state)\n\n*User space notification settings*\n\n: *User space notification settings* are singleton resources that represent a\n specified user notification settings in a Google Chat space.\n\n: Resource reference:\n\n - [RPC reference](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.SpaceNotificationSetting)\n - [REST reference](/workspace/chat/api/reference/rest/v1/users.spaces.spaceNotificationSetting)\n\n### Authentication\n\nCalling the Chat API requires authentication. Each\nChat API method requires either\n[user authentication](/workspace/chat/authenticate-authorize-chat-user)\n(to perform actions or access\ndata on behalf of a user) or\n[app authentication](/workspace/chat/authenticate-authorize-chat-app)\n(to perform actions or access data as a Chat app). Some\nmethods support both user authentication and app authentication.\n\nTo learn more about authentication in Chat, see\n[Authentication overview](/workspace/chat/authenticate-authorize).\n\n### Client libraries\n\nThe recommended way for most developers to call the Google Chat API\nis with our officially supported\n[Cloud Client Libraries](/workspace/chat/libraries)\nfor your preferred language, like Python, Java, or Node.js.\n\nIf you're coding with Google Apps Script, use the\n[Advanced Chat service](/apps-script/advanced/chat)\ninstead of installing a client library.\n\nBuild Chat apps\n---------------\n\nThe Chat API lets you build Google Chat apps that bring your\nservices and resources right into Google Chat. You can build\nChat apps to do any of the following:\n\n- Retrieve information based on structured or free text queries entered by the user.\n- Generate incident reports or other artifacts, using information provided by the user.\n- Enhance team collaboration, such as providing \"team memory\" or scheduling resources.\n\nYou can design your Chat app using several different\narchitecture styles, including the following:\n\n- **Interactive apps**: Respond to user interaction, such as @mentions or slash commands, and present information or guide users through a workflow with cards and dialogs.\n- **Command-line apps or webhooks**: Send proactive messages, such as alarms or notifications, from another system into a space. Users can't directly interact with this type of app.\n- **Event-driven apps**: Subscribe to and react to activity in a Chat space, such as a new member joining. In response to an event, the app can send a message or perform another action.\n\nFor details about designing your Chat app, see\n[Choose a Google Chat app architecture](/workspace/chat/structure).\n\nRelated topics\n--------------\n\n- [Explore Google Chat app samples](/workspace/chat/samples).\n- [Build interactive Google Chat apps](/workspace/chat/interact-users-overview).\n- [Choose a Google Chat app architecture](/workspace/chat/structure).\n\n|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Want to see the Google Chat API in action? The Google Workspace Developers channel offers videos about tips, tricks, and the latest features. [Subscribe now](https://www.youtube.com/channel/UCUcg6az6etU_gRtZVAhBXaw) |"]]