# Users - Chat - [Introduction](#introduction) - [Set up a Chat Bot](#set-up-a-chat-bot) - [API documentation](#api-documentation) - [Query Documentation](#query-documentation) - [Definitions](#definitions) - [Chat Space Permissions](#chat-space-permissions) - [Manage Chat Spaces](#manage-chat-spaces) - [Display Chat Spaces](#display-chat-spaces) - [Manage Chat Members](#manage-chat-members) - [Display Chat Members](#display-chat-members) - [Manage Chat Messages](#manage-chat-messages) - [Display Chat Messages](#display-chat-messages) - [Display Chat Events](#display-chat-events) - [Bulk Operations](#bulk-operations) ## Introduction These features were added in version 6.60.00. To use these commands you must update your service account authorization. ``` gam user user@domain.com update serviceaccount [*] 4) Chat API - Memberships (supports readonly) [*] 5) Chat API - Memberships Admin (supports readonly) [*] 6) Chat API - Messages (supports readonly) [*] 7) Chat API - Spaces (supports readonly) [*] 8) Chat API - Spaces Admin (supports readonly) [*] 9) Chat API - Spaces Delete [*] 10) Chat API - Spaces Delete Admin ``` Added `use_chat_admin_access` Boolean variable to `gam.cfg`. ``` * When False, GAM uses user access when making all Chat API calls. For calls that support admin access, this can be overridden with the asadmin command line option. * When True, GAM uses admin access for Chat API calls that support admin access; other calls will use user access. * Default: False ``` Google requires that you have a Chat Bot configured in order to use the Chat API; set up a Chat Bot as described in the next section. ## Set up a Chat Bot * Run the command `gam setup chat`; it will point you to a URL to configure your Chat Bot. * Enter an App name and Description of your choosing. * For the Avatar URL you can use `https://dummyimage.com/384x256/4d4d4d/0011ff.png&text=+GAM` or a public URL to an image of your own choosing. * In Functionality, uncheck both "Receive 1:1 messages" and "Join spaces and group conversations" * In Connection settings, choose "Cloud Pub/Sub" and enter `projects//topics/no-topic` for the topic name. Replace `` with your GAM project ID. GAM doesn't yet listen to pub/sub so this option is not used. * In Visibility, uncheck "Make this Chat app available to specific people and groups in Domain Workspace". * Click Save. ## API documentation * [Overview](https://developers.google.com/workspace/chat/overview) * [Chat API](https://developers.google.com/workspace/chat/api/reference/rest) * [Chat API - Members](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.members/list) * [Chat API - Messages](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/list) * [Chat API - Events](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents/list) * [Apps in Google Chat](https://support.google.com/chat/answer/7655820) * [Manage Spaces in Admin Console](https://support.google.com/a/answer/13369245) * [Predefined permission settings](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#Space.FIELDS.predefined_permission_settings) ## Query documentation * [Search Spaces](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search) ## Definitions * [``](Collections-of-Users) * [Drive File Selection](Drive-File-Selection) for symbols not listed here, such as `` * [Command data from Google Docs/Sheets/Storage](Command-Data-From-Google-Docs-Sheets-Storage) ``` ::= ::= ::= https://storage.cloud.google.com//| https://storage.googleapis.com//| gs:///| / ::= ||( ) ::= ((text )| (textfile [charset ])| (gdoc )| (gcsdoc )) ::= spaces//spaceEvents/ ::= spaces//members/ ::= "(,)*" ::= spaces//messages/ ::= spaces/ | space | space spaces/ ::= spaces//threads/ ::= space| groupchat| directmessage ::= "(,)*" ::= client- must contain only lowercase letters, numbers, and hyphens up to 56 characters in length. ``` ``` ::= accesssettings| admininstalled| createtime| displayname| externaluserallowed| importmode| lastactivetime| membershipcount| name| permissionsettings| singleuserbotdm| spacedetails| spacehistorystate| spacethreadingstate|threaded| spacetype|type| spaceuri ::= "(,)*" ::= createtime| deletetime| groupmember| member| name| role| state| ::= "(,)*" ::= accessorywidgets| actionresponse| annotations| argumenttext| attachedgifs| attachment| cards| cardsv2| clientassignedmessageid| createtime| deletetime| deletionmetadata| emojireactionsummaries| fallbacktext| formattedtext| lastupdatetime| matchedurl| name| privatemessageviewer| quotedmessagemetadata| sender| slashcommand| space| text| thread| threadreply ::= "(,)*" ``` ## Chat Space Permissions ### Announcement | Keyword | Description | Allowed | Default | |---------|-------------|---------|---------| | manageapps | Manage apps | managers-immutable | managers | | managemembersandgroups | Manage members and groups | managers/members | managers | | managewebhooks | Manage web hooks | managers-immutable | managers | | modifyspacedetails | Modify space details | managers/members | managers | | postmessages | Post messages | managers-immutable | managers | | replymessages | Reply messages | members/managers | members | | togglehistory | Turn history on and off | managers/members | managers | | useatmentionall | Use @all | managers-immutable | managers | ### Collaboration | Keyword | Description | Allowed | Default | |---------|-------------|---------|---------| | manageapps | Manage apps | members-immutable | members | | managemembersandgroups | Manage members and groups | managers/members | members | | managewebhooks | Manage web hooks | managers/members | members | | modifyspacedetails | Modify space details | managers/members | members | | postmessages | Post messages | members-immutable | members | | replymessages | Reply messages | members-immutable | members | | togglehistory | Turn history on and off | managers/members | members | | useatmentionall | Use @all | managers/members | members | ## Manage Chat Spaces ### Create a chat space ``` gam create chatspace [type ] [announcement|collaboration] [restricted|(audience )] [externalusersallowed ] [members ] [displayname ] [description ] [guidelines ] [history ] [] [formatjson|returnidonly] ``` For `type space`, the following apply: * `members ` - Optional, can not specify more that 20 users * `displayname ` - Required * `description ` - Optional * `guidelines ` - Optional * `history ` - Optional * `announcement|collaboration` - Initial permission settings; default is `collaboration`; this is in Developer Preview For `type groupchat`, the following apply: * `members ` - Required, must specify between 2 and 20 users * `displayname ` - Ignored * `description ` - Optional * `guidelines ` - Optional * `history ` - Optional For `type directmessage`, the following apply: * `members ` - Required, must specify 1 user * `displayname ` - Ignored * `description ` - Ignored * `guidelines ` - Ignored * `history ` - Optional By default, Gam displays the information about the created chatspace as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. * `returnidonly` - Display the chatspace name only Use the `` option to send an initial message to the created chatspace. By default, details about the chatmessage are displayed. * `returnidonly` - Display the chatmessage name only ### Update a user's chat space ``` gam update chatspace [restricted|(audience )]| ([displayname ] [type space] [description ] [guidelines|rules ] [history ]) [managemembersandgroups managers|members] [modifyspacedetails managers|members] [togglehistory managers|members] [useatmentionall managers|members] [manageapps managers|members] [managewebhooks managers|members] [replymessages managers|members] [formatjson] ``` A groupchat space can be upgraded to a space by specifying `type space` and `displayname `. The `restricted|audience` options can not be combined with options `displayname,type,description,guidelines,history`. You can manage permissions for chat spaces with the following options that are available with Developer Preview. [managemembersandgroups managers|members] [modifyspacedetails managers|members] [togglehistory managers|members] [useatmentionall managers|members] [manageapps managers|members] [managewebhooks managers|members] [postmessages managers|members] [replymessages managers|members] By default, Gam displays the information about the created chatspace as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ### Update a chat space, asadmin ``` gam update chatspace asadmin [restricted|(audience )]| ([displayname ] [type space] [description ] [guidelines|rules ] [history ]) [formatjson] ``` A groupchat space can be upgraded to a space by specifying `type space` and `displayname `. The `restricted|audience` options can not be combined with options `displayname,type,description,guidelines,history`. By default, Gam displays the information about the created chatspace as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ### Delete a user's chat space ``` gam delete chatspace ``` ### Delete a chat space, asadmin ``` gam delete chatspace asadmin ``` ## Display Chat Spaces ### Display information about a specific chat space for a user ``` gam info chatspace [fields ] [formatjson] ``` By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ### Display information about a direct message chat space between two users ``` gam info chatspacedm [fields ] [formatjson] ``` By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ### Display information about all chat spaces for a user ``` gam show chatspaces [types ] [fields ] [formatjson] ``` By default, chat spaces of all types are displayed. * `types ` - Display specific types of spaces. By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ``` gam print chatspaces [todrive *] [types ] [fields ] [formatjson [quotechar ]] ``` By default, chat spaces of all types are displayed. * `types ` - Display specific types of spaces. By default, Gam displays the information as columns of fields; the following option causes the output to be in JSON format, * `formatjson` - Display the fields in JSON format. By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. When using the `formatjson` option, double quotes are used extensively in the data resulting in hard to read/process output. The `quotechar ` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. `quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used. ### Display information about all user's chat spaces ``` # Local file gam config auto_batch_min 1 redirect csv ./AllChatSpaces.csv multiprocess redirect stdout - multiprocess redirect stderr stdout all users print chatspaces # Google sheet gam config auto_batch_min 1 redirect csv - todrive * multiprocess redirect stdout - multiprocess redirect stderr stdout all users print chatspaces ``` Add these options as desired: ``` [types ] [formatjson [quotechar ]] ``` By default, Gam displays the information as columns of fields; the following option causes the output to be in JSON format, * `formatjson` - Display the fields in JSON format. By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. When using the `formatjson` option, double quotes are used extensively in the data resulting in hard to read/process output. The `quotechar ` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. `quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used. ### Display information about a specific chat space, asadmin ``` gam info chatspace asadmin [fields ] [formatjson] ``` By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ### Display information about all chat spaces, asadmin For query and orderby information, see: https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search Only spaces of `` `space` are displayed; spaces of `` `groupchat` and `directmessage` are not displayed. ``` gam show chatspaces asadmin [query ] [querytime