Skip to content

Commit 578f3e9

Browse files
committed
fix: correct Slack webhook example code in documentation
- Fix ReferenceError by changing 'text: body' to 'text: body_markdown' on line 118 (the variable 'body' was never defined; should use 'body_markdown' from req.body) - Fix invalid_blocks API error by changing header block text type from 'mrkdwn' to 'plain_text' on line 122 (Slack's header block type only supports plain_text, not mrkdwn) - Rename 'title_markdown' to 'title' since the header block uses plain_text type, not markdown (variable names should reflect their actual content) These errors were preventing webhook messages from being sent to Slack.
1 parent 55f4efd commit 578f3e9

File tree

1 file changed

+5
-5
lines changed
  • docs/admin/monitoring/notifications

1 file changed

+5
-5
lines changed

docs/admin/monitoring/notifications/slack.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ To build the server to receive webhooks and interact with Slack:
8989
return res.status(400).send("Error: request body is missing");
9090
}
9191

92-
const { title_markdown, body_markdown } = req.body;
93-
if (!title_markdown || !body_markdown) {
92+
const { title, body_markdown } = req.body;
93+
if (!title || !body_markdown) {
9494
return res
9595
.status(400)
96-
.send('Error: missing fields: "title_markdown", or "body_markdown"');
96+
.send('Error: missing fields: "title", or "body_markdown"');
9797
}
9898

9999
const payload = req.body.payload;
@@ -115,11 +115,11 @@ To build the server to receive webhooks and interact with Slack:
115115

116116
const slackMessage = {
117117
channel: userByEmail.user.id,
118-
text: body,
118+
text: body_markdown,
119119
blocks: [
120120
{
121121
type: "header",
122-
text: { type: "mrkdwn", text: title_markdown },
122+
text: { type: "plain_text", text: title },
123123
},
124124
{
125125
type: "section",

0 commit comments

Comments
 (0)