将 Google Chat 聊天室设为可供 Google Workspace 组织中的特定用户检测到
本页介绍了如何使用 Google Chat API 与 Google Workspace 组织中的特定用户共享 Google Chat 聊天室,以便他们可以发现并加入聊天室。
若要指定贵组织中可以发现和加入聊天室的用户,您需要创建目标对象群组。目标对象群组是指您可以与之共享 Chat 聊天室的一组人员(例如特定部门或整个组织),以提高聊天室的认知度和分享度。借助目标受众群体,您还可以管理和自定义聊天室会员资格,而无需邀请个别用户加入聊天室。如需了解详情,请参阅目标受众群体简介。
您只能向目标对象群组公开命名聊天室。您无法与目标对象群组分享其他类型的聊天室,例如私信或群组对话。
前提条件
获取目标对象群组 ID
如需获取目标受众群体的 ID,请执行以下操作:
在 Google 管理控制台中,依次点击菜单 menu
> 目录
> 目标对象群组。
前往“目标对象群组”页面
在目标对象群组表中,点击目标对象群组的名称字段。
在网页的网址中找到目标受众群体 ID。网址格式为 https://admin.google.com/ac/targetaudiences/TARGET_AUDIENCE_ID
,其中 TARGET_AUDIENCE_ID
是目标受众群体的字母数字 ID。
在下一部分中,您将使用目标受众群体 ID 创建可被发现的聊天室,或更新现有聊天室以使其可供目标受众群体发现。
在 Chat API 请求中指定目标受众群体
如需为特定目标受众群体创建聊天室,请对 Space
资源使用 create()
或 setup()
方法。如需使现有聊天室可供发现,请对 Space
资源使用 update()
方法。由于只有命名聊天室可以与目标受众群体共享,因此聊天室类型(在 spaceType
字段中表示)必须为 SPACE
。
如需让聊天室对目标对象群组可供搜索,请在 Chat API 请求的 Space
资源中添加 AccessSettings
对象。在该对象中,指定 audience
字段:
"accessSettings": {
"audience": "audiences/TARGET_AUDIENCE_ID"
}
将 TARGET_AUDIENCE_ID
替换为您在上一部分中获取的目标受众群体的 ID。如需使用 Google Workspace 组织的默认 Chat 聊天室共享设置,请将其替换为 default
。
如需详细了解如何使用 Chat API 创建或更新聊天室,请参阅以下指南:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-16。
[null,null,["最后更新时间 (UTC):2025-02-16。"],[[["This page guides Google Workspace admins on how to use the Google Chat API to share named spaces with specific users within their organization."],["Target audiences are used to control which users can discover and join a space, replacing the need to invite individuals."],["To share a space, the `AccessSettings` object in the Chat API request should contain the target audience ID within the `audience` field."],["Prerequisites include a Business or Enterprise Google Workspace account with super admin privileges, an available target audience, and user authentication when calling the Chat API."],["Admins can get the target audience ID from the Google Admin console under Directory \u003e Target Audiences, then locate it within the URL of the specific target audience page."]]],["The core content details sharing Google Chat spaces with specific users within a Google Workspace organization using the Google Chat API. It focuses on creating or updating spaces to be discoverable to target audiences—groups of users like departments or the entire organization. To achieve this, users must obtain a target audience ID from the Google Admin console and include it in the API request's `AccessSettings` object when creating or updating a named space. This makes the space discoverable and allows customized memberships.\n"]]