Skip to main content

Telegram

Notification

Synopsis

Sends alert notifications to Telegram chats using the Bot API, supporting HTML and Markdown formatting, severity-based emojis, silent notifications, and configurable message options.

Schema

- telegram:
bot_token: <string>
chat_id: <string>
message: <string>
parse_mode: <string>
disable_notification: <boolean>
disable_web_page_preview: <boolean>
severity: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

FieldRequiredDefaultDescription
bot_tokenN${TELEGRAM_BOT_TOKEN}Telegram bot token
chat_idN${TELEGRAM_CHAT_ID}Target chat ID (user, group, or channel)
messageY-Message text to send
parse_modeNHTMLText formatting mode: HTML, Markdown, or MarkdownV2
disable_notificationNfalseSend message silently without notification sound
disable_web_page_previewNfalseDisable link preview generation
severityN-Severity level for emoji prefix: info, warning, critical, or resolved
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseSee Handling Failures
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

The telegram processor sends notifications to Telegram chats using the Bot API.

Bot Setup: Create a Telegram bot:

  1. Message @BotFather on Telegram
  2. Send /newbot and follow the prompts
  3. Copy the bot token provided
  4. Add the bot to your target chat/group/channel

Chat ID: The target for messages. Types include:

  • Positive numbers: Private chats with users
  • Negative numbers: Group chats (e.g., -1001234567890)
  • Channel usernames: @channelname

Parse Modes: Control text formatting:

  • HTML: Use HTML tags (<b>, <i>, <code>, <a href="">, etc.)
  • Markdown: Use Markdown syntax (*bold*, _italic_, backticks for code)
  • MarkdownV2: Enhanced Markdown with more features

Severity Emojis: When severity is set, an emoji prefix is added:

  • resolved / success / good: ✔️
  • critical / danger / error: ‼️
  • warning / high: ⚠️
  • info / low: ℹ️

Silent Notifications: Set disable_notification: true for non-urgent messages that shouldn't trigger notification sounds.

Template Support: All string fields support Go template syntax with event field interpolation using {{ .field_name }}.

For integration patterns with schema validation, see Schema Drift Detection.

Examples

Basic Alert

Sending a simple alert notification...

{
"alert_name": "High CPU Usage",
"server": "prod-server-01",
"cpu_usage": "95%"
}
- telegram:
bot_token: "${TELEGRAM_BOT_TOKEN}"
chat_id: "${TELEGRAM_CHAT_ID}"
message: "Alert: {{ .alert_name }}\nCPU usage is at {{ .cpu_usage }} on server {{ .server }}"
severity: "critical"

Message sent with ‼️ critical emoji prefix...

HTML Formatting

Using HTML formatting for rich messages...

{
"alert_type": "Schema Drift",
"schema": "ASimNetworkSessionLogs",
"missing": "3 required fields"
}
- telegram:
bot_token: "${TELEGRAM_BOT_TOKEN}"
chat_id: "${TELEGRAM_CHAT_ID}"
message: "<b>{{ .alert_type }} Detected</b>\n<i>Schema:</i> {{ .schema }}\n<u>Missing:</u> {{ .missing }}"
parse_mode: "HTML"
severity: "warning"

Bold title with italic and underlined labels...

Markdown Formatting

Using Markdown for simpler formatting...

{
"server": "db-server-01",
"status": "Connection Failed",
"details": "Unable to establish connection"
}
- telegram:
bot_token: "${TELEGRAM_BOT_TOKEN}"
chat_id: "${TELEGRAM_CHAT_ID}"
message: "*Server:* {{ .server }}\n*Status:* {{ .status }}\n_Details:_ {{ .details }}"
parse_mode: "Markdown"
severity: "critical"

Markdown formatting with bold and italic text...

Silent Notification

Sending non-urgent information silently...

{
"info": "System maintenance scheduled"
}
- telegram:
bot_token: "${TELEGRAM_BOT_TOKEN}"
chat_id: "${TELEGRAM_CHAT_ID}"
message: "{{ .info }}"
disable_notification: true
severity: "info"

Message delivered without notification sound...

Complete Alert

Full-featured alert with all formatting options...

{
"alert_type": "Critical System Alert",
"server": "prod-web-01",
"cpu_usage": "95%",
"memory_used": "87%",
"disk_space": "92%",
"uptime": "45 days",
"dashboard": "https://monitoring.example.com/prod-web-01"
}
- telegram:
bot_token: "${TELEGRAM_BOT_TOKEN}"
chat_id: "${TELEGRAM_CHAT_ID}"
message: |
<b>{{ .alert_type }}</b>

<b>Server:</b> <code>{{ .server }}</code>
<b>Uptime:</b> {{ .uptime }}

<b>Resource Usage:</b>
• CPU: {{ .cpu_usage }}
• Memory: {{ .memory_used }}
• Disk: {{ .disk_space }}

<a href="{{ .dashboard }}">View Dashboard</a>

<i>Action required: Resources critically high</i>
parse_mode: "HTML"
severity: "critical"
disable_web_page_preview: false

Rich formatted message with dashboard link preview...

Schema Drift Alert

Alerting on schema validation failures...

processors:
- check_schema:
schema: "ASimNetworkSessionLogs"
target_field: "schema_check"
on_missing:
- telegram:
bot_token: "${TELEGRAM_BOT_TOKEN}"
chat_id: "${TELEGRAM_CHAT_ID}"
message: |
<b>Schema Validation Failed</b>

<b>Schema:</b> ASimNetworkSessionLogs
<b>Status:</b> Invalid

<i>Please update your schema to include all required fields.</i>
parse_mode: "HTML"
severity: "warning"

Alert triggered automatically when schema drift detected...

Dynamic Chat ID

Routing messages to different chats based on event data...

{
"chat_id": "-1001234567890",
"message": "Alert for specific team"
}
- telegram:
bot_token: "${TELEGRAM_BOT_TOKEN}"
chat_id: "{{ .chat_id }}"
message: "{{ .message }}"
severity: "info"

Message routed to team-specific chat...