Google Chat 应用示例
本部分提供了一些示例,介绍了如何构建和部署不同类型的 Chat 应用。
借助快速入门教程开始使用
如果您从未构建过 Chat 应用,可以先完成快速入门,然后再开始构建应用。快速入门介绍了如何设置和运行基本示例。如需开始使用 Google Chat API,您可以从以下两种类型的快速入门教程中进行选择:
- API 快速入门:构建一个 Chat 应用,通过调用 Chat API 代表您执行任务(例如发送消息或返回您是成员的聊天室列表),从而设置您的环境。
- 互动式快速入门:配置 Chat API 并创建一个基本 Chat 应用,您可以将其添加到聊天室中并通过该应用发送消息。
API 快速入门
API 快速入门使用用户身份验证来调用 Chat API,这意味着它们会以经过身份验证的 Chat 用户身份执行操作。在这种情况下,快速入门可以帮助您以自己的身份调用 Chat API。与交互式快速入门不同,您无需在 Chat 聊天室中安装 Chat 应用或与其互动。
API 快速入门提供以下语言版本:
对于所有其他编程语言,请查看并安装我们的客户端库,以便开始使用 Chat API。
交互式快速入门
根据您希望采用的构建方式,从以下交互式快速入门教程中进行选择:
完成快速入门后,您可以继续构建,以便您的 Chat 应用能够执行以下操作:
- 使用正斜线命令、对话框、链接预览和其他互动功能回复用户。
- 主动或独立执行任务,例如每当外部服务发生变化时发送消息。如需执行非用户发起的任务,您必须设置应用身份验证,以便 Chat 应用能够进行身份验证并调用 Chat API。如需了解详情,请参阅以 Google Chat 应用身份进行身份验证。
探索更多完整示例
尝试快速入门后,您可以探索使用更多功能和服务的 Chat 应用示例。下表根据聊天应用示例所使用的格式、技术、架构和互动功能对其进行了分类:
- 格式:选段的格式,包括:
- 教程提供从头到尾的分步说明,假定您除了 Google Cloud 项目之外没有任何其他设置。
- Codelabs 是对一个或多个 Google 产品的引导式演示,通常在活动中展示,稍后发布供您在家试用。
- GitHub 代码示例已发布到 Google Chat GitHub 代码库,并附有有关如何使用这些示例的一些基本说明。这些示例通常也用于文档中。
- 技术:示例中使用的 Google Workspace 和 Google Cloud 产品、服务或 API。
- 架构:示例中使用的 Chat 应用架构或服务。
- 查看该示例使用了哪些 Interactive 功能:
- 斜杠命令:响应用户的命令,例如
/about.
- 对话框:在新窗口中打开界面,供用户输入和提交信息。
- 链接预览:将基于卡片的界面附加到包含第三方服务链接的消息中,以便用户预览或更新链接中的信息。
- 首页:在 Chat 应用的消息中显示首页标签页,供用户了解或使用其功能。
- 互动式微件:使用微件提示用户点击或与消息和其他类型的界面(包括按钮、复选框和文本输入)互动。
- 事件:响应 Chat 中的活动,例如聊天室中有新消息或新成员。
示例 |
说明 |
格式 |
技术 |
架构 |
斜杠命令 |
对话框 |
链接预览 |
首页 |
互动微件 |
事件 |
AI 知识助理 |
使用 Gemini 根据 Chat 聊天室中的对话记录回答问题。
|
教程 |

Google Workspace Events API

Google Cloud Functions

Google Cloud Pub/Sub

Google Cloud Eventarc

Google Cloud Vertex AI

Google Gemini

Google Cloud Firestore
|

HTTP (Node.js)
|
block
|
block
|
block
|
block
|
check_circle
|
check_circle
|
Incident Manager |
在 Chat 中响应突发事件,并在 Google 文档中生成 AI 生成的解决方案摘要。
|
教程 |

Admin SDK API

Google 文档

Google Cloud Vertex AI
|

Apps 脚本
|
check_circle
|
check_circle
|
block
|
block
|
check_circle
|
block
|
项目经理 |
帮助用户在 Chat 中创建、更新和完成项目。
|
教程 |

Google Cloud Functions

Google Cloud Pub/Sub

Google Cloud Vertex AI

Google Cloud Firestore
|

HTTP (Node.js)
|
check_circle
|
check_circle
|
block
|
block
|
check_circle
|
block
|
使用 Gemini 构建 Google 应用 |
从 2024 年 Google I/O 大会开始,您可以使用 Gemini 功能构建各种 Chat 应用。
|
Codelab |

Google Cloud Functions

Google Cloud Pub/Sub

Google Cloud Vertex AI

Google Gemini

Google Workspace Events API
|

Apps 脚本

HTTP (Node.js)

Dialogflow CX
|
check_circle
|
check_circle
|
check_circle
|
check_circle
|
check_circle
|
check_circle
|
互动式投票 |
允许用户创建投票活动并显示总投票数。
|
Codelab |

Google Cloud Functions

Google Cloud Shell
|

HTTP (Node.js)
|
check_circle
|
check_circle
|
block
|
block
|
check_circle
|
block
|
联系管理员 |
通过在卡片消息和对话框中收集信息,帮助用户管理其个人和商家联系人。
|
教程 |
|

Apps 脚本
|
check_circle
|
check_circle
|
block
|
block
|
check_circle
|
block
|
会议安排工具 |
在 Chat 聊天室中创建 Google 日历活动。
|
教程 |

Google 日历
|

Apps 脚本
|
check_circle
|
check_circle
|
block
|
block
|
check_circle
|
block
|
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-16。
[null,null,["最后更新时间 (UTC):2025-02-16。"],[[["This section provides resources for building and deploying various Google Chat apps, including quickstarts and more comprehensive samples."],["Quickstarts offer two paths: API quickstarts to programmatically perform actions as a user and interactive quickstarts for building interactive apps within Chat spaces."],["Explore complete samples showcasing a range of features, technologies, and architectures to enhance Chat app functionality."],["Samples are presented as tutorials, codelabs, and GitHub code, enabling developers to learn and build using preferred formats and tools."],["After getting started, developers can further enhance Chat apps with interactive features such as slash commands, dialogs, and link previews, and automate tasks using app authentication."]]],["This document outlines building and deploying Chat apps via quickstarts, categorized as API or interactive. API quickstarts use user authentication to perform actions as the authenticated user, available in Apps Script, Python, Node.js, and Java. Interactive quickstarts offer options like Google Apps Script, HTTP service, Dialogflow CX, Pub/Sub, and AppSheet. After quickstarts, apps can respond to users or perform independent tasks. The document also describes various samples and lists interactive features.\n"]]