Skip to content

Advanced Templating

Filters

Filters transform variable output. They follow a pipe symbol after the variable:

{{ variable | filter }}

Common Filters

Text Transformation:

  • upcase: Convert to uppercase - {{ alert.severity | upcase }}CRITICAL
  • downcase: Convert to lowercase - {{ alert.service | downcase }}payment-processor
  • capitalize: Capitalize first letter - {{ alert.severity | capitalize }}Critical
  • strip: Remove leading/trailing whitespace - {{ message | strip }}

Date Formatting:

  • date: Format dates - {{ timestamp | date: "%Y-%m-%d %H:%M" }}2025-04-22 15:30

Number Formatting:

  • round: Round to nearest integer - {{ value | round }}95
  • floor: Round down - {{ value | floor }}94
  • ceil: Round up - {{ value | ceil }}95
  • divided_by: Division - {{ value | divided_by: 10 | round }}9

Array/Object Operations:

  • first: Get first item - {{ users | first }}
  • last: Get last item - {{ users | last }}
  • size: Count items - {{ users | size }}3

Chaining Filters

You can chain multiple filters together:

{{ timestamp | date: "%B %d, %Y" | upcase }}

This formats the date and then converts it to uppercase: APRIL 22, 2025

Advanced GitHub-Flavored Markdown Features

Relaye uses GitHub-flavored Markdown (GFM) for formatting across all platforms, with automatic conversion to each platform's native format behind the scenes. Here are some advanced GFM features you can use:

Warning

Note: The actual delivered message using these advanced features may appear different depending on the destination output/platform.

Footnotes

Here's a sentence with a footnote reference.[^1]

[^1]: This is the footnote content.

Syntax Highlighting

```json
{
  "name": "John Doe",
  "age": 30
}
def hello_world():
    print("Hello, world!")

Automatic URL Linking

URLs will automatically be converted to links:

https://relaye.io

Working with Complex Data

JSON Data

For complex JSON payloads, you can access nested data using dot notation:

{{ payload.data.attributes.user.profile.name }}

Arrays

Access array items by index:

{{ servers[0].name }}

Or loop through all items:

### Affected Servers:

{% for server in servers %}
- **{{ server.name }}**: {{ server.status }}
{% endfor %}

Working with Missing Data

Handle missing data gracefully with default values:

Status: {{ status | default: "Unknown" }}

Or with conditional checks:

{% if user.email %}
  Email: {{ user.email }}
{% else %}
  No email available
{% endif %}

Output Platform Compatibility

While Relaye handles the conversion from GitHub-flavored Markdown to each platform's native format automatically, it's good to be aware of certain limitations:

  1. Complex tables may not render consistently across all platforms
  2. Advanced formatting like footnotes might not be supported on all platforms
  3. Collapsible sections work in limited platforms

For the best cross-platform compatibility, focus on: - Headers - Bold and italic text - Simple lists - Code blocks - Links - Emojis

Template Examples

Monitoring Alert Template

{% if alert.severity == "critical" %}
# 🔴 {{ alert.name | upcase }}
{% elsif alert.severity == "warning" %}
## 🟠 {{ alert.name | upcase }}
{% else %}
### 🟢 {{ alert.name | upcase }}
{% endif %}

*{{ alert.message }}*

📊 **Metric**: {{ alert.metric_name }} = {{ alert.current_value }}{{ alert.unit }} (Threshold: {{ alert.threshold }}{{ alert.unit }})
🖥️ **Resource**: {{ alert.resource_name }}
⏰ **Detected at**: {{ alert.timestamp | date: "%H:%M:%S" }}

{% if alert.runbook_url %}[View Runbook]({{ alert.runbook_url }}){% endif %}

Deployment Notification Template

# 🚀 Deployment Update

**Status**: {% if status == "success" %}✅ Successful{% elsif status == "failed" %}❌ Failed{% else %}⏳ In Progress{% endif %}
**Project**: {{ project_name }}
**Version**: {{ version }}
**Environment**: {{ environment }}

{% if status == "failed" %}
### Error Details:
{{ error_message }}
{% endif %}

{% if changes.size > 0 %}
### Changes:
{% for change in changes %}
- **{{ change.id }}**: {{ change.description }} (by {{ change.author }})
{% endfor %}
{% endif %}

[View Details]({{ details_url }})

Customer Support Template

# 📨 New Support Ticket #{{ ticket.id }}

**From**: {{ ticket.customer.name }} ({{ ticket.customer.email }})
**Priority**: {% if ticket.priority == "high" %}🔴 High{% elsif ticket.priority == "medium" %}🟠 Medium{% else %}🟢 Low{% endif %}
**Category**: {{ ticket.category | capitalize }}

## Subject: {{ ticket.subject }}

{{ ticket.message | truncate: 200 }}

[View in Helpdesk]({{ ticket.url }})

Server Status Update Template

# Server Status Update: {{ server.hostname }}

{% if server.status == "down" %}
## 🔴 SERVER DOWN
{% elsif server.status == "degraded" %}
## 🟠 PERFORMANCE DEGRADED
{% else %}
## 🟢 OPERATING NORMALLY
{% endif %}

**Last checked**: {{ server.last_check | date: "%Y-%m-%d %H:%M:%S" }}
**Uptime**: {{ server.uptime | divided_by: 3600 | round }} hours

{% if server.metrics %}
### Current Metrics:
| Metric | Value | Status |
|--------|-------|--------|
{% for metric in server.metrics %}
| {{ metric.name }} | {{ metric.value }}{{ metric.unit }} | {% if metric.status == "ok" %}✅{% elsif metric.status == "warning" %}⚠️{% else %}❌{% endif %} |
{% endfor %}
{% endif %}

{% if server.status != "up" %}
### Recent Events:
{% for event in server.recent_events %}
- {{ event.timestamp | date: "%H:%M:%S" }}: {{ event.message }}
{% endfor %}
{% endif %}

By using GitHub-flavored Markdown consistently across all your templates, you can create readable, well-formatted notifications that will be automatically adapted to each platform's specific format while maintaining a consistent style.