The following examples show how to compose Slack messages in Markdown, Slack Markdown, Block Kit JSON, and Automation expression formats using
Slack Connector.
Send a Slack message automatically.
Connection: select any connection from the dropdown list, for example, dynatrace-notifications-sandbox.
Message: see the examples in the following table.
| Input type | Sample input |
|---|---|
Markdown |
|
Slack Markdown |
|
Block Kit Builder |
|
Automation expression |
|
Interactions
Select Run to send your message to your Slack channel.
Output:
| Sample result | |
|---|---|
threadTs |
|
channelID |
|
messageTs |
|
permalink |
|
Log output examples
[INFO] POST https://slack.com/api/chat.postMessage called successfully[INFO] GET https://slack.com/api/chat.getPermalink called successfully[INFO] Message 1234567890.123456 posted in C0000000000.
[ERROR] Slack API error while calling 'chat.postMessage': 'no_text'
You can use Block Kit Builder to create richly formatted messages for Slack. For text formatting options, see Slack's Markdown reference. After designing your message, copy the JSON output and adapt it to your needs in Dynatrace Workflows using workflow expressions.
{"blocks": [{"type": "header","text": {"type": "plain_text","text": "🚨 Dynatrace Alert: High CPU Usage Detected","emoji": true}},{"type": "section","text": {"type": "mrkdwn","text": "*Alert Details:*\n• *Entity*: `Host-1234`\n• *Metric*: CPU Usage\n• *Threshold*: > 90%\n• *Current Value*: 95%"}},{"type": "divider"},{"type": "section","text": {"type": "mrkdwn","text": "💡 *Recommended Actions:*"}},{"type": "actions","elements": [{"type": "button","text": {"type": "plain_text","text": "Acknowledge Alert"},"style": "primary","value": "acknowledge_alert"},{"type": "button","text": {"type": "plain_text","text": "View in Dynatrace"},"url": "https://dynatrace.example.com/alert/1234","style": "danger"}]},{"type": "context","elements": [{"type": "mrkdwn","text": "Triggered at: 2026-01-08 14:30 UTC"}]}]}
Slack doesn't have a built-in templating language. Use Dynatrace expressions instead. Expressions will be resolved at execution time, creating a static card payload that will be sent.
To create a structured message with multiple data fields, use Slack Block Kit.
{"blocks": [{"type": "header","text": {"type": "plain_text","text": "production-payment-service","emoji": true}},{"type": "section","text": {"type": "plain_text","emoji": true,"text": "2024-01-09T11:30:00+01:00"}},{"type": "section","text": {"type": "mrkdwn","text": "```Error: Connection timeout after 5000ms\n at PaymentGateway.connect (gateway.js:45)\n at processPayment (service.js:123)```"}},{"type": "section","text": {"type": "mrkdwn","text": "DT App function: `processPayment`"}},{"type": "section","text": {"type": "mrkdwn","text": "DT entity service: `SERVICE-A1B2C3D4E5F6G7H8`"}}]}
To replicate this behavior, you can use expressions instead.
{%- set data = [{"dt_app_id": "production-payment-service","instance": "2024-01-09T10:30:00Z","error": "Error: Connection timeout after 5000ms\n at PaymentGateway.connect (gateway.js:45)\n at processPayment (service.js:123)","dt_app_function": "processPayment","dt_entity_service": "SERVICE-A1B2C3D4E5F6G7H8"}]-%}{"blocks": [{% for item in data %}{"type": "header","text": {"type": "plain_text","text": "{{ item.dt_app_id }}","emoji": true}},{"type": "section","text": {"type": "plain_text","emoji": true,"text": "{{ item.instance | to_datetime(timezone='Europe/Vienna') }}"}},{"type": "section","text": {"type": "mrkdwn","text": {{ ("```" ~ item.error ~ "```") | to_json }}}},{"type": "section","text": {"type": "mrkdwn","text": "DT App function: `{{ item.dt_app_function }}`"}},{% if 'dt_entity_service' in item %}{"type": "section","text": {"type": "mrkdwn","text": "DT entity service: `{{ item.dt_entity_service }}`"}}{% endif %}{% if not loop.last %},{% endif %}{% endfor %}]}
{% set data = [...] %}: Define data inline or use result("task_name") to reference workflow task results.{{ item.field }}: Access object properties.| to_datetime(timezone='...'): Format timestamps.| to_json: Escape special characters for JSON compatibility.{% if condition %}: Add conditional blocks.{% for item in data %}: Iterate over arrays.For more expression capabilities, see Jinja expressions for Workflows.