Florent VanDeMoortele
11/19/2025, 5:01 PMMarvin
11/19/2025, 5:01 PMMarvin
11/19/2025, 5:05 PMnotify method, you can include basic Slack mrkdwn in the string (e.g., *bold*, _italic_, `` code ``, and triple backticks). The notify call sends a plain text payload via Slack’s Incoming Webhook; Slack will render basic mrkdwn in that field. You cannot use Block Kit or advanced layouts via notify.
Example with the built-in block:
from prefect.blocks.notifications import SlackWebhook
slack = SlackWebhook.load("my-slack-webhook")
slack.notify("*Build complete* — _all tests passed_\n\n```multi-line code```")
If you need richer formatting (Block Kit, buttons, fields, sections), use the prefect-slack collection and send blocks:
from prefect_slack import SlackWebhook
from prefect_slack.messages import send_incoming_webhook_message
webhook = SlackWebhook.load("my-slack-webhook") # block from prefect-slack
await send_incoming_webhook_message(
slack_webhook=webhook,
text="Fallback text",
slack_blocks=[
{"type": "section", "text": {"type": "mrkdwn", "text": "Hello *bold* and _italic_"}},
],
)
Notes:
- Use single asterisks for bold (*bold*) and underscores for italics (_italic_)—Slack does not use double-asterisk Markdown.
- notify is limited to a single text message; for full control use prefect-slack.
Links:
- Slack formatting (mrkdwn): Slack mrkdwn reference
- Incoming webhooks: Slack Incoming Webhooks
- Prefect Slack collection: prefect-slack docs
Quick follow-up: Are you using a Slack Webhook block’s .notify() in a flow, or Prefect Cloud Automations to Slack? If it’s Automations, the message body is plain text but you can still include basic mrkdwn like above. If you need blocks from Automations, we’d route through a small flow that uses prefect-slack.