Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit b649094

Browse files
author
CJ Anslow
committed
add advanced slack custom message use case
1 parent 75972e0 commit b649094

1 file changed

Lines changed: 207 additions & 0 deletions

File tree

site/content/docs/integrations/slack.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,210 @@ We provide a lot of information in the initial Slack message including links to
3333
From the recovered Slack message, you can see the timestamp as well as a link to the check itself.
3434

3535
![A slack message showing a recovered alert](/docs/images/alerting/slack-recovered-check.png)
36+
37+
---
38+
39+
## Custom Slack Webhook Integration (Advanced)
40+
41+
For advanced users who need more control over the Slack alert format and content, you can use a **Webhook Alert Channel** in Checkly to send fully customized messages to Slack.
42+
43+
This approach is ideal when the native Slack integration does not meet your formatting or dynamic content needs.
44+
45+
### Setup Overview
46+
47+
You will be using a `WebhookAlertChannel` construct with a Slack Incoming WebHook URL and a custom payload template. This setup allows you to:
48+
49+
- Control Slack message formatting using Slack's [Block Kit](https://api.slack.com/block-kit)
50+
- Show detailed check information such as:
51+
- Check name and ID
52+
- Run location and start time
53+
- Response time
54+
- Error messages (on failure)
55+
- Recovery or degraded state
56+
- Link directly to a runbook or documentation for the failing check
57+
58+
### Setting It Up
59+
60+
1. **Create a Slack Webhook**
61+
- Follow Step 1 from the main section above to generate a Webhook URL in Slack.
62+
- Choose the bot name and icon for your alerts.
63+
64+
2. **Create a Webhook Alert Channel in Checkly**
65+
- Go to **Alert Settings > Add More Channels > Webhook**
66+
- Fill in the following:
67+
- **Name**: e.g. `Custom Slack Alerts`
68+
- **URL**: Paste the Slack Webhook URL
69+
- **Method**: `POST`
70+
- **Send Alerts for**: Enable `Failure`, `Recovery`, and `Degraded`
71+
- **SSL Expiry**: Optional, not supported in this template
72+
- **Template**: See below
73+
74+
3. **Customize the Template**
75+
76+
The following template uses conditional logic (`{{#if}}`) to change the message depending on the alert type:
77+
78+
```
79+
{
80+
"attachments": [
81+
{
82+
{{#if (eq ALERT_TYPE "ALERT_FAILURE")}}
83+
"color": "#a30200",
84+
{{/if}}
85+
{{#if (eq ALERT_TYPE "ALERT_RECOVERY")}}
86+
"color": "#2eb886",
87+
{{/if}}
88+
{{#if (eq ALERT_TYPE "ALERT_DEGRADED_RECOVERY")}}
89+
"color": "#2eb886",
90+
{{/if}}
91+
{{#if (eq ALERT_TYPE "ALERT_DEGRADED")}}
92+
"color": "#daa038",
93+
{{/if}}
94+
"blocks": [
95+
{
96+
"type": "header",
97+
"text": {
98+
"type": "plain_text",
99+
"text": "Check Result Details",
100+
"emoji": true
101+
}
102+
},
103+
{
104+
"type": "section",
105+
"fields": [
106+
{
107+
"type": "mrkdwn",
108+
"text": "*Check:*\n<https://app.checklyhq.com/checks/{{CHECK_ID}}|{{CHECK_NAME}}>"
109+
},
110+
{{#if GROUP_NAME}}
111+
{
112+
"type": "mrkdwn",
113+
"text": "*Group:*\n{{GROUP_NAME}}"
114+
},
115+
{{/if}}
116+
{
117+
"type": "mrkdwn",
118+
"text": "*Type:*\n{{CHECK_TYPE}}"
119+
},
120+
{
121+
"type": "mrkdwn",
122+
"text": "*Started at:*\n{{STARTED_AT}}"
123+
},
124+
{
125+
"type": "mrkdwn",
126+
"text": "*Run Location:*\n`{{RUN_LOCATION}}`"
127+
},
128+
{
129+
"type": "mrkdwn",
130+
"text": "*Response Time:*\n{{RESPONSE_TIME}}ms"
131+
}
132+
{{#if API_CHECK_RESPONSE_STATUS_CODE}},
133+
{
134+
"type": "mrkdwn",
135+
"text": "*Status Code:*\n{{API_CHECK_RESPONSE_STATUS_CODE}} {{API_CHECK_RESPONSE_STATUS_TEXT}}"
136+
}
137+
{{/if}}
138+
]
139+
},
140+
{{#if CHECK_ERROR_MESSAGE}}
141+
{
142+
"type": "section",
143+
"text": {
144+
"type": "mrkdwn",
145+
"text": "*❌ Error Message:*\n```{{CHECK_ERROR_MESSAGE}}```"
146+
}
147+
},
148+
{{/if}}
149+
150+
{{#if (eq ALERT_TYPE "ALERT_RECOVERY")}}
151+
{
152+
"type": "section",
153+
"text": {
154+
"type": "mrkdwn",
155+
"text": "✅ *This check has recovered and is now passing successfully.*"
156+
}
157+
},
158+
{{/if}}
159+
160+
{{#if (eq ALERT_TYPE "ALERT_DEGRADED_RECOVERY")}}
161+
{
162+
"type": "section",
163+
"text": {
164+
"type": "mrkdwn",
165+
"text": "🟡 *This check has recovered from a degraded state.*"
166+
}
167+
},
168+
{{/if}}
169+
170+
{{#if (eq ALERT_TYPE "ALERT_DEGRADED")}}
171+
{
172+
"type": "section",
173+
"text": {
174+
"type": "mrkdwn",
175+
"text": "⚠️ *This check is running but performance is degraded.*"
176+
}
177+
},
178+
{{/if}}
179+
180+
{
181+
"type": "section",
182+
"text": {
183+
"type": "mrkdwn",
184+
"text": "🔎 *View full result:*\n<{{RESULT_LINK}}|Click here to view details in Checkly>"
185+
}
186+
},
187+
{
188+
"type": "actions",
189+
"elements": [
190+
{
191+
"type": "button",
192+
"text": {
193+
"type": "plain_text",
194+
"text": "Runbook",
195+
"emoji": true
196+
},
197+
{{#if (eq CHECK_NAME "Check A")}}
198+
"url": "https://example.com/check-a",
199+
{{else if (eq CHECK_NAME "Check B")}}
200+
"url": "https://example.com/check-b",
201+
{{else}}
202+
"url": "https://example.com/default",
203+
{{/if}}
204+
"action_id": "open_link_button"
205+
},
206+
{
207+
"type": "button",
208+
"text": {
209+
"type": "plain_text",
210+
"text": "OTel Provider",
211+
"emoji": true
212+
},
213+
"url": "https://example.com",
214+
"action_id": "open_link_button_needs_to_be_unique"
215+
}
216+
]
217+
},
218+
{
219+
"type": "context",
220+
"elements": [
221+
{
222+
"type": "plain_text",
223+
"text": "Tags: {{TAGS}} | UUID: {{CHECK_RESULT_ID}}",
224+
"emoji": false
225+
}
226+
]
227+
}
228+
]
229+
}
230+
]
231+
}
232+
```
233+
234+
>[!NOTE]
235+
> Be sure to update or remove the placeholder button links to Runbooks, OTel provider and anything else that is not needed for your use case.
236+
237+
>[!NOTE]
238+
> Be sure each check mapped in the runbook logic has a corresponding URL. If a match isn’t found, fallback to a default documentation page.
239+
240+
### Testing the Webhook limitations
241+
* You cannot use the Test Webhook button in Checkly for this template, as Slack requires valid payload structure and the test payload lacks real check data.
242+
* To test, trigger a real alert by adjusting a check so it fails, degrades, and recovers.

0 commit comments

Comments
 (0)