---
title: Automations
description: >-
  Create Bits Code automations that run sessions on a schedule or in response to
  Datadog signals.
breadcrumbs: Docs > Bits AI > Bits Code > Automations
---

# Automations

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Overview{% #overview %}

Create an automation to have Bits Code start a [session](https://docs.datadoghq.com/bits_ai/bits_ai_dev_agent.md#sessions) when a trigger fires, such as a new Code Security finding or a recurring schedule, then deliver the results as a pull request or Slack notification.

{% image
   source="https://docs.dd-static.net/images/bits_ai/dev_agent/automations/list.457dbdb650b7a166c950f57dc8f051da.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/bits_ai/dev_agent/automations/list.457dbdb650b7a166c950f57dc8f051da.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="Under an 'Automate with Bits' title, a table with columns like Name, Author, and Last Run has four rows." /%}

With Bits Code automations, you can:

- Generate code fixes on a schedule, without starting each session manually
- Have Bits Code respond to signals from other Datadog products, such as a new APM Recommendation, a flaky test, or a Code Security finding
- Route the resulting code changes directly to a pull request or notify a team in Slack

## Prerequisites{% #prerequisites %}

To set up a Bits Code automation, each of the following must be true:

- You have the **Bits Code Write** (`bits_dev_write`) permission in Datadog.
- You have completed the Bits Code [setup](https://docs.datadoghq.com/bits_ai/bits_ai_dev_agent/setup.md).
- If you plan to have your automations output Slack notifications, you have set up the [Slack integration](https://docs.datadoghq.com/integrations/slack.md).

## Create an automation{% #create-an-automation %}

You can create a custom automation, or use a Datadog-provided automation template.

{% image
   source="https://docs.dd-static.net/images/bits_ai/dev_agent/automations/custom_prompt_creation_form.24f1cca0513972ef3a09828de78b5735.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/bits_ai/dev_agent/automations/custom_prompt_creation_form.24f1cca0513972ef3a09828de78b5735.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="Under an 'Automate with Bits' title, a form with fields like 'Custom Prompt' and 'Every week on' is shown." /%}

By default, newly created automations have an **Active** status, and appear in the **My Automations** list.

### Create a custom automation{% #create-a-custom-automation %}

To create a custom Bits Code automation:

1. In Datadog, navigate to **Bits AI** > **Bits Code** > [**Automations**](https://app.datadoghq.com/code/automations).
1. Click **New Automation**.
1. In the **Automation name** field, enter a descriptive name for the automation.
1. In the **Trigger** section, configure a trigger.
1. In the **Output** section, configure one or more outputs.
1. Click **Create Automation** or **Create & run now**.

### Create an automation from a template{% #create-an-automation-from-a-template %}

Find Datadog-provided automation templates in the **Automation Templates** section. These may include:

- **Create PRs based on APM Recommendations**: Generates pull requests based on APM Recommendations for a specific service.
- **Fix frequent errors for a repo**: Uses the **Custom Prompt** trigger to instruct Bits Code to scan the last 24 hours of logs, find the most frequent error, and open a pull request with a fix.

Click a template tile to be taken to the new automation form. You must configure an output before creating the automation.

## Triggers{% #triggers %}

A trigger defines when an automation runs and what Bits Code acts on. A trigger is built from up to three components:

- Product finding: a signal from within Datadog, such as an Error Tracking issue
- Custom prompt: a freeform instruction telling Bits Code what to do against a chosen repository
- Schedule: a recurring time interval, such as daily or on specific days of the week

Click **Add Trigger** to add a component. You can combine a product finding with a schedule, a custom prompt with a schedule, or use a product finding on its own.

To limit how many Bits Code sessions the automation can create in a given period (for example, `5 runs per Week`), click **Add Trigger** > **Set max runs**. One automation execution may produce more than one session. Use this setting to control the volume of pull requests or notifications an automation produces.

### Product finding trigger{% #product-finding-trigger %}

A product finding trigger runs the automation in response to new issues in another Datadog product (for example, Error Tracking or Code Security). You can use a product finding trigger by itself, which runs the automation whenever there is a new finding, or with a schedule and lookback window you define (in the **New findings within** field).

{% alert level="info" %}
While it's common to use a product finding trigger alone (to immediately remediate new findings), coupling it with a schedule and lookback window lets you monitor for new findings only during certain times. For example, if you deploy weekly on Wednesdays, you may want to configure an APM Recommendations trigger to run every Thursday, looking back 24 hours.
{% /alert %}

When setting up a product finding trigger, you can configure additional filters, which vary by product. For example:

- **Flaky Tests** supports filtering by **Repository**, **Branch** (defaults to the repository's default branch), and **Status**.
- **Code Security (SAST)** supports filtering by **Repository**, **Severity**, **Rule to remediate**, and a toggle to **Filter out findings identified as false positives by Bits AI**.

{% alert level="warning" %}
Each finding that triggers an automation is tied to a single session. Multiple findings cannot be fixed in a single session or pull request.
{% /alert %}

### Custom prompt trigger{% #custom-prompt-trigger %}

A custom prompt tells Bits Code what to do each time the automation runs, in freeform text, against a chosen repository. Use a custom prompt for recurring maintenance tasks that aren't tied to a specific Datadog signal, such as updating dependencies or refreshing documentation.

### Schedule trigger{% #schedule-trigger %}

A schedule trigger controls when an automation runs. It can be used in combination with a product finding or a custom prompt. When setting a schedule, you can choose from:

- **Every…**: Choose a preset interval (for example, `Every day at 09:00 am`).
- **Custom Schedule**: Choose specific days of the week and a time of day (for example, `Mo, We, Fr at 03:00 pm`).

## Outputs{% #outputs %}

An output defines what Bits Code does after a [session](https://docs.datadoghq.com/bits_ai/bits_ai_dev_agent.md#sessions) completes. An automation can have one or more outputs, including opening a pull request and generating a Slack notification.

### Pull request output{% #pull-request-output %}

You can configure your automation to:

- **Create a PR**: Open a pull request with the proposed changes
- **Draft a PR**: Open a draft pull request with the proposed changes

As the author of a Bits Code automation, you are the author of all pull requests it generates.

### Slack message output{% #slack-message-output %}

You can configure your automation to send a Slack message summarizing the [session](https://docs.datadoghq.com/bits_ai/bits_ai_dev_agent.md#sessions) and code changes. If you use a pull request output in addition to a Slack output, Bits Code includes a link to the pull request in the Slack message.

When you add a Slack message output, by default, Bits Code sends the message to the channel configured for the affected service in [Catalog](https://docs.datadoghq.com/internal_developer_portal/catalog.md). You can set a fallback Slack channel, which is used when no channel is set in Catalog.

## Manage automations{% #manage-automations %}

On [**Automations**](https://app.datadoghq.com/code/automations), view the automations you created on the **My Automations** tab. Switch to **All** to see automations created by anyone in your organization.

You can pause or resume any automation, but you can only edit or delete automations you created.

## Further reading{% #further-reading %}

- [Bits Code](https://docs.datadoghq.com/bits_ai/bits_ai_dev_agent.md)
