# Custom Content Templates

Custom Content Templates empower users to define personalized Incident messages and description templates by utilizing the payload of a configured alert source for this service. If there is a template configured, the incoming Incident will have a customized message and description.

In the absence of user-defined templates, the system will default to using the Incident message and description templates defined by Squadcast, which is the current behavior.

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>: This feature is available only in the Premium and Enterprise [<mark style="color:blue;">plans</mark>](https://www.squadcast.com/pricing).
{% endhint %}

## Prerequisites

The User Role associated with the user in the Team must have required permissions to manage Services (ability to manage Custom Content Templates).

## Create Custom Content Templates

To add a custom content template,

1. Navigate to **Services** -> **Service Overview** -> Select or search for your desired service.
2. Expand the accordion -> **View Service Details.**
3. In the **Custom Content Templates** section -> Click **+ Template**
4. Select an **Alert Source** from the drop-down -> **Define Templates**

{% hint style="info" %}
**Note**: For additional information on how to write templates, refer [<mark style="color:blue;">Go’s standard library</mark>](https://developer.hashicorp.com/nomad/tutorials/templates/go-template-syntax).
{% endhint %}

5. Establish the template for the **Incident Message** and **Description** -> Refer to the **Output** section to preview the appearance of your configured template.

<details>

<summary><mark style="color:blue;">Here are some illustrative examples that demonstrate how to define a template for an Incident Message and Description</mark>.</summary>

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-8a5bf73a2875148b6acb6f3eb6a959193b67507b%2FScreenshot%202023-08-03%20at%202.53.05%20PM.png?alt=media) ![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-7dacbea85a02df420eae9b4739b1865c817e373e%2FScreenshot%202023-08-03%20at%202.58.03%20PM.png?alt=media)

</details>

6. Click **Save**.

<details>

<summary><mark style="color:blue;"><strong>Regular Expression-Based Extraction in Go Template</strong></mark></summary>

Our system supports regular expression-based extraction using regex rules. It allows for multiple name captures but only retains the first match for a specific named group. Additionally, when the passed expression is not valid, the function returns empty match results.

<pre class="language-go"><code class="lang-go"><strong>{{- with $matches := ("(?m)^Container: (?P&#x3C;container>.*)|Alertname: (?P&#x3C;alertname>.*)|Summary: (?P&#x3C;summary>.*)$" | reExtract .description) -}}
</strong>    {{$matches.container}}-{{$matches.alertname}}
{{- end -}}
</code></pre>

This code snippet is a template written in Go's text templating language, used to parse alert descriptions. It extracts specific details like container name, alert name, and summary from the descriptions using regular expressions and presents them in a concise format.

Here's a breakdown:

1. Regular Expression (`(?m)^Container: (?P<container>.*)|Alertname: (?P<alertname>.*)|Summary: (?P<summary>.*)$`):
   * `(?m)` enables multiline matching.
   * `^Container: (?P<container>.*)` captures everything after "Container: " into a named group "container".
   * `|Alertname: (?P<alertname>.*)` captures everything after "Alertname: " into a named group "alertname".
   * `|Summary: (?P<summary>.*)$` captures everything after "Summary: " into a named group "summary" and ensures it matches the end of the line (`$`).
2. Template Processing (`{{$matches := ...}}`):
   * The code defines a variable `$matches` using the regular expression to extract details from the description string `.description`.
3. Output Formatting (`{{$matches.container}}-{{$matches.alertname}}`)
   * The template accesses the captured container name (`$matches.container`) and alert name (`$matches.alertname`) from the `$matches` variable.
   * It combines them with a hyphen (-) for a one-line description format.

</details>

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>: Please keep in mind that notifications for these incidents will feature the provided custom incident message and will follow applicable notification guidelines.
{% endhint %}

## Delete Custom Content Templates

To delete a custom content template,

1. Click on the **Custom Content Template** for a selected Service.
2. On the right-hand side, click **More Options** -> **Delete Template**
3. A confirmation modal will appear -> Click **Delete** again to confirm.

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.squadcast.com/services/custom-content-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
