将 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 请求中将 AccessSettings
对象纳入 Space
资源中。在该对象中,指定 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-08-04。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[[["\u003cp\u003eThis page guides Google Workspace admins on how to use the Google Chat API to share named spaces with specific users within their organization.\u003c/p\u003e\n"],["\u003cp\u003eTarget audiences are used to control which users can discover and join a space, replacing the need to invite individuals.\u003c/p\u003e\n"],["\u003cp\u003eTo share a space, the \u003ccode\u003eAccessSettings\u003c/code\u003e object in the Chat API request should contain the target audience ID within the \u003ccode\u003eaudience\u003c/code\u003e field.\u003c/p\u003e\n"],["\u003cp\u003ePrerequisites include a Business or Enterprise Google Workspace account with super admin privileges, an available target audience, and user authentication when calling the Chat API.\u003c/p\u003e\n"],["\u003cp\u003eAdmins can get the target audience ID from the Google Admin console under Directory > Target Audiences, then locate it within the URL of the specific target audience page.\u003c/p\u003e\n"]]],["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"],null,["# Make a Google Chat space discoverable to specific users in a Google Workspace organization\n\nThis page explains how to use the Google Chat API to share a Google Chat space\nwith specific users in a Google Workspace organization, so that they can\ndiscover and join the space.\n\nTo specify the users in your organization that can discover and join a space,\nyou create target audiences. A *target audience* is a group of people---such as\nspecific departments or the entire organization---that you can share a\nChat space with, to improve the space's awareness and\nshareability. Target audiences also let you manage and customize space\nmemberships rather than needing to invite individual users to a space. For more\ninformation, see [About target\naudiences](https://support.google.com/a/answer/9934697).\n\nYou can only make named spaces discoverable to target audiences. You can't\nshare other space types, such as direct messages or group conversations, with\ntarget audiences.\n\nPrerequisites\n-------------\n\n- A Business or Enterprise [Google Workspace](https://support.google.com/a/answer/6043576) account with access to [Google Chat](https://workspace.google.com/products/chat/). Your account must have the [super administrator\n role](https://support.google.com/a/answer/2405986?sjid=1448018578843125834-NC#super_admin) for your Google Workspace organization.\n- A target audience that's available for access in Chat. To create a target audience, see [Create a target\n audience](https://support.google.com/a/answer/9935192). To make an existing target audience available to Chat spaces, see [Set up space access for Chat](https://support.google.com/a/answer/12129901).\n- You must call Google Chat API, with [user authentication](/workspace/chat/authenticate-authorize-chat-user).\n\nGet the target audience ID\n--------------------------\n\nTo get the ID of a target audience, do the following:\n\n1. In the Google Admin console, go to\n **Menu menu\n \\\u003e Directory\n \\\u003e Target audiences**.\n\n [Go to Target audiences](https://admin.google.com/ac/targetaudiences)\n2. In the **Target audiences** table, click the **Name** field of the target\n audience.\n\n3. Find the target audience ID in the URL for the page. The URL format is\n `https://admin.google.com/ac/targetaudiences/`\u003cvar translate=\"no\"\u003eTARGET_AUDIENCE_ID\u003c/var\u003e,\n where \u003cvar translate=\"no\"\u003eTARGET_AUDIENCE_ID\u003c/var\u003e is the alphanumeric ID for\n your target audience.\n\nIn the next section, you use the target audience ID to either create a\ndiscoverable space or update an existing space to make it discoverable to the\ntarget audience.\n\nSpecify the target audience in your Chat API request\n----------------------------------------------------\n\nTo create a space for a specific target audience, use the [`create()`](/workspace/chat/api/reference/rest/v1/spaces/create) or\n[`setup()`](/workspace/chat/api/reference/rest/v1/spaces/setup) method on the `Space` resource. To make an existing space\ndiscoverable, use the [`update()`](/workspace/chat/api/reference/rest/v1/spaces/patch) method on the `Space` resource. Because only\nnamed spaces can be shared with target audiences, the space type\n(represented in the `spaceType` field) must be `SPACE`.\n\nTo make a space discoverable to your target audience, include the\n[`AccessSettings`](/workspace/chat/api/reference/rest/v1/spaces#accesssettings)\nobject in the `Space` resource as part of your Chat API request. In\nthe object, specify `audience` field: \n\n \"accessSettings\": {\n \"audience\": \"audiences/\u003cvar translate=\"no\"\u003eTARGET_AUDIENCE_ID\u003c/var\u003e\"\n }\n\nReplace \u003cvar translate=\"no\"\u003eTARGET_AUDIENCE_ID\u003c/var\u003e with the ID of the target\naudience that you obtained in the previous section. To use the default\nChat space share settings for your Google Workspace\norganization, replace with `default`.\n\nFor details on creating or updating spaces using the Chat API, see the\nfollowing guides:\n\n- [Create a space](/workspace/chat/create-spaces)\n- [Set up a space](/workspace/chat/set-up-spaces)\n- [Update a space](/workspace/chat/update-spaces)\n\nRelated topics\n--------------\n\n- [Create a target audience](https://support.google.com/a/answer/9935192)\n- [Set up sharing in Chat](https://support.google.com/a/answer/12129901)\n- [Create spaces with different access levels](https://support.google.com/chat/answer/11971020)"]]