Phát triển bằng Google Chat
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trang này cung cấp thông tin tổng quan về Google Chat API và các ứng dụng Google Chat.
Tổng quan về Google Chat API
Chat API bao gồm các dịch vụ gRPC hoặc tài nguyên và phương thức REST cấp quyền truy cập vào Chat, bao gồm cả không gian, thành viên không gian, tin nhắn, lượt thể hiện cảm xúc với tin nhắn, tệp đính kèm tin nhắn, sự kiện không gian và trạng thái đã đọc của người dùng.
Khái niệm
Phần sau đây xác định các dịch vụ, tài nguyên và phương thức cho Chat API:
- Không gian
Không gian là nơi mọi người và ứng dụng có thể trò chuyện và chia sẻ tệp. Có một số loại không gian. Tin nhắn trực tiếp (DM) là cuộc trò chuyện 1:1 giữa hai người dùng hoặc giữa một người dùng và một ứng dụng Chat. Cuộc trò chuyện nhóm là cuộc trò chuyện giữa từ 3 người dùng trở lên và các ứng dụng Chat. Không gian có tên là những nơi ổn định để mọi người gửi tin nhắn, chia sẻ tệp và cộng tác.
Mã tham chiếu tài nguyên:
Để biết ví dụ về cách sử dụng, hãy xem:
- Thành viên
Thành viên là những người dùng và ứng dụng Chat đã tham gia hoặc được mời tham gia một không gian.
Mã tham chiếu tài nguyên:
Để biết ví dụ về cách sử dụng, hãy xem:
- Tin nhắn
Tin nhắn bao gồm văn bản và thông tin liên lạc bằng thẻ được đăng trong không gian. Tin nhắn có thể đính kèm tệp.
Mọi người có thể thể hiện cảm xúc với tin nhắn bằng cách thêm biểu tượng cảm xúc vào tin nhắn.
Mã tham chiếu tài nguyên:
Để biết ví dụ về cách sử dụng, hãy xem:
- Bày tỏ cảm xúc
Phản ứng là những biểu tượng cảm xúc mà mọi người dùng để thể hiện cảm xúc đối với một tin nhắn, chẳng hạn như 👍, 🚲 và 🌞.
Mã tham chiếu tài nguyên:
Để biết ví dụ về cách sử dụng, hãy xem:
- Biểu tượng cảm xúc tuỳ chỉnh
Biểu tượng cảm xúc tuỳ chỉnh là biểu tượng cảm xúc tuỳ chỉnh được tạo và chia sẻ trong tổ chức trên Google Chat. Bạn có thể thêm biểu tượng cảm xúc tuỳ chỉnh vào nội dung của tin nhắn hoặc dùng để thể hiện cảm xúc đối với một tin nhắn.
Mã tham chiếu tài nguyên:
Để biết ví dụ về cách sử dụng, hãy xem:
- Nội dung nghe nhìn và tệp đính kèm
Nội dung nghe nhìn là một tệp được tải lên Google Chat, chẳng hạn như hình ảnh, video và tài liệu.
Tài nguyên tham chiếu nội dung nghe nhìn (Không có trong RPC):
Tệp đính kèm là các phiên bản của nội dung nghe nhìn (tệp) được đính kèm vào tin nhắn.
Mã tham chiếu tài nguyên:
Để biết ví dụ về cách sử dụng, hãy xem:
- Sự kiện trong Space
Sự kiện không gian thể hiện những thay đổi đối với một không gian hoặc các tài nguyên con của không gian đó, bao gồm cả thành viên, tin nhắn và lượt bày tỏ cảm xúc.
Mã tham chiếu tài nguyên:
Để biết ví dụ về cách sử dụng, hãy xem:
- Trạng thái đọc của người dùng
Trạng thái đã đọc của người dùng là tài nguyên singleton thể hiện thông tin chi tiết về tin nhắn đã đọc gần đây nhất của một người dùng cụ thể trong một không gian hoặc chuỗi tin nhắn trên Google Chat.
Tham chiếu tài nguyên trạng thái đọc của không gian:
Tham chiếu tài nguyên trạng thái đọc luồng:
Để biết ví dụ về cách sử dụng, hãy xem:
- Chế độ cài đặt thông báo về không gian của người dùng
Chế độ cài đặt thông báo về không gian của người dùng là các tài nguyên đơn lẻ đại diện cho chế độ cài đặt thông báo của một người dùng cụ thể trong một không gian trên Google Chat.
Mã tham chiếu tài nguyên:
Xác thực
Bạn cần phải xác thực để gọi Chat API. Mỗi phương thức Chat API đều yêu cầu xác thực người dùng (để thực hiện các thao tác hoặc truy cập vào dữ liệu thay mặt cho người dùng) hoặc xác thực ứng dụng (để thực hiện các thao tác hoặc truy cập vào dữ liệu dưới dạng một ứng dụng Chat). Một số phương thức hỗ trợ cả xác thực người dùng và xác thực ứng dụng.
Để tìm hiểu thêm về quy trình xác thực trong Chat, hãy xem bài viết Tổng quan về quy trình xác thực.
Thư viện ứng dụng
Cách mà hầu hết nhà phát triển nên dùng để gọi Google Chat API là sử dụng Thư viện ứng dụng đám mây được chúng tôi hỗ trợ chính thức cho ngôn ngữ mà bạn muốn, chẳng hạn như Python, Java hoặc Node.js.
Nếu bạn đang viết mã bằng Google Apps Script, hãy sử dụng dịch vụ Chat nâng cao thay vì cài đặt một thư viện ứng dụng.
Tạo ứng dụng Chat
API Chat cho phép bạn tạo các ứng dụng Google Chat đưa các dịch vụ và tài nguyên của bạn vào ngay Google Chat. Bạn có thể tạo ứng dụng trò chuyện để thực hiện bất kỳ thao tác nào sau đây:
- Truy xuất thông tin dựa trên các cụm từ tìm kiếm có cấu trúc hoặc văn bản tự do do người dùng nhập.
- Tạo báo cáo sự cố hoặc các hiện vật khác bằng thông tin do người dùng cung cấp.
- Tăng cường khả năng cộng tác trong nhóm, chẳng hạn như cung cấp "bộ nhớ nhóm" hoặc lập lịch tài nguyên.
Bạn có thể thiết kế ứng dụng Chat bằng nhiều kiểu kiến trúc, bao gồm:
- Ứng dụng có tính tương tác: Phản hồi hoạt động tương tác của người dùng, chẳng hạn như @đề cập hoặc lệnh dấu gạch chéo, đồng thời trình bày thông tin hoặc hướng dẫn người dùng thực hiện quy trình bằng thẻ và hộp thoại.
- Ứng dụng dòng lệnh hoặc webhook: Gửi tin nhắn chủ động (chẳng hạn như báo thức hoặc thông báo) từ một hệ thống khác vào một không gian. Người dùng không thể tương tác trực tiếp với loại ứng dụng này.
- Ứng dụng dựa trên sự kiện: Đăng ký và phản ứng với hoạt động trong một không gian Chat, chẳng hạn như khi có thành viên mới tham gia. Để phản hồi một sự kiện, ứng dụng có thể gửi một thông báo hoặc thực hiện một hành động khác.
Để biết thông tin chi tiết về cách thiết kế ứng dụng Chat, hãy xem phần Chọn cấu trúc ứng dụng Google Chat.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-04 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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,["This page provides an overview of the Google Chat API and Google Chat apps.\n\nGoogle Chat API overview \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\nConcepts\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*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\nAuthentication\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\nClient 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\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- [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) |"]]