Skip to main content

Rich-formatted alert

Use native rich-text values to emphasize an operational notice without constructing raw Block Kit JSON.

Output

Local preview of the selected language’s tested example. Slack client appearance may differ; controls here do not send requests.

Deployed api version 3.1.0. View dashboard.
Serialized output
{
"channel": "C1",
"mrkdwn": true,
"blocks": [
{
"type": "rich_text",
"block_id": "<generated-block-id>",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Deployed "
},
{
"type": "text",
"text": "api",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " version "
},
{
"type": "text",
"text": "3.1.0",
"style": {
"code": true
}
},
{
"type": "text",
"text": ". "
},
{
"type": "link",
"url": "https://status.example.com",
"text": "View dashboard"
},
{
"type": "text",
"text": "."
}
]
}
]
}
],
"text": "Deployed api 3.1.0"
}

Code​

Use RichTextBlock when you want inline bold/italic/code styling without writing markdown by hand.

from slackblocks import (
Message,
RichText,
RichTextBlock,
RichTextLink,
RichTextSection,
)


def deploy_alert(*, channel: str, service: str, version: str, dashboard_url: str) -> Message:
return Message(
channel=channel,
text=f"Deployed {service} {version}",
blocks=[
RichTextBlock(
RichTextSection(
elements=[
RichText(text="Deployed "),
RichText(text=service, bold=True),
RichText(text=" version "),
RichText(text=version, code=True),
RichText(text=". "),
RichTextLink(url=dashboard_url, text="View dashboard"),
RichText(text="."),
],
),
),
],
)
print(deploy_alert(channel="C1", service="api", version="3.1.0", dashboard_url="https://status.example.com").json())