> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/ai-sre/3.0/ai-sre-for-administrators/set-up-runbook-management/workflows/use-mustache-runbook-actions.md).

# Use Mustache Templates in Runbook Actions

Mustache templates provide simple variable substitution in runbook actions. Use Mustache when you need to insert dynamic values from incidents, alerts, or previous action outputs into your runbook actions.

### How to reference fields <a href="#how-to-reference-fields" id="how-to-reference-fields"></a>

When configuring runbook actions in the UI:

1. Click an action input field that supports dynamic values (marked with a data picker icon)
2. Click the **data picker button** (looks like a database icon)
3. Select the field source:
   * **Incident** - Fields from the current incident
   * **Alert** - Fields from the triggering alert
   * **Runbook Inputs** - Variables defined in the Input/Output section
   * **Action Outputs** - Results from previous actions
4. Select the specific field
5. The Mustache variable is automatically inserted: `{{incident.service}}`

Alternatively, you can type Mustache syntax directly: `{{incident.field_name}}`

***

### Example: Slack message with incident details <a href="#example-slack-message-with-incident-details" id="example-slack-message-with-incident-details"></a>

**Action**: Slack: Post Message

**Channel**: `#incidents`

**Message** (configured in form field):

```mustache
🔥 **New {{incident.severity}} Incident**

**Title**: {{incident.title}}
**Service**: {{incident.service}}
**Environment**: {{incident.environment}}
**Owner**: {{incident.owner}}
**Status**: {{incident.status}}

**View Details**: {{incident.url}}
```

**Result**: When the runbook runs, Mustache variables are replaced with actual values:

```
🔥 **New SEV1 Incident**

**Title**: Payment Service High Error Rate
**Service**: payment-service
**Environment**: production
**Owner**: Jane Smith
**Status**: investigating

**View Details**: https://app.harness.io/incidents/INC-456
```

**CEL alternative with conditional logic**:

```
${{incident.severity in ["0", "1"] ? "🚨🚨🚨" : "🔥"}}
**New ${{
  incident.severity == "0" ? "CRITICAL" : "SEV" + incident.severity
}} Incident**

**Title**: ${{incident.title}}
**Service**: ${{incident.service}}
**Environment**: ${{
  incident.environment == "production" ?
  "🔴 PRODUCTION" : incident.environment
}}
**Owner**: ${{
  incident.owner != null ? incident.owner : "⚠️ UNASSIGNED"
}}
**Status**: ${{incident.status}}
**Priority**: ${{
  incident.severity in ["0", "1"] ?
  "IMMEDIATE ACTION REQUIRED" : "Normal triage"
}}

**View Details**: ${{incident.url}}
```

***

### Example: Conditional routing for Slack <a href="#example-conditional-routing-for-slack" id="example-conditional-routing-for-slack"></a>

Use runbook triggers to create conditional behavior based on field values.

**Pattern**: Route P1 alerts to `#critical-incidents`, others to `#incidents`

**Implementation**:

1. Create two runbooks:
   * **P1 Alert Handler**:
     * Trigger: Alert created with `alert.priority equals p1_critical`
     * Action: Slack post to `#critical-incidents`
   * **Standard Alert Handler**:
     * Trigger: Alert created with `alert.priority in [p2_error, p3_warning, p4_info]`
     * Action: Slack post to `#incidents`

Go to [Create runbook triggers](/ai-sre/ai-sre-for-administrators/set-up-runbook-management/triggers/create-trigger.md) to configure conditional execution.

***

### Example: Jira ticket with incident context <a href="#example-jira-ticket-with-incident-context" id="example-jira-ticket-with-incident-context"></a>

**Action**: Jira: Create Issue

**Form Configuration**:

* **Project**: `INCIDENT` (static value)
* **Issue Type**: `Incident` (static value)
* **Summary** (form field with data picker):

  ```mustache
  [{{incident.severity}}] {{incident.title}}
  ```
* **Description** (form field with data picker):

  ```mustache
  Incident Details:
  - **Service**: {{incident.service}}
  - **Environment**: {{incident.environment}}
  - **Severity**: {{incident.severity}}
  - **Status**: {{incident.status}}
  - **Created**: {{incident.created_at}}

  View in AI SRE: {{incident.url}}
  ```
* **Priority** (form field with data picker):

  ```mustache
  {{incident.severity}}
  ```

**Result**: Jira ticket is created with all incident context embedded.

**CEL alternative with dynamic priority logic**:

**Summary field**:

```
[${{
  incident.severity == "0" ? "P0-CRITICAL" :
  incident.severity == "1" ? "P1-HIGH" : "P2"
}}] ${{incident.title}}
```

**Description field**:

```
Incident Details:
- **Service**: ${{incident.service}}
- **Environment**: ${{
    incident.environment == "production" ?
    "🔴 PRODUCTION" : incident.environment
  }}
- **Severity**: SEV${{incident.severity}} (${{
    incident.severity == "0" ? "Critical outage" :
    incident.severity == "1" ? "Major incident" :
    "Moderate issue"
  }})
- **Status**: ${{incident.status}}
- **Created**: ${{incident.created_at}}

${{
  incident.affected_users != null &&
  incident.affected_users > 0 ?
  "**User Impact**: " + string(incident.affected_users) +
  " users affected\n" : ""
}}

**Required Actions**:
${{
  incident.severity in ["0", "1"] ?
  "- Page on-call team IMMEDIATELY\n- Start incident bridge\n- Update status page" :
  "- Assign to service team\n- Triage within SLA"
}}

View in AI SRE: ${{incident.url}}
```

***

### Example: HTTP request with alert data <a href="#example-http-request-with-alert-data" id="example-http-request-with-alert-data"></a>

**Action**: HTTP Request

**Form Configuration**:

* **URL** (form field):

  ```mustache
  https://api.example.com/alerts/{{alert.id}}/acknowledge
  ```
* **Method**: `POST` (dropdown)
* **Body** (form field with data picker):

  ```json
  {
    "alert_id": "{{alert.id}}",
    "service": "{{alert.service}}",
    "priority": "{{alert.priority}}",
    "acknowledged_by": "AI SRE Runbook"
  }
  ```

***

### Example: Reference previous action outputs <a href="#example-reference-previous-action-outputs" id="example-reference-previous-action-outputs"></a>

Actions can reference outputs from previous actions in the same runbook.

**Action 1**: Zoom: Create Meeting

* Outputs: `join_url`, `meeting_id`, `passcode`

**Action 2**: Slack: Post Message

* **Message** (referencing Action 1 output):

  ```mustache
  🎥 **Incident Bridge Created**

  Join the call:
  {{runbook.outputs.zoom_create_meeting.join_url}}
  Meeting ID:
  {{runbook.outputs.zoom_create_meeting.meeting_id}}
  Passcode:
  {{runbook.outputs.zoom_create_meeting.passcode}}

  **Incident**: {{incident.title}}
  ```

The data picker automatically shows available outputs from previous actions.

***

### Next steps <a href="#next-steps" id="next-steps"></a>

* Go to [Use CEL in runbook actions](/ai-sre/ai-sre-for-administrators/set-up-runbook-management/workflows/use-cel-runbook-actions.md) to implement conditional logic and transformations.
* Go to [Use system fields in runbook actions](/ai-sre/ai-sre-for-administrators/set-up-runbook-management/workflows/use-system-fields-in-runbook-actions.md) to learn about available system fields.
* Go to [Best practices](/ai-sre/ai-sre-for-administrators/set-up-runbook-management/workflows/best-practices.md) to review field usage guidelines.
