Skip to main content

Slack Integration & ChatOps

Bring k8s-autopilot directly into your team's Slack channels. The Slack integration server allows platform engineers and SREs to investigate incidents, generate Helm charts, and execute progressive rollouts right where conversations happen.


Architecture Overview

The Slack integration runs as a standalone async service using Slack Bolt for Python, running alongside the existing A2A server. It translates Slack events, thread messages, and interactive Block Kit button clicks into LangGraph state machine executions.

┌────────────────────────────────────────────────────────┐
│ Slack Workspace │
│ ├── Direct Messages to @k8s-autopilot │
│ ├── Channel mentions (@k8s-autopilot debug pod foo) │
│ └── Slack Assistant Container (side pane) │
└───────────────────────────┬────────────────────────────┘
│ HTTPS (Events API & Interactivity)

┌────────────────────────────────────────────────────────┐
│ k8s-autopilot Slack Integration Server (Port 3000) │
│ ├── /slack/events → Event subscriptions │
│ ├── /slack/interactions → Block Kit action buttons │
│ └── /health → Health & readiness check │
│ │
│ Slack Bolt ──► SlackMessagingIntegration │
│ ├── IdentityMapper (Slack UID → RBAC role) │
│ ├── ThreadStore (Thread TS → LangGraph thread_id) │
│ └── GraphStreamBridge (LangGraph event streaming) │
└────────────────────────────────────────────────────────┘

Key Features

  • 💬 Thread Continuity: Each Slack thread maps directly to an isolated LangGraph session. Previous investigation context (e.g. crashing pod logs or firing alerts) persists naturally within the thread.
  • 🛡️ Interactive Approval Cards: When an agent proposes a state-modifying action (e.g., rolling back a Helm chart or scaling a deployment), it renders an interactive Slack Block Kit card with Approve and Reject buttons.
  • Live Streaming Updates: Streams agent progress and intermediate tool discoveries directly into the Slack message, giving engineers visibility as complex workflows execute.
  • 🔒 RBAC Identity Mapping: Maps Slack User IDs to internal TalkOps RBAC policies to ensure only authorized engineers can approve production mutations.

Quick Setup Guide

1. Install Dependencies

Install k8s-autopilot with Slack extras:

uv pip install -e ".[slack]"

Verify that the Slack SDK modules are available:

uv run python -c "from slack_bolt.async_app import AsyncApp; print('✅ slack-bolt installed')"

2. Create the Slack App

  1. Navigate to api.slack.com/apps and click Create New AppFrom an app manifest.
  2. Select your workspace, choose YAML, and paste the following manifest:
display_information:
name: k8s-autopilot
description: Autonomous Kubernetes & Observability AI Agent
background_color: "#1a1f2c"
features:
bot_user:
display_name: k8s-autopilot
always_online: true
assistant_thread:
use_container: true
oauth_config:
scopes:
bot:
- app_mentions:read
- chat:write
- chat:write.customize
- im:history
- im:read
- im:write
- assistant:write
settings:
event_subscriptions:
bot_events:
- app_mention
- message.im
- assistant_thread_started
- assistant_thread_context_changed
interactivity:
is_enabled: true
  1. Install the app to your workspace and copy your Bot User OAuth Token (xoxb-...) and Signing Secret.

3. Configure Environment Variables

Add the following keys to your .env file:

# Slack Integration Credentials
SLACK_BOT_TOKEN=xoxb-your-bot-user-oauth-token
SLACK_SIGNING_SECRET=your-slack-signing-secret

# Server Ports
SLACK_SERVER_PORT=3000
A2A_SERVER_PORT=10102

4. Start the Slack Server

Launch the Slack integration server:

# Using the CLI entrypoint
k8s-autopilot-slack --port 3000

# Or via Python module
python -m k8s_autopilot.slack.server --port 3000

5. Connect Slack Interactivity & Events

For local development, expose port 3000 using a secure tunnel like ngrok:

ngrok http 3000

In your Slack App Settings:

  1. Go to Event Subscriptions $\rightarrow$ Enable Events $\rightarrow$ Set Request URL to: https://<your-ngrok-domain>/slack/events
  2. Go to Interactivity & Shortcuts $\rightarrow$ Turn On $\rightarrow$ Set Request URL to: https://<your-ngrok-domain>/slack/interactions

Interacting with the Bot

In Channels

Invite @k8s-autopilot to your incident or platform channel:

@k8s-autopilot Why did the checkout deployment fail in the production namespace?

In Direct Messages

Send direct messages to the bot to generate Helm charts or inspect Prometheus metrics privately:

Generate a high-availability Helm chart for Redis with 3 replicas and Sentinel enabled.

Approving Infrastructure Changes

When the agent formulates a plan, it replies in the thread with an interactive card:

┌──────────────────────────────────────────────────────────┐
│ 🚨 PLAN APPROVAL REQUIRED │
│ Action: Scale Deployment 'checkout-api' to 5 replicas │
│ Namespace: production │
│ Impact: Minimal (Safe scaling operation) │
│ │
│ [ ✅ Approve ] [ ❌ Reject ] │
└──────────────────────────────────────────────────────────┘

Clicking Approve resumes the LangGraph execution and applies the changes via the Kubernetes MCP server.