# Alert Templates

Customize the [Slack](https://docs.paradime.io/app-help/documentation/integrations/notifications/slack) and [Microsoft Teams](https://docs.paradime.io/app-help/documentation/integrations/notifications/microsoft-teams) notifications sent by your Bolt Schedules. Using Jinja2 syntax, templates let you control exactly what your alerts say, surfacing the run context your team needs, in the format that works for them.

{% hint style="info" %}
Templates are created once in the Alert Templates page and can then be attached to any channel destination across your schedules.
{% endhint %}

***

### Creating a Template

1. Navigate to **Bolt > Alert Templates** in the top navigation
2. Click **+ New Template**
3. Give your template a name
4. Write your message using plain text, template variables, and Jinja expressions
5. Save the template

<div data-with-frame="true"><figure><img src="https://2337193041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHET0AD04uHMgdeLAjptq%2Fuploads%2FSBQZdw57ALlcxPCqjuyh%2Fimage.png?alt=media&#x26;token=6adee161-0dcd-4070-8877-b99f5c725cb2" alt=""><figcaption></figcaption></figure></div>

### Attaching a Template to a Schedule

1. Open the Bolt Schedule you want to configure
2. Navigate to the **Notification Settings** tab
3. Under **Notification Destinations**, locate the Slack or MS Teams channel you want to customize
4. Select your saved template from the template dropdown on that channel row
5. Click **Deploy** to save your changes

<div data-with-frame="true"><figure><img src="https://2337193041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHET0AD04uHMgdeLAjptq%2Fuploads%2FjLyLfgqN6RXjlnW9Tt2f%2Fimage.png?alt=media&#x26;token=43768b13-638a-4753-9bd9-e9c973ab7c94" alt=""><figcaption></figcaption></figure></div>

***

### Template Variables

Templates use Jinja2 syntax. The following variables are available:

{% tabs %}
{% tab title="Schedule" %}

| Variable               | Description                 |
| ---------------------- | --------------------------- |
| `{{ schedule_name }}`  | Name of the Bolt Schedule   |
| `{{ schedule_owner }}` | Owner email of the schedule |
| {% endtab %}           |                             |

{% tab title="Run" %}

| Variable             | Description                                        |
| -------------------- | -------------------------------------------------- |
| `{{ status }}`       | Run completion status (e.g. "succeeded", "failed") |
| `{{ status_emoji }}` | Emoji representing the run status                  |
| `{{ run_link }}`     | URL link to the run in Paradime                    |
| `{{ run_uuid }}`     | UUID of the run                                    |
| `{{ start_dttm }}`   | Run start datetime                                 |
| `{{ end_dttm }}`     | Run end datetime                                   |
| `{{ duration }}`     | Run duration (e.g. "5m 32s")                       |
| {% endtab %}         |                                                    |

{% tab title="Environment" %}

| Variable               | Description                    |
| ---------------------- | ------------------------------ |
| `{{ workspace_name }}` | Name of the Paradime workspace |
| `{{ branch }}`         | Git branch used for the run    |
| `{{ commit_hash }}`    | Git commit hash                |
| `{{ actor }}`          | User who triggered the run     |
| {% endtab %}           |                                |

{% tab title="Commands" %}
`{{ commands }}` is a list of objects, one per dbt command in the schedule. Each object contains:

| Field          | Description                  |
| -------------- | ---------------------------- |
| `command`      | The dbt command string       |
| `status`       | Completion status            |
| `status_emoji` | Emoji for the command status |
| `duration`     | Duration string              |
| `start_dttm`   | Command start datetime       |
| `end_dttm`     | Command end datetime         |
| {% endtab %}   |                              |

{% tab title="Errors" %}

| Variable              | Description                         |
| --------------------- | ----------------------------------- |
| `{{ error_command }}` | The command that errored, or `None` |
| `{{ error_output }}`  | The error output text, or `None`    |
| {% endtab %}          |                                     |
| {% endtabs %}         |                                     |

#### Filters & Helpers

| Syntax                                                | Description                                                                                           |
| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `{{ start_dttm \| date_format('YYYY-MM-DD HH:mm') }}` | Format a datetime string. Supported tokens: `YYYY`, `YY`, `MMMM`, `MMM`, `MM`, `DD`, `HH`, `mm`, `ss` |
| `{{ duration(start_dttm, end_dttm) }}`                | Compute duration between two datetime strings                                                         |

***

### Example Template

<div data-with-frame="true"><figure><img src="https://2337193041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHET0AD04uHMgdeLAjptq%2Fuploads%2F0WDWYsElejsOYZwYEbi2%2Fimage.png?alt=media&#x26;token=912d4163-ec61-4dda-b73e-3405c6178b79" alt=""><figcaption></figcaption></figure></div>

{% code fullWidth="false" %}

````jinja
*Bolt run complete*
*{{schedule_name}}* {{status}}
Owner · {{schedule_owner}}
Started · {{start_dttm}}
Duration · {{duration}}

*Commands*

{% for cmd in commands %}
`{{cmd.command}}` | {{cmd.status_emoji}} | {{cmd.duration}} | {{cmd.end_dttm}}
{% endfor %}

{% if error_output %}
*Overview*
```
{{error_output}}
```
{% endif %}

{{run_link}}
📒 Error Resolution Playbook
https://www.notion.so/paradime/On-Call-Pipeline-Failure-Playbook-322324b99ab380569472cdfa44b178a0?showMoveTo=true&saveParent=true
````

{% endcode %}
