> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coderabbit.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Respond to incidents

> Set up a CodeRabbit automation that assesses each new alert from Datadog, PagerDuty, or any alerting bot in Slack, and posts the assessment in the alert's thread, a channel, or on the PagerDuty incident.

Cloud Only (This feature is available on CodeRabbit Cloud only. It is not available on self-hosted CodeRabbit deployments.)

## What you get

For each new alert, CodeRabbit posts an assessment: whether the alert looks real, the likely impact and failure domain, recent changes that could explain it, and the next step for the owner. The templates tell it not to change code, roll back deployments, or change the incident.

Pick the route by where your alerts arrive and where the assessment should go:

| Alerts arrive | Assessment goes to | Start from |
| - | - | - |
| An alerting bot posts them to a Slack channel, such as the Datadog or PagerDuty app in `#prod-alerts` | The alert's thread | [`/automations` or `@coderabbit` in the channel](#alerts-already-post-to-a-slack-channel) |
| Datadog sends them by webhook | A Slack channel | [**Triage Datadog alert**](#datadog-alerts-to-a-slack-channel) |
| PagerDuty opens an incident | A note on the incident, or a Slack channel | [**Add assessment to PagerDuty incident** or **Triage PagerDuty incident**](#pagerduty-incidents) |

## Before you start

| Requirement | Who does it | Where |
| - | - | - |
| Agent billing: CodeRabbit Agent for Slack for the Slack routes, the Automations Agent trial or paid Agent access for the PagerDuty note. See [Who can use Automations](https://docs.coderabbit.ai/automations.md#who-can-use-automations). | A CodeRabbit admin | **Billing**, or the **Automations Agent usage** card on the Automations page |
| Your repositories and the alert source as connections, such as Datadog (an API key and an application key) or PagerDuty, in the run's scope | A CodeRabbit admin | [Connections](https://docs.coderabbit.ai/connections.md); scope in **Slack** > **Channel mappings** or [Base Scope](https://docs.coderabbit.ai/automations/destinations.md#connections-and-base-scope) |
| CodeRabbit in the alert channel, if it's private | A channel member | `/invite @coderabbit` in the channel |
| An **Automation limit** for the alert channel | A CodeRabbit admin | **Slack** > **Channel mappings** > the channel's assignment |

A channel message trigger starts a run for every matching message, so a busy alert channel needs its own limit. In the assignment, the **Automation limit** is a USD amount per monthly billing period: **Use Slack default**, **No limit**, or **Set limit**. Zero blocks new paid runs. See [Scope and spend limits](https://docs.coderabbit.ai/slack-agent/automations.md#scope-and-spend-limits).

## Set it up

### Alerts already post to a Slack channel

The quickest setup runs on every new top-level message in the channel:

**1. Open the template**

In the alert channel, run `/automations` and start a new automation. In **Purpose**, choose **Respond to incidents**. In **When to run**, choose **New channel message**.

**2. Edit the instructions**

The template classifies each alert as Real, Likely noise, or Unclear, checks pull requests and deploys from the last 48 hours, suggests owners and the next recovery step, and keeps the reply under 15 lines. Edit the **Agent instructions** (the `/automations` form takes up to 3,000 characters; the web editor takes up to 20,000) to name your services or runbooks.

**3. Check the connections**

Check that **Connections Available** lists your repositories and the alert source. If one is missing, change the channel's scope in **Slack** > **Channel mappings**.

**4. Save**

Select **Save and activate**. The automation is active right away, without a trial run.

To run only on alert messages and not on every post, add a filter:

* **By text.** Open the automation from **Automations** > **Home**, select **Edit**, and add phrases such as `Triggered` under **Text includes** in the **Trigger** card. See [Channel messages](https://docs.coderabbit.ai/automations/triggers.md#channel-messages).
* **By author and text.** Create the automation in chat instead of with `/automations`. Ask `@coderabbit` in the channel and name both the alerting bot or app and the phrases, for example:

  ```text Slack message wrap theme={null}
  @coderabbit For each new message from the Datadog app in this channel that contains "Triggered", check whether the alert is real, look at deploys and merged pull requests from the last 48 hours, and suggest the owner and the next step. Reply in the alert's thread in under 15 lines. Don't change code or roll back deployments.
  ```

  CodeRabbit does one trial run, then shows an **Automation draft ready** card; select **Create automation**. See [Create an automation from Slack](https://docs.coderabbit.ai/slack-agent/automations.md#create-an-automation-from-slack).

How the filters combine:

* A message must match both the author filter and the text filter.
* Several phrases match any one of them, as a case-insensitive substring. Several authors match any one of them.
* Messages from bots and apps count. Thread replies and CodeRabbit's own messages never start a run.

The web editor and the automation's page show only the channel and the text filter. To change an author filter, ask `@coderabbit` in the channel.

### Datadog alerts to a Slack channel

**1. Open the template**

In the web app, open **Slack** > **Automations** and, under **Prebuilt automations**, select **Triage Datadog alert**. The trigger is Datadog with the `monitor.alert` event and a read-only filter that ignores recovery notifications. The instructions assess the impact, likely failure domain, immediate mitigation, and next owner action, avoid duplicate assessments for the same alert, and don't change code.

**2. Choose the channel**

In the **Target** card, choose the Slack channel, then select **Save automation**.

**3. Configure the webhook in Datadog**

After you save, the editor shows the webhook URL and the Datadog setup steps:

1. Open the Webhooks integration tile in Datadog and create or edit a webhook with the URL.
2. Paste the payload JSON from the editor.
3. Add the alert-only notification from the editor to the monitor's message. It's wrapped in Datadog's `is_alert` condition, so recoveries don't call the webhook.
4. Paste the required headers JSON into the webhook's custom headers. Leave authentication empty and **Encode as form** unchecked.
5. Save.

See [Other providers](https://docs.coderabbit.ai/automations/triggers.md#other-providers).

The same template posts to Discord under **Discord** > **Automations**.

### PagerDuty incidents

**1. Open the template**

To add the assessment as a note on the incident, open **Automations** > **Home**, select **Investigate alerts** under **Templates**, and select **Set up** on the **Assess new incidents** card. The editor opens with the **Add assessment to PagerDuty incident** template.

To post the assessment to a Slack channel instead, open **Slack** > **Automations** and, under **Prebuilt automations**, select **Triage PagerDuty incident**.

Both templates run on the `incident.triggered` event. The instructions assess the customer impact, likely failure domain, immediate mitigation, and next owner action, and don't change code or acknowledge, resolve, or reassign the incident.

**2. Choose the destination**

In the **Target** card, choose the PagerDuty connection or the Slack channel, then select **Save automation**.

CodeRabbit manages the PagerDuty webhook after a CodeRabbit admin connects PagerDuty once. The subscription covers the whole PagerDuty account, not one service or team. See [Managed webhooks](https://docs.coderabbit.ai/automations/triggers.md#managed-webhooks).

## Test it

| Route | How to test |
| - | - |
| Slack channel message | Post a message that matches the filters in the channel, or try the automation in a test channel first. With an author filter, the message has to come from that bot, so fire a test alert from the monitoring tool. **Run now** isn't available for message triggers. |
| Datadog webhook | Make a monitor go into the Alert state, for example a test monitor with a low threshold. Recovery notifications don't start a run. |
| PagerDuty | Trigger an incident on a test service. The templates accept only `incident.triggered`, so a `pagey.ping` test event doesn't start a run. |

See [Test a trigger](https://docs.coderabbit.ai/automations/triggers.md#test-a-trigger).

## Check the runs

Each run is listed on the automation's page. See [Automation details](https://docs.coderabbit.ai/automations/manage.md#automation-details). What each route produces:

* **Slack channel message:** a reply in the alert's thread.
* **Datadog webhook or Triage PagerDuty incident:** a new thread in the channel for each alert.
* **Add assessment to PagerDuty incident:** a note on the incident.

When the channel reaches its **Automation limit**, new alerts don't start runs until a CodeRabbit admin raises the limit or the billing period resets. See [Spend limits](https://docs.coderabbit.ai/automations/manage.md#spend-limits).

## Variations

* **Sentry or Google Cloud alerts.** Create an automation with the **Sentry** or **GCP** trigger and reuse the instructions from one of these templates. See [Create an automation in the web app](https://docs.coderabbit.ai/automations/create.md#create-an-automation-in-the-web-app).
* **Follow-up actions.** Ask in the instructions for an **Open revert PR** button, or for a summary in `#incidents` when the verdict is Real. Webhook-triggered runs can't post to a second channel. See [Buttons, second channel, and DMs](https://docs.coderabbit.ai/slack-agent/automations.md#buttons-second-channel-and-dms).
* **Replies in the thread.** For channel message automations, ask the instructions to act on replies, for example "if someone replies *fix it*, open a revert PR." See [Slack channel message triggers](https://docs.coderabbit.ai/slack-agent/automations.md#slack-channel-message-triggers).

## What's next

> [card] [Automations in Slack](https://docs.coderabbit.ai/slack-agent/automations.md)
>
> Learn how channel message triggers, thread replies, and Slack spend limits work.

> [card] [Automation triggers](https://docs.coderabbit.ai/automations/triggers.md)
>
> See every webhook provider, matching rule, and how deduplication works.

> [card] [Automation guides](https://docs.coderabbit.ai/automations/guides.md)
>
> Set up ticket triage, support triage, and more from their templates.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.