Send notifications to Slack
Set up Slack webhook notifications with simple text templates and Block Kit JSON templates for rich formatting.
This recipe configures Planekeeper to send alert notifications to a Slack channel. Slack supports both simple text messages and rich Block Kit formatting through incoming webhooks.
Prerequisites
- A running Planekeeper instance with at least one alert config
- A Slack workspace where you can create apps
Step 1: Create a Slack incoming webhook
- Go to api.slack.com/apps and click Create New App
- Choose From scratch, name it
Planekeeper, and select your workspace - Go to Incoming Webhooks and toggle it On
- Click Add New Webhook to Workspace
- Select the channel where you want notifications
- Copy the webhook URL
The URL looks like: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Step 2: Create a notification channel in Planekeeper
- Navigate to Notification Channels in the sidebar
- Click Create Channel
- Fill in the fields:
| Field | Value |
|---|---|
| Name | Slack Alerts |
| Channel Type | webhook |
| URL | Paste your Slack webhook URL |
- Check Use Event-Specific Templates
- Add the templates from step 3 below
- Click Create
Step 3: Add Slack templates
Choose either simple text templates or Block Kit templates depending on how much formatting you want.
Simple text
### New alert template
```json title="New Alert / Escalated"
{"text": ":rotating_light: *{{.Alert.Severity | upper}}*: {{.Alert.ConfigName}}\nArtifact: {{.Alert.ArtifactName}}\nVersion {{.Alert.DiscoveredVersion}} is {{.Alert.BehindBy}} behind latest ({{.Alert.LatestVersion}})\n<{{.AcknowledgeURL}}|Click to Acknowledge>"}
```
### Acknowledged template
```json title="Acknowledged / Unacknowledged"
{"text": "{{if .IsAcknowledged}}:white_check_mark: *Acknowledged*{{else}}:arrows_counterclockwise: *Unacknowledged*{{end}}: {{.Alert.ConfigName}} - {{.Alert.ArtifactName}}{{if .IsAcknowledged}}\nAcknowledged by {{.AcknowledgedBy}}{{end}}"}
```
### Resolved template
```json title="Resolved"
{"text": ":tada: *Resolved*: {{.Alert.ConfigName}} - {{.Alert.ArtifactName}}\nThe alert has been automatically resolved."}
```
Block Kit (rich format)
### New alert template
```json title="New Alert / Escalated (Block Kit)"
{"blocks": [{"type": "header", "text": {"type": "plain_text", "text": "{{.Alert.Severity | upper}} Alert"}}, {"type": "section", "fields": [{"type": "mrkdwn", "text": "*Config:*\n{{.Alert.ConfigName}}"}, {"type": "mrkdwn", "text": "*Artifact:*\n{{.Alert.ArtifactName}}"}, {"type": "mrkdwn", "text": "*Current:*\n{{.Alert.DiscoveredVersion}}"}, {"type": "mrkdwn", "text": "*Latest:*\n{{.Alert.LatestVersion}}"}]}, {"type": "actions", "elements": [{"type": "button", "text": {"type": "plain_text", "text": "Acknowledge"}, "url": "{{.AcknowledgeURL}}", "style": "primary"}]}]}
```
### Acknowledged template
```json title="Acknowledged / Unacknowledged (Block Kit)"
{"blocks": [{"type": "section", "text": {"type": "mrkdwn", "text": "{{if .IsAcknowledged}}:white_check_mark: *Acknowledged*: {{.Alert.ConfigName}}\nBy {{.AcknowledgedBy}}{{else}}:arrows_counterclockwise: *Unacknowledged*: {{.Alert.ConfigName}}{{end}}"}}]}
```
### Resolved template
```json title="Resolved (Block Kit)"
{"blocks": [{"type": "section", "text": {"type": "mrkdwn", "text": ":tada: *Resolved*: {{.Alert.ConfigName}} - {{.Alert.ArtifactName}}\nThe alert has been automatically resolved."}}]}
```
Step 4: Test the channel
- Go to Notification Channels and find
Slack Alerts - Click Test
- Check your Slack channel for the test message
- If the test fails, verify:
- The webhook URL is correct
- The Slack app is still installed in your workspace
- The target channel still exists
Step 5: Create a notification rule
- Navigate to Notification Rules in the sidebar
- Click Create Rule
- Fill in the fields:
| Field | Value |
|---|---|
| Name | All Alerts to Slack |
| Channel | Select Slack Alerts |
| Severity Filter | Leave empty (matches all severities) |
| Event Filter | Leave empty (matches all events) |
- Click Create
Routing different severities to different channels
Create separate Slack channels and notification rules for different severity levels:
| Notification rule | Severity filter | Slack channel |
|---|---|---|
| Critical to Pager Channel | critical | #ops-critical |
| High to Alerts Channel | high | #ops-alerts |
| Moderate to Info Channel | moderate | #ops-info |
This requires creating three notification channels in Planekeeper (one per Slack channel) and three notification rules with different severity filters.
Use Block Kit for critical alerts
Block Kit formatting with the acknowledge button is especially useful for critical alerts where you want one-click acknowledgment directly from Slack.