# Receive Alert Notifications via Google Chat

> Setup Google Chat integration and receive alert notifications from Last9.

Source: https://last9.io/docs/google-chat-integration/

## Getting started

Last9 can send alert notifications and resolutions to Google Chat spaces. This document provides step-by-step instructions on how to set up Google Chat integration with Last9 and start receiving alert notifications.

:::tip
Last9 automatically detects Google Chat webhook URLs and formats messages using the [Cards v2 API](https://developers.google.com/chat/api/reference/rest/v1/cards) for rich, interactive notifications with headers, sections, and action buttons.
:::

## Setting up an Incoming Webhook in Google Chat

1. Open [Google Chat](https://chat.google.com) and navigate to the space where you want to receive alerts

2. Click on the space name at the top to open the dropdown menu

3. Select **Apps & integrations** (or **Manage webhooks** in older versions)

4. Click **Add webhooks**

5. Configure your webhook:

   - Enter a **Name** for the webhook (e.g., "Last9 Alerts")
   - Optionally, add an **Avatar URL** for the webhook icon

6. Click **Save**

7. Copy the generated webhook URL. It will look like:
   ```
   https://chat.googleapis.com/v1/spaces/SPACE_ID/messages?key=KEY&token=TOKEN
   ```

:::note
Keep this webhook URL secure. Anyone with access to this URL can post messages to your Google Chat space.
:::

## Setting up a notification channel in Last9

1. In [Notification Channels](https://app.last9.io/alerting/notification-channels/), click **Add** to create a new channel

   ![Notification channels list](../../../../../assets/content/docs/alerting/overviews/notification-channels-overview/notification-channel-1.png)

2. Provide the following details:

   - **Channel Name**: A descriptive name to easily identify the channel (e.g., "Google Chat Production Alerts")
   - **Channel**: Select **Webhook** from the dropdown
   - **Webhook URL**: Paste the Google Chat webhook URL copied from the previous step
   - **Send Resolved**: Enable this option if you want to be notified when an alert has been resolved

   ![Add webhook channel](../../../../../assets/content/docs/alerting/overviews/notification-channels-overview/webhook-channel-config.png)

3. Click **Save** to enable the channel

:::tip
Last9 automatically detects Google Chat webhook URLs (containing `chat.googleapis.com`) and formats notifications using the Cards v2 API.
:::

## Assigning a notification channel to an alert group

1. Navigate to your Alert Group in [Alerting](https://app.last9.io/alerting/)

2. Click on the notification channel icon to configure notifications

3. Select your Google Chat channel from the dropdown

:::tip
You can set different notification channels for `threat` and `breach` notifications depending on the severity of the alerts.
:::

## Google Chat Notification Format

Last9 sends notifications to Google Chat using the Cards v2 API, which provides rich formatting. Each notification card includes:

| Section  | Description                                                        |
| -------- | ------------------------------------------------------------------ |
| Header   | Alert summary with subtitle showing severity, class, and timestamp |
| Sections | Organized alert details with decorated text widgets                |
| Button   | "Inspect in Last9" link to view the alert directly                 |

### Severity Indicators

| Severity | Icon          | Description                                   |
| -------- | ------------- | --------------------------------------------- |
| Breach   | Red circle    | Critical alerts requiring immediate attention |
| Threat   | Orange circle | Warning alerts indicating potential issues    |

---

## Using Terraform

You can also create the Google Chat notification channel using the [Last9 Terraform Provider](/docs/terraform-provider/):

```hcl
resource "last9_notification_channel" "google_chat" {
  name          = "google-chat-production-alerts"
  type          = "webhook"
  destination   = "https://chat.googleapis.com/v1/spaces/SPACE_ID/messages?key=KEY&token=TOKEN"
  send_resolved = true
}
```

---

## Troubleshooting

### Notifications not appearing in Google Chat

1. Verify the webhook URL is correct and starts with `https://chat.googleapis.com/`
2. Check that the webhook is still active in your Google Chat space settings
3. Ensure the space where the webhook was created still exists

### Messages are not formatted correctly

Last9 auto-detects Google Chat webhooks based on the URL pattern. Ensure your webhook URL contains `chat.googleapis.com`.

### Rate limiting

Google Chat has rate limits for incoming webhooks. If you're sending a high volume of alerts, some messages may be delayed or dropped. Consider consolidating alerts or using alert grouping in Last9.

Please get in touch with us on [Discord](https://discord.com/invite/Q3p2EEucx9) or [Email](mailto:support@last9.io) if you have any questions.
