Slack Integration for Runbooks
Post messages, create channels, and run commands from runbooks.
Harness AI SRE integrates with Slack at the organization level, enabling automated incident communication and team collaboration across all projects.
Overview
Slack integration enables your runbooks to do the following:
Send automated notifications
Create incident-specific channels
Manage threaded discussions
Coordinate response teams
Track incident updates
Set up the integration
Prerequisites
Slack Workspace Admin access
Harness Organization Admin role
Setup steps
Go to Organization Settings, then Third Party Integrations (AI SRE).
Click Connect for Slack.
Follow the OAuth flow to authorize Harness.
Configure workspace permissions.
Required Slack permissions
The Harness Slack bot requires these permissions:
channels:manage: Create and manage channelschat:write: Send messagesgroups:write: Manage private channelsim:write: Send direct messages
Features
Global Slack workspace access across all projects
Unified authentication
Centralized channel management
Cross-project notifications
Use Slack actions in runbooks
Slack actions are configured through the runbook action form in the UI:
In your runbook, click New Step, then Action.

New Step Menu In the Select Action dialog, go to the Communication category.
Select the Slack action you need from the available options.

Select Action Dialog Configure the action through a form. The fields shown depend on the action type you select.
Slack actions in runbooks
Send Slack message action
Sends a message to a specified Slack channel.
Form fields:
Channel: Channel name or ID (e.g.,
#incidentsor{{Activity.slack_channel}})Message: Message text to send
Supports Mustache variables:
{{Activity.title}},{{Activity.summary}}Can include Slack markdown formatting (bold, italics, links)
Supports Block Kit JSON format for rich message layouts. Go to Format messages with Block Kit to review examples.
Create Slack channel action
Creates a new Slack channel for incident coordination.
Form fields:
Channel Name: Name for the new channel (must follow Slack naming rules)
Example:
incident-{{Activity.id}}
Description: Channel topic/description
Is Private: Whether to create a private channel
Available Mustache variables:
{{Activity.title}}: AI SRE incident title{{Activity.id}}: AI SRE incident ID{{Activity.severity}}: AI SRE incident severity{{Activity.severity.id}}: AI SRE incident severity ID (e.g., 1, 2, 3){{Activity.status}}: AI SRE incident status{{Activity.summary}}: AI SRE incident summaryAny custom incident fields configured in your incident template
Format messages with Block Kit
Harness AI SRE supports Slack's Block Kit JSON for rich layouts, including varied text sizes, colors, and formatting beyond basic markdown.
When to use Block Kit
Use Block Kit when you need:
Visually distinct severity indicators
Multi-section messages with different formatting
Compact supplementary information
Consistent message layouts across incidents
Rich interactive elements (buttons, menus)
Use simple text when you need:
Quick notifications without special formatting
Plain status updates
Messages with only basic markdown
Format overview
Block Kit messages are JSON arrays of block objects, each with a type. The Message field accepts plain text or Block Kit JSON.
Section block
Use Section blocks for standard text with markdown, ideal for primary incident info and announcements.
Example: Incident alert with severity
Rendered output in Slack:
Characteristics:
Standard text size
Full markdown support (bold, italics, links, emoji)
Black text on white background
Suitable for primary content
With multiple variables:
A header section carries the title; a fields section holds metadata as label/value pairs, keeping each string short. Use Context blocks for small, compact gray text, ideal for metadata or instructions that should be de-emphasized.
Rendered output in Slack:
Context block
Use Context blocks for small, compact gray text, ideal for metadata or instructions that should be de-emphasized.
Example: Supplementary instructions
Rendered output in Slack:
Characteristics:
Smaller text size
Gray text color
Markdown support in each element
Suitable for secondary information
Key difference from Section block:
Context blocks use an
elementsarray (can contain multiple text elements)Section blocks use a single
textobjectContext blocks render in a more compact, muted style
Combine blocks
Create rich, multi-section messages by combining block types. Blocks are rendered in array order.
Example: Incident notification with details and instructions
Metadata goes in a fields section; the link sits in its own context block.
Rendered output in Slack:
Divider blocks
Add visual separation between sections using divider blocks.
Format text with markdown
Within mrkdwn text fields, you can use:
Bold:
*text*Italics:
_text_Strikethrough:
~text~Code:
`code`Code block:
```code block```Links:
<URL|link text>User mentions:
<@USER_ID>Channel mentions:
<!channel>,<!here>,<#CHANNEL_ID>Emoji:
:emoji_name:Line breaks:
\n
Variable interpolation
Mustache variables work seamlessly within Block Kit JSON. Variables are replaced before the JSON is sent to Slack.
Examples:
{{Activity.severity.id}}renders as1,2,3{{Activity.title}}renders asDatabase Connection Failure{{Activity.status}}renders asInvestigating,Resolved
The examples below link with {{Activity.url}} and {{Activity.postmortem_url}}, which are example custom fields holding the incident and post-mortem links. Use whatever link fields your incident template provides, or a full URL.
Important: Variables are auto-escaped, but ensure values contain no characters that break JSON (quotes, newlines).
Common templates
High-severity incident alert
Rendered output in Slack:
Status update notification
Rendered output in Slack:
Resolution notification
Rendered output in Slack:
Limitations
When using Block Kit in Harness AI SRE, be aware of these constraints:
Block limit: Slack allows up to 50 blocks per message
Text length: Section and context text fields have a 3,000 character limit
JSON validation: Invalid JSON will cause the action to fail. Validate syntax before deploying.
Interactive elements: Buttons and menus display but are not interactive from AI SRE runbooks, they do not trigger callbacks.
Variable escaping: Variables are auto-escaped, but ensure incident data has no malformed JSON characters.
Test messages
Before deploying runbooks with Block Kit messages:
Use Block Kit Builder: Preview your JSON at api.slack.com/block-kit.
Test with static data: Replace Mustache variables with example values to validate JSON syntax.
Run in a test channel: Execute the runbook in a non-production Slack channel first.
Verify variable rendering: Check that all
{{Activity.*}}variables are replaced correctly in the execution logs.
Migrate from plain text
If you have existing runbooks with plain text messages, you can migrate them to Block Kit:
Before (plain text):
After (Block Kit):
Rendered output in Slack:
Benefits:
Better visual hierarchy
Consistent formatting
Easier to add sections without breaking layout
Best practices
Name channels consistently
Follow these conventions when naming incident channels:
Use consistent prefixes:
incident-,alert-,sev1-Include incident IDs:
incident-{{Activity.id}}-apiKeep names descriptive:
sev{{Activity.severity.id}}-{{Activity.service}}Follow workspace conventions: lowercase, hyphens, no spaces
Document naming patterns in runbook descriptions
Message structure
Use clear formatting: Structure messages with headers, sections, and spacing
Include severity indicators: Use emoji (🔴, ⚠️, ℹ️) or text prefixes (SEV1, SEV2)
Link to relevant resources: Dashboards, runbooks, incident details, monitoring tools
Mention appropriate teams: Use
<!channel>,<!here>, or<@USER_ID>for targeted notificationsPrioritize readability: Use Block Kit for complex messages, plain text for simple updates
Keep messages concise: Slack messages should be scannable; avoid large blocks of text
Block Kit tips
Test before deploying: Always preview Block Kit messages in Slack Block Kit Builder
Use Section blocks for primary content: Main incident information, alerts, announcements
Use Context blocks for metadata: Timestamps, IDs, supplementary instructions
Use
fieldsfor label/value pairs: Keeps strings short and renders metadata in a tidy two-column gridAdd dividers for visual separation: Break up long messages into logical sections
Validate JSON syntax: Use a JSON validator before saving runbook actions
Use
\nfor line breaks: Only the\nescape produces a line break, never a real newline or trailing backslashLimit block count: Keep messages under 20 blocks for best performance
Store templates: Save common Block Kit patterns as runbook templates for reuse
Consider accessibility: Ensure emoji and formatting convey meaning even without color
Variable usage
Validate variable names: Ensure custom fields exist before using in messages
Use consistent naming: Match variable names exactly (case-sensitive)
Provide context: Include labels with variables (
*Severity:* {{Activity.severity.id}})Test with sample data: Replace variables with realistic values during testing
Handle missing data: Consider what happens if a custom field is empty
Permissions
Use least privilege access: Only grant permissions needed for specific actions
Regularly audit permissions: Review bot permissions quarterly
Document access requirements: Maintain list of channels and permissions needed
Monitor usage patterns: Track message volume and runbook execution frequency
Rotate credentials: Update OAuth tokens according to security policies
Common use cases
Incident coordination
Workflow:
Create incident-specific channel
Notify stakeholders with severity and context
Share initial assessment and runbook
Track response actions in threaded conversations
Example runbook actions:
Action 1: Create channel
Action Type: Create Slack Channel
Channel Name:
incident-{{Activity.id}}-{{Activity.service}}Description:
SEV{{Activity.severity.id}} - {{Activity.title}}Is Private: False
Action 2: Notify team (Block Kit)
Action Type: Send Slack Message
Channel:
#incidentsMessage:
Rendered output in Slack:
Status updates
Workflow:
Send periodic updates to incident channel
Track resolution progress with structured messages
Share metrics, graphs, and monitoring links
Document action items and next steps
Example runbook action:
Action: Status update (Block Kit)
Action Type: Send Slack Message
Channel:
#incident-{{Activity.id}}-{{Activity.service}}Message:
Rendered output in Slack:
Post-incident communication
Workflow:
Send resolution notification
Share incident summary and timeline
Schedule retrospective meeting
Archive incident channel
Document lessons learned
Example runbook actions:
Action 1: Resolution notice (Block Kit)
Action Type: Send Slack Message
Channel:
#incident-{{Activity.id}}-{{Activity.service}}Message:
Rendered output in Slack:
Action 2: Archive channel
Action Type: Archive Slack Channel
Channel:
incident-{{Activity.id}}-{{Activity.service}}
Maintenance notifications
Example runbook action:
Action: Maintenance alert (Block Kit)
Action Type: Send Slack Message
Channel:
#engineeringMessage:
Rendered output in Slack:
Troubleshooting
Quick reference
Structure comparison
Text Size
Standard
Smaller, compact
Text Color
Black
Gray
Use Case
Primary content
Supplementary info
Structure
Single text object
Array of elements
Markdown
✅ Supported
✅ Supported
Common patterns
Simple alert:
Alert with metadata:
Multi-section with divider:
Label/value metadata (two-column):
Essential variables
These Mustache variables are commonly used in Slack messages:
{{Activity.id}}
Incident ID
INC-12345
{{Activity.title}}
Incident title
Database Connection Failure
{{Activity.severity.id}}
Severity level number
1, 2, 3
{{Activity.status}}
Current status
Investigating, Resolved
{{Activity.service}}
Affected service
api-gateway
Slack markdown
Bold
*text*
*Critical*
Italic
_text_
_investigating_
Strike
~text~
~resolved~
Code
`text`
`error_code`
Link
<URL|text>
<https://example.com|Dashboard>
Mention
<@USER>
<@U12345>
Channel
<!channel>
<!channel>
Resources
Use these Slack references when building Block Kit messages:
Slack Block Kit Builder: api.slack.com/block-kit/building
Block Kit Reference: api.slack.com/reference/block-kit
Slack Markdown Reference: api.slack.com/reference/surfaces/formatting
JSON Validator: jsonlint.com
Next steps
Slack Commands: Use Slack slash commands for incident management.
Microsoft Teams Integration: Set up Microsoft Teams notifications.
Zoom Integration: Create incident war rooms.
Create a Runbook: Build automated response workflows.
Last updated
Was this helpful?