> Documentation index: https://developers.google.com/workspace/chat/llms.txt

# Configure the Google Chat API

Each Google Chat app that you create requires its own
Google Cloud project with the Chat API enabled and configured.

To perform read-only API calls with
[user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user.md.txt), like
getting spaces and listing messages, you only need to
[enable the API](https://developers.google.com/workspace/guides/enable-apis.md.txt) and
[create an OAuth client](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user.md.txt#step-2:).

To perform create, update, and delete API calls, or to deploy and test an
interactive Chat app (built as a
Google Workspace add-on that extends Chat), you must also
configure the Chat API. The Chat API configuration settings
are where you specify all the details about the
Chat app, including its display name, avatar,
deployment endpoints, and interactive features.

## Prerequisites

- 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/).
- [Create a Google Cloud project](https://developers.google.com/workspace/guides/create-project.md.txt).
- [Configure the OAuth consent screen](https://developers.google.com/workspace/guides/configure-oauth-consent.md.txt).
- [Enable the Google Chat API](https://developers.google.com/workspace/guides/enable-apis.md.txt).

## Choose a display name, avatar, and description for your Chat app

When you enable the Chat API, you configure the details about your
Chat app that appear to users in Chat,
including a display name, avatar, and description. These details only appear
in Chat. To publish your Chat app to the
Marketplace, you must also specify the details that
appear in your Chat app's
[Marketplace listing](https://developers.google.com/workspace/marketplace/create-listing.md.txt).

Before you configure a Chat app, prepare the following
information:

| Field | Description | Format |
|---|---|---|
| App name | The display name for the Chat app. | Up to 25 alphanumeric characters |
| Avatar URL | The image that displays as your Chat app's avatar. | An HTTPS URL pointing to a square graphics image (PNG or JPEG). Recommended size is 256 by 256 pixels or more. |
| Description | A short description of the Chat app, displayed when users search for apps in Chat. | Up to 40 alphanumeric characters |
| Long description | Optional. A description of what the Chat app can do, displayed when users start a conversation with the Chat app or open the [sessions](https://developers.google.com/workspace/chat/sessions.md.txt) home page for an agent. Currently only supported when updating the app configuration using the Google Cloud console and not supported through the Google Workspace add-ons API. | Up to 250 characters |

The Chat app's name, avatar, and description are
displayed to users in the Chat UI. For some Chat API
write requests, Chat uses this information to attribute the
actions that a Chat app takes in Chat.

For example, if you call the `spaces.create()` method, Chat
includes the name of the Chat app in the
description of who created the space, as shown in the following image:
![Google Chat app creates a space for a user.](https://developers.google.com/static/workspace/chat/images/auth-user-create-space.png) **Figure 1** . The attribution message that Chat displays when the `spaces.create()` method is used to create a space on behalf of a user.

![](https://developers.google.com/static/workspace/chat/images/auth-user-create-space.png)

To interact with Chat apps, users also see or use this
information in the following ways:

- @mention the Chat app to add it to a space or send it a message.
- Find and start a direct message with the Chat app. In the **Apps** menu, direct messages display the Chat app's name and avatar.
- From the compose bar, users can browse Chat apps and see their name, avatar, and description.

## Configure your Chat app in the Google Cloud console

When you have your Chat app details, open your
Cloud project and configure the Chat API:

1. In the Google Cloud console, go to the Chat API page and click the
   **Configuration** page:

   [Go to the Chat API Configuration page](https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat)
2. Under **Application info** , fill out the **App name** , **Avatar URL** ,
   and **Description** fields.

3. Optional: Fill in the **Long description** field.

4. Optional: From the **Markup syntax** menu, select the default markup syntax
   (**Markdown** or **Chat** ) for your Chat app's
   messages. To learn more about text formatting and how Chat
   determines the markup syntax for API requests, see
   [Format messages](https://developers.google.com/workspace/chat/format-messages.md.txt#format-texts).

5. Under **Interactive features**, configure whether your
   Chat app responds to user interactions:

   > [!NOTE]
   > **Note:** If your Chat app only calls the Chat API and doesn't receive or respond to user interactions, leave **Enable interactive features** turned off and skip to the next step.

   To build an interactive Chat app, turn on
   **Enable interactive features** and complete the following:
   1. Under **Functionality** :
      - Optional: Select **Support App Home** to display a [homepage card](https://developers.google.com/workspace/chat/send-app-home-card-message.md.txt) in the **Home** tab of 1:1 direct messages with the Chat app.
      - Select **Join spaces and group conversations** to make your Chat app available to install and use. By default, users can install and message with the Chat app in a dedicated space between the user and Chat app. Users can also add and interact with the Chat app in spaces with multiple people.
   2. Under **Connection settings** , select the architecture that you want to
      use to receive
      [event objects from Chat](https://developers.google.com/workspace/chat/receive-respond-interactions.md.txt#event-objects):

      - To use an HTTP service, select **HTTP endpoint URL** and provide a URL.
      - To use a Google Apps Script project, select **Apps Script** and provide a [deployment ID](https://developers.google.com/apps-script/concepts/deployments.md.txt) for the project.
      - To use a Dialogflow agent, select **Dialogflow** , select **Dialogflow CX** or **Dialogflow ES**, and provide the agent's resource name.
      - To use Pub/Sub, select **Cloud Pub/Sub** and enter the topic name.

      > [!WARNING]
      > **Warning:** If an Apps Script deployment ID is already populated, the Cloud project is connected to an existing Google Workspace add-on. If you update the deployment ID in the Chat API, the deployment ID is updated for your add-on and could affect your listing in the Google Workspace Marketplace. To review your add-on configuration, see [Configure your app in the Google Workspace Marketplace SDK](https://developers.google.com/workspace/marketplace/enable-configure-sdk.md.txt).

   3. Optional: To route event objects to specific endpoints or functions, go
      to **Connection settings** \>
      **Triggers** and provide or update the callback endpoints or functions
      for the following
      [Chat triggers](https://developers.google.com/workspace/chat/receive-respond-interactions.md.txt#triggers):

      > [!NOTE]
      > **Note:** For Apps Script, if you don't update the triggers, you must implement the default callback functions that are populated in this section (such as `onMessage`, `onAddedToSpace`, `onRemovedFromSpace`, `onAppCommand`, and `onAppHome`).

      - **App home** (if **Support App Home** is enabled): A user opens the **Home** tab in a 1:1 direct message with the Chat app.
      - **Added to space**: A user adds the Chat app to a group conversation or space, or installs the Chat app for 1:1 messages.
      - **Message**: A user sends a message to the Chat app. For example, a user sends a direct message to the Chat app or @mentions the Chat app in a space with multiple people.
      - **Removed from space**: A user uninstalls or removes the Chat app from a space.
      - **App command**: A user invokes a quick command, slash command, or message action from the Chat app.
   4. Optional: Add other interactive features such as
      [sessions](https://developers.google.com/workspace/chat/sessions.md.txt),
      [starter prompts](https://developers.google.com/workspace/chat/receive-respond-interactions.md.txt#starter-prompts),
      [commands](https://developers.google.com/workspace/chat/commands.md.txt) (quick commands, slash commands,
      and message actions), or
      [link previews](https://developers.google.com/workspace/chat/preview-links.md.txt).

   5. Under **Visibility** , select
      **Make this Chat app available to specific
      people and groups** and enter the email addresses of individuals or
      Google Groups in your Google Workspace organization:

      - To [install and test your
        app](https://developers.google.com/workspace/chat/test-interactive-features) yourself, enter your own email address.
      - To share an internal Chat app across a team or your entire organization without publishing to the Marketplace, enter one or more Google Groups. Groups don't have a member limit. If your app requests `chat.app.*` scopes, you must still [publish the
        app](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app#publish-gwm) for administrator approval.
      - If your administrator restricts Marketplace installs to apps on an allowlist, Google Cloud console limits this field to five individual user email addresses for development. Group visibility applies only after an administrator adds the app to the allowlist.
6. Optional: Under **Logs** , select the **Log errors to Logging** checkbox to
   use Google Cloud Logging. For more information, see
   [Query error logs for Chat apps](https://developers.google.com/workspace/chat/query-logs.md.txt).

7. Click **Save**.

After you save the configuration, anyone that you specified in the
Chat API's **Visibility** setting can install, test, or use the
Chat app. To start testing and debugging your
Chat app, see
[Test interactive features for Google Chat apps](https://developers.google.com/workspace/chat/test-interactive-features.md.txt).

## Configure your Chat app using the Google Cloud CLI

> [!WARNING]
> **Beta:** The commands in this section are in the [beta
> release track](https://docs.cloud.google.com/sdk/gcloud#release_levels) of the Google Cloud CLI and might change without notice.

Instead of using the Google Cloud console, you can view and update the configuration
of a Chat app from the command line with the
Google Cloud CLI (gcloud CLI). For example, you can configure a
Chat app from a script, or keep its configuration in a
file that you store with your code.

The `gcloud beta workspace-add-ons chat-app-config` command group has the
following commands:

- [`describe`](https://cloud.google.com/sdk/gcloud/reference/beta/workspace-add-ons/chat-app-config/describe): Shows the configuration.
- [`update`](https://cloud.google.com/sdk/gcloud/reference/beta/workspace-add-ons/chat-app-config/update): Configures a Chat app for the first time, or changes its configuration.

The commands use the
[`chatAppConfig`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig.md.txt)
resource in the [Google Workspace add-ons API](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#configure-api).

> [!NOTE]
> **Note:** The `chat-app-config` commands only support Chat apps built as Google Workspace add-ons. To upgrade an existing Chat app, see [Convert a Google Chat app to a
> Google Workspace add-on](https://developers.google.com/workspace/chat/convert).

### Before you begin

1. [Install the gcloud CLI](https://cloud.google.com/sdk/docs/install). If you installed the gcloud CLI previously, make sure that you have the latest version by running `gcloud components update`.
2. Sign in to the gcloud CLI with your user account. The commands don't support
   service accounts.

   ```bash
   gcloud auth login
   ```
3. Set the Cloud project of your Chat app as
   the default project of the gcloud CLI. Use the project ID, because the
   commands don't accept a project number.

   ```bash
   gcloud config set project PROJECT_ID
   ```

   Alternatively, add the `--project` flag to each command.
4. Enable the Google Workspace add-ons API in the Cloud project:

   ```bash
   gcloud services enable gsuiteaddons.googleapis.com
   ```
5. Make sure that you have the following Identity and Access Management (IAM)
   roles on the Cloud project:

   - **Google Workspace Add-ons Developer** (`roles/gsuiteaddons.developer`) to view and update the configuration, or **Google Workspace Add-ons Reader** (`roles/gsuiteaddons.reader`) to only view it. These roles include the permissions that are listed in [Prerequisites and authentication](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#api-prerequisites).
   - **Service Usage Consumer** (`roles/serviceusage.serviceUsageConsumer`). The gcloud CLI uses the Cloud project as the quota project for its requests, which requires the `serviceusage.services.use` permission.

   The **Owner** and **Editor** roles include all of these permissions. The
   **Chat apps Owner** and **Chat apps Viewer**
   roles, which give access to the configuration page in the
   Google Cloud console, aren't sufficient.

### View the configuration

To view the configuration of your Chat app, run the
`describe` command:

```bash
gcloud beta workspace-add-ons chat-app-config describe
```

The output is similar to the following:

```yaml
avatarUri: https://www.gstatic.com/dynamite/images/quickstart-app-avatar.png
description: Helps manage tasks and schedules
displayName: Cymbal Assistant
errorLoggingEnabled: true
interactiveFeatureConfig:
  allowlistedTestingPrincipals:
  - user@example.com
  appCommands:
  - command: /help
    commandId: 1
    commandType: SLASH_COMMAND
    description: Show available commands
  connectionConfig:
    httpEndpointConfig:
      commonUrl: https://example.com/chat
  supportsMultiuserSpaces: true
  urlPatterns:
  - hostPattern: example.com
    pathPrefix: tasks/
name: projects/123456789012/chatAppConfig
state: ACTIVE
```

If the Cloud project doesn't have a Chat app
yet, the command succeeds and prints only the `name` field of the
configuration:

```yaml
name: projects/123456789012/chatAppConfig
```

To change the output, add one of the following flags:

- `--format=json`: Prints the configuration in JSON format.
- `--view=basic`: Leaves out the interactive feature settings (`interactiveFeatureConfig`).
- `--format="value(displayName)"`: Prints only the display name, or an empty line if the Cloud project doesn't have a Chat app yet. A configured Chat app always has a display name, so you can use this flag in a script to check whether a Chat app exists.

### Update the configuration

To configure a Chat app for the first time, or to
change its configuration, run the `update` command. Specify the settings with
flags or in a configuration file. You can't combine the two in one command.

The first time that you run the command for a Cloud project, you must
specify at least a display name and a description. Unless you set the state to
disabled, the Chat app is active as soon as the command
finishes. The people that you list as testers can then find and use it.

#### Use flags

The following example configures a Chat app that
receives events at an HTTP endpoint:

```bash
gcloud beta workspace-add-ons chat-app-config update \
    --display-name="Quickstart App" \
    --description="Quickstart app" \
    --avatar-uri=https://developers.google.com/workspace/chat/images/quickstart-app-avatar.png \
    --http-endpoint-url=HTTP_ENDPOINT_URL \
    --supports-multiuser-spaces \
    --add-allowlisted-testing-principals=USER_EMAIL \
    --error-logging-enabled
```

Replace the following:

- `HTTP_ENDPOINT_URL`: the HTTPS URL that receives [event objects](https://developers.google.com/workspace/chat/receive-respond-interactions.md.txt#event-objects) from Chat.
- `USER_EMAIL`: the email address of a person or a group in your Google Workspace organization who can install and test the Chat app, such as your own email address.

The command prints the updated configuration.

The following table lists the flags for the settings on the Chat API
**Configuration** page in the Google Cloud console. For details about each flag,
see the
[`update` command reference](https://cloud.google.com/sdk/gcloud/reference/beta/workspace-add-ons/chat-app-config/update).

| Setting in the Google Cloud console | Flags |
|---|---|
| App name | `--display-name` |
| Avatar URL | `--avatar-uri` with the HTTPS URL of an image that meets the [avatar requirements](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#name), or `--clear-avatar-uri` to use the default avatar |
| Description | `--description` |
| App status | `--state=active` or `--state=disabled` |
| Markup syntax | `--markup-syntax=markdown` or `--markup-syntax=chat` |
| Join spaces and group conversations | `--supports-multiuser-spaces` or `--no-supports-multiuser-spaces` |
| Connection settings | One of the following: - HTTP endpoint URL: `--http-endpoint-url` - Apps Script: `--apps-script-deployment-id` - Cloud Pub/Sub: `--pubsub-topic` with a topic in the same Cloud project, in the format `projects/PROJECT_ID/topics/TOPIC_ID` - Dialogflow: `--dialogflow-edition=es`, or `--dialogflow-edition=cx` with `--dialogflow-agent` set to the resource name of the agent or environment, such as `projects/PROJECT_ID/locations/LOCATION/agents/AGENT_ID` |
| Visibility | `--add-allowlisted-testing-principals`, `--remove-allowlisted-testing-principals`, and `--clear-allowlisted-testing-principals` |
| Log errors to Logging | `--error-logging-enabled` or `--no-error-logging-enabled` |

Commands, link previews, and separate endpoints for each trigger don't have
flags. To configure them, [use a configuration file](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#gcloud-update-file).

For example, to
[turn off your Chat app](https://developers.google.com/workspace/chat/turn-off-app.md.txt)
without changing its other settings, run the following command. To turn it on
again, use `--state=active`.

```bash
gcloud beta workspace-add-ons chat-app-config update --state=disabled
```

#### Use a configuration file

To keep the configuration in a file, or to configure settings that don't have
flags, pass a YAML or JSON file to the `update` command. The file uses the
fields of the
[`chatAppConfig`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig.md.txt)
resource, which are the same fields that the `describe` command prints.

1. Create a file that contains the settings to update. For example, create a
   file named `chat_app_config.yaml` with the following content:

   ```yaml
   displayName: Cymbal Assistant
   description: Helps manage tasks and schedules
   avatarUri: https://www.gstatic.com/dynamite/images/quickstart-app-avatar.png
   state: ACTIVE
   errorLoggingEnabled: true
   interactiveFeatureConfig:
     supportsMultiuserSpaces: true
     connectionConfig:
       httpEndpointConfig:
         commonUrl: https://example.com/chat
     appCommands:
     - commandId: 1
       commandType: SLASH_COMMAND
       command: /help
       description: Show available commands
     urlPatterns:
     - hostPattern: example.com
       pathPrefix: tasks/
     allowlistedTestingPrincipals:
     - USER_EMAIL
   ```

   Replace `USER_EMAIL` with the email address of a
   person or a group in your Google Workspace organization who can
   install and test the Chat app.
2. Run the `update` command with the `--config-file` flag:

   ```bash
   gcloud beta workspace-add-ons chat-app-config update \
       --config-file=chat_app_config.yaml
   ```

To start from the current configuration of a Chat app,
save the output of the `describe` command to a file:

```bash
gcloud beta workspace-add-ons chat-app-config describe > chat_app_config.yaml
```

Then edit the file, delete the fields that you don't want to change, and pass
the file to the `update` command. If the file contains a setting that the
command can't update, the command fails. For details, see
[Limitations](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#gcloud-limitations).

The `update` command ignores the `name` field in the file. It always updates the
Cloud project that you set in the gcloud CLI, so you can use the same
file to configure a Chat app in another
Cloud project.

#### How the command applies your changes

- **Only the settings that you specify change.** With flags, the command changes the settings for the flags that you pass. With a configuration file, it changes the fields that are in the file, so the file doesn't need to contain the whole configuration. The connection settings are an exception: a connection type that you set replaces the current one, and a Dialogflow edition that you set replaces the whole Dialogflow configuration.
- **Lists are replaced as a whole.** If the file contains the `appCommands`, `urlPatterns`, or `allowlistedTestingPrincipals` field, the list in the file replaces the current list. To add or remove individual testers instead, use the `--add-allowlisted-testing-principals` and `--remove-allowlisted-testing-principals` flags.
- **An empty value clears a setting.** For example, a file that contains `urlPatterns: []` under `interactiveFeatureConfig` removes all link preview URL patterns.
- **A command that fails doesn't change anything.** If a value isn't valid, the command prints the error and leaves the configuration as it was.
- **Requests are rate limited.** The API limits the number of read requests and update requests per minute, for each Cloud project and for each organization. Each `update` command sends one update request. If you add or remove testers with flags, the command also sends a read request. To change several settings, pass them in one command or one file instead of running a command for each setting.

### Limitations

- The commands only support Chat apps built as Google Workspace add-ons.
- The commands don't support service accounts or service account impersonation. You must sign in to the gcloud CLI with a user account.
- A Cloud project has one Chat app configuration, and the commands can't delete it. To stop people from using the Chat app, set its state to disabled or delete the Cloud project.
- An update applies to the live Chat app. The commands don't have a draft or dry-run mode.
- While a Chat app is published or under review in the Google Workspace Marketplace, the commands can't change its display name, avatar, description, commands, or link preview URL patterns.
- The commands support the settings in the [`chatAppConfig`
  resource](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig). To configure a setting that the resource doesn't include, use the Google Cloud console.

<br />

### Troubleshoot

If a command fails, find the text from the error message in the following
table. If the message starts with a status such as `INVALID_ARGUMENT`, the
[Google Workspace add-ons API](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#configure-api) rejected the request, and the text after the
status describes the problem.

| Error message contains | Cause | Solution |
|---|---|---|
| `Invalid choice: 'chat-app-config'` or `Invalid choice: 'workspace-add-ons'` | The command doesn't include `beta`, or your version of the gcloud CLI doesn't include the commands. | Start the command with `gcloud beta workspace-add-ons chat-app-config`. If the error persists, update the gcloud CLI to the latest version. |
| `PROJECT ID` | The project is set to a project number. | Set the project to the project ID. |
| `Failed to parse value(s) in protobuf` | The configuration file contains a field that the gcloud CLI doesn't recognize. The error message names the field. | Compare the field name with the output of the `describe` command. If the field is new, update the gcloud CLI to the latest version. |
| `does not have permission to access projects instance` | The API denied the request. The text after this message gives the reason. For example: - Your account doesn't have the required IAM roles. If the text contains `Caller does not have required permission to use project`, the Service Usage Consumer role is missing. - The Google Workspace add-ons API isn't enabled in the Cloud project. - You signed in with a service account. | Check the requirements in [Before you begin](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#gcloud-prerequisites). |
| `INVALID_ARGUMENT` | A value isn't valid. For example, the display name must have between 3 and 25 characters, and the description between 1 and 40 characters. If the message contains `not found or deleted`, the project ID isn't correct. | Correct the value that the error message describes, and run the command again. |
| `FAILED_PRECONDITION` | The Chat app doesn't allow the request. For example, it isn't built as a Google Workspace add-on, or it's published in the Google Workspace Marketplace and the setting can't be changed. | Follow the instructions in the error message. To configure a Chat app that isn't a Google Workspace add-on, use the Google Cloud console or [convert it](https://developers.google.com/workspace/chat/convert.md.txt). |
| `RESOURCE_EXHAUSTED` or `429` | The API received too many requests for the Cloud project or for your organization in a short time. | Wait a minute, and then run the command again. |

## Configure your Chat app using the Google Workspace add-ons API

Instead of configuring your Chat app manually in the
Google Cloud console, you can programmatically read and update the configuration
for a Chat app built as a Google Workspace add-on
using the `chatAppConfig` resource in the
[`Google Workspace add-ons API`](https://developers.google.com/workspace/add-ons/reference.md.txt).

`chatAppConfig` is a singleton resource that always exists for each
Cloud project. Before you save a configuration for the first time, the
resource contains an empty configuration (which is also what
[`GetChatAppConfig`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig/get.md.txt)
returns if you read the resource before the first save). Because the resource
already exists, you don't need to create it separately---use
[`UpdateChatAppConfig`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig/patch.md.txt)
both to save the initial configuration and to update an existing configuration.

> [!NOTE]
> **Note:** The `chatAppConfig` methods only support Chat apps built as Google Workspace add-ons. To upgrade an existing Chat app, see [Convert a Google Chat app to a Google Workspace add-on](https://developers.google.com/workspace/chat/convert.md.txt).

### Prerequisites and authentication

Before calling `GetChatAppConfig` or `UpdateChatAppConfig`, complete the
following prerequisites:

1. [Enable](https://developers.google.com/workspace/guides/enable-apis.md.txt) the Google Workspace add-ons API (`gsuiteaddons.googleapis.com`) in your Cloud project. Optionally, you can enable the Google Chat API (`chat.googleapis.com`) if you want to view or update the Chat app configuration in the Google Cloud console or call the Chat API.
2. Authenticate as a human user with an OAuth 2.0 credential that includes the `https://www.googleapis.com/auth/cloud-platform` scope. Service account authentication isn't supported for `chatAppConfig` methods.
3. Ensure the authenticated user has the required Identity and Access Management (IAM) permissions on the target Cloud project:
   - `gsuiteaddons.chatAppConfigs.get` and `chat.bots.get` to read the configuration (`GetChatAppConfig`).
   - `gsuiteaddons.chatAppConfigs.update`, `chat.bots.update`, and `chat.bots.get` to update the configuration (`UpdateChatAppConfig`).
4. If you use a client library, install the latest version of the Google Workspace add-ons API client library for your language. For a list of client libraries, see the [Google Workspace add-ons API reference](https://developers.google.com/workspace/add-ons/reference.md.txt).

### Update a Chat app configuration

To configure a Chat app for the first time or update an
existing configuration, send a `PATCH` request
([`UpdateChatAppConfig`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig/patch.md.txt))
to the singleton
[`chatAppConfig`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig.md.txt)
resource for your Cloud project:

- For the initial save on a Cloud project with an empty `chatAppConfig`, `displayName` (3 to 25 characters) and `description` (1 to 40 characters) are required. If you omit `interactiveFeatureConfig` on the initial save, the Chat app is configured as non-interactive.
- For subsequent updates, use the optional `updateMask` query parameter to specify the comma-separated fields to update (or omit `updateMask` to update all provided fields). Updating a repeated field (`appCommands`, `urlPatterns`, or `allowlistedTestingPrincipals`) replaces the entire list.

```console
PATCH https://gsuiteaddons.googleapis.com/v1/projects/PROJECT_NUMBER/chatAppConfig?updateMask=displayName,description,avatarUri,state,errorLoggingEnabled,markupSyntax,interactiveFeatureConfig
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

{
  "name": "projects/PROJECT_NUMBER/chatAppConfig",
  "displayName": "Cymbal Assistant",
  "description": "Helps manage tasks and schedules",
  "avatarUri": "https://www.gstatic.com/dynamite/images/quickstart-app-avatar.png",
  "state": "ACTIVE",
  "errorLoggingEnabled": true,
  "markupSyntax": "MARKUP_SYNTAX_MARKDOWN",
  "interactiveFeatureConfig": {
    "supportsMultiuserSpaces": false,
    "connectionConfig": {
      "httpEndpointConfig": {
        "commonUrl": "https://example.com/chat"
      }
    },
    "appCommands": [
      {
        "commandType": "SLASH_COMMAND",
        "commandId": 1,
        "command": "/help",
        "description": "Show available commands",
        "dialogEnabled": false
      }
    ],
    "urlPatterns": [
      {
        "hostPattern": "example.com",
        "pathPrefix": "tasks/"
      }
    ],
    "allowlistedTestingPrincipals": [
      "USER_EMAIL"
    ]
  }
}
```

Replace the following in the request URL, header, and body:

- `PROJECT_NUMBER`: The numeric project number of the Cloud project hosting your Chat app.
- `ACCESS_TOKEN`: A user OAuth 2.0 access token authorized with the `https://www.googleapis.com/auth/cloud-platform` scope.
- `USER_EMAIL`: An email address or Google Group from your Google Workspace organization to allowlist for testing the Chat app (for example, your own email address).
- The example configuration fields in the request body (such as `displayName`, `description`, `avatarUri`, and `interactiveFeatureConfig`, including your endpoint configuration, commands, link preview URL patterns, and testing principals) with the values for your Chat app. For details on all supported fields and endpoint options, see the [`projects.chatAppConfig` REST reference](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig.md.txt) and [`projects.chatAppConfig.patch`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig/patch.md.txt).

### Get a Chat app configuration

To read the current Chat app configuration for a
Cloud project, call
[`GetChatAppConfig`](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig/get.md.txt).
You can pass the optional `view` query parameter (`ChatAppConfigView`):

- `BASIC` (default): Returns basic metadata without `interactiveFeatureConfig`.
- `FULL`: Returns all configuration fields, including `interactiveFeatureConfig`.

If the Chat app configuration hasn't been saved for the
Cloud project yet, the method returns an empty `ChatAppConfig` object.

### HTTP

```console
GET https://gsuiteaddons.googleapis.com/v1/projects/PROJECT_NUMBER/chatAppConfig?view=FULL
Authorization: Bearer ACCESS_TOKEN
```

### Node.js

```javascript
const {GSuiteAddOnsClient} = require('@google-cloud/gsuiteaddons').v1;

const client = new GSuiteAddOnsClient();

async function getChatAppConfig() {
  const [response] = await client.getChatAppConfig({
    name: 'projects/PROJECT_NUMBER/chatAppConfig',
    view: 'FULL',
  });
  console.log(JSON.stringify(response, null, 2));
}

getChatAppConfig();
```

### Python

```python
from google.cloud import gsuiteaddons_v1

client = gsuiteaddons_v1.GSuiteAddOnsClient()

request = gsuiteaddons_v1.GetChatAppConfigRequest(
    name="projects/PROJECT_NUMBER/chatAppConfig",
    view=gsuiteaddons_v1.GetChatAppConfigRequest.ChatAppConfigView.FULL,
)
response = client.get_chat_app_config(request=request)
print(response)
```

### Usage limits

The `chatAppConfig` methods have per-project quotas. If you exceed a quota, the
request fails with a `429: Too many requests` HTTP status code. For the quota
limits, see [Google Workspace add-ons API usage limits](https://developers.google.com/workspace/add-ons/reference/limits.md.txt).

### Troubleshoot errors

If a `chatAppConfig` request fails, check the HTTP status code and the `message`
field in the error response. The following table lists common errors, their
causes, and how to resolve them.

| HTTP status code | Common causes | Resolution |
|---|---|---|
| `400: Bad Request` (`INVALID_ARGUMENT`) | - The `updateMask` contains a field that doesn't exist or can't be updated. - A field value is missing or invalid. For example, `interactiveFeatureConfig` doesn't include a `connectionConfig`. | Check the `message` field for the invalid field, and correct the request. For supported fields and values, see the [`projects.chatAppConfig` reference](https://developers.google.com/workspace/add-ons/reference/rest/v1/projects.chatAppConfig.md.txt). |
| `400: Bad Request` (`FAILED_PRECONDITION`) | - The Chat app isn't built as a Google Workspace add-on. - The field can't be changed because the Chat app is published on the Google Workspace Marketplace. - The new value isn't compatible with the existing Chat app configuration. | - [Convert the Chat app to a Google Workspace add-on](https://developers.google.com/workspace/chat/convert.md.txt), or configure it in the Google Cloud console. - Follow the instructions in the `message` field to update the published listing. - Check the `message` field for the conflicting setting, and update both settings in the same request, or change the existing setting first. |
| `403: Forbidden` (`PERMISSION_DENIED`) | - The authenticated user doesn't have the required IAM permissions on the Cloud project. - The request is authenticated with a service account instead of a user account. | - Grant the user the permissions listed in [Prerequisites and authentication](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#api-prerequisites). - Authenticate as a human user with the `https://www.googleapis.com/auth/cloud-platform` scope. |
| `404: Not Found` (`NOT_FOUND`) | The Cloud project in the resource name doesn't exist, or the authenticated user can't access it. | Check that the resource name uses the correct project number in the format `projects/PROJECT_NUMBER/chatAppConfig`, and that the user has access to the Cloud project. |
| `429: Too Many Requests` (`RESOURCE_EXHAUSTED`) | The per-project quota is exceeded. | Wait and retry the request later. For limits, see [Usage limits](https://developers.google.com/workspace/add-ons/reference/limits.md.txt). |

## Considerations for existing Google Workspace add-ons

Chat apps require a different configuration compared to
Google Workspace add-ons that extend other Google Workspace applications.
If your add-on extends other
Google Workspace applications, consider the following requirements
for configuring the Chat app:

- Both individuals and Google Workspace administrators must be able to install your add-on from the Marketplace. You configure these installation settings in the Marketplace SDK.
- Chat apps don't use the name and logo that you configure for other Google Workspace applications in the `addons.common` object of the [manifest](https://developers.google.com/workspace/add-ons/concepts/workspace-manifests.md.txt).
- For add-ons that are published to the Google Workspace Marketplace, you can't save a draft of any changes to the Google Chat API configuration settings. After you update and save the Chat API configuration settings, the updated Chat app is immediately available to all existing users. To update your Marketplace listing, you can [create a draft](https://developers.google.com/workspace/marketplace/manage-app-listing.md.txt#draft-app-listing) before submitting any changes.
- If you built your add-on using Apps Script:
  - You must use the same Apps Script deployment ID that you use for the rest of your add-on configuration.
  - You can't use the Apps Script editor to install [test deployments](https://developers.google.com/workspace/add-ons/how-tos/testing-workspace-addons.md.txt#install_an_unpublished) in Chat. Instead, you must [install them directly from the Chat UI](https://developers.google.com/workspace/chat/test-interactive-features.md.txt).
- If you built your add-on using an HTTP service, omit any Chat app configuration details in the `projects.deployments` manifest that you create using the Google Workspace add-ons API. The HTTP deployments that you specify in the Google Workspace Marketplace SDK are only used for other Google Workspace applications. Instead, configure your Chat app in the [Google Cloud console](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#configure-console), with the [gcloud CLI](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#configure-gcloud), or using the `chatAppConfig` resource in the [Google Workspace add-ons API](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#configure-api).

## Grant other people permission to configure the Chat API

You can
[give specific users access](https://cloud.google.com/iam/docs/granting-changing-revoking-access#single-role)
to the Chat app configuration page by granting them
the **Chat apps Owner** or **Chat apps Viewer**
[Google Cloud Identity Access Management (IAM) role](https://cloud.google.com/iam/docs/roles-permissions/chat).
Users with these roles can't navigate to the Chat apps
configuration page by using the **APIs \& Services** dashboard, but can
access the configuration page by navigating to the Google Cloud console for the
Chat app's host Cloud project as follows:

```
https://console.developers.google.com/apis/api/chat.googleapis.com/hangouts-chat?project=PROJECT_ID
```

Where `PROJECT_ID` is the project ID of the
Google Cloud project hosting the Chat app.

> [!NOTE]
> Users with **Project** roles can also access the app configuration page.
>
>
> Users with custom roles containing the
> `resourcemanager.projects.(get|update)` permissions cannot access
> the Chat app configuration. For custom roles, use
> the `chat.bots.(get|update)` permissions (and
> `gsuiteaddons.chatAppConfigs.(get|update)` when using the
> [gcloud CLI](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#configure-gcloud) or calling the
> [Google Workspace add-ons API](https://developers.google.com/workspace/chat/configure-chat-api.md.txt#configure-api)) instead. The gcloud CLI also
> requires the `serviceusage.services.use` permission.

## Related topics

- [Choose a Chat app architecture](https://developers.google.com/workspace/chat/structure.md.txt)
- [Receive and respond to user interactions](https://developers.google.com/workspace/chat/receive-respond-interactions.md.txt)
- [Test interactive features for Google Chat apps](https://developers.google.com/workspace/chat/test-interactive-features.md.txt)

## Chat apps that aren't add-ons: Configure the Google Chat API

If you maintain a Chat app that isn't a
Google Workspace add-on, your configuration uses a single endpoint for all
interaction events rather than per-event triggers:

1. In the Google Cloud console, go to the Chat API **Configuration**
   page:

   [Go to Chat API Configuration page](https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat)
2. Under **Interactive features** , turn on **Enable interactive features**.

3.
   Clear **Build this Chat app as a Google Workspace add-on** . A dialog opens asking you to confirm. In the dialog, click **Disable**.

4. Under **Functionality** , select **Support App Home** or **Join spaces and
   group conversations** as needed.

5. Under **Connection settings** , specify a single endpoint for your
   Chat app (**HTTP endpoint URL** ,
   **Apps Script** deployment ID, **Cloud Pub/Sub topic name** ,
   or **Dialogflow**).

6. Configure optional **Commands** , **Starter prompts** , **Link previews** ,
   **Visibility** , and **Logs** , then click **Save**.

To upgrade a Chat app that isn't an
add-on to a Google Workspace add-on that extends
Google Chat, see
[Convert a Google Chat app to a Google Workspace add-on](https://developers.google.com/workspace/chat/convert.md.txt).