Skip to main content

Overview

The Slack integration covers two surfaces:
  1. Incoming webhook — outbound delivery of investigation findings to a channel.
  2. Socket Mode bot — two-way chat with the OpenSRE agent (mentions and DMs), managed the same way as the Telegram gateway.

Prerequisites

  • A Slack workspace where you can create or install apps (workspace admin or app-install permissions).
  • The channel you want findings posted to (webhook) and/or where the bot will be invited (Socket Mode).

Setup

Choose webhook, Socket Mode, or both. Credentials are persisted to ~/.opensre/integrations.json (and can be merged on re-run). Picking one mode clears the other when you intentionally switch.

Option 2: Onboarding wizard

Select Slack and choose webhook / Socket Mode / both. The wizard validates the webhook when configured, then persists credentials to the integration store. Socket Mode tokens are dual-written to ~/.opensre/credentials.json; the webhook URL is not.

Option 3: Environment variables

OpenSRE reads env as a fallback when no Slack entry exists in ~/.opensre/integrations.json. Bot / app tokens use resolve_env_credential (process env, then the credentials file). SLACK_WEBHOOK_URL is store/env only.
Credential resolution. Store first when present. Then: SLACK_BOT_TOKEN / SLACK_APP_TOKEN → env then keyring; SLACK_WEBHOOK_URL → plain env only (never keyring).
Socket Mode needs both xoxb- and xapp- tokens (prefixes enforced).

Credentials

Create a Slack incoming webhook

  1. Visit https://api.slack.com/apps and click Create New App → From scratch.
  2. Name the app (e.g. OpenSRE) and pick your workspace.
  3. In the left sidebar, open Incoming Webhooks and toggle the feature On.
  4. Click Add New Webhook to Workspace.
  5. Pick the channel where findings should be posted and click Allow.
  6. Copy the generated URL:
Treat this URL like a password — anyone holding it can post to your channel. If your workspace already has a Slack app you want to reuse, you can add a new webhook to it instead of creating a fresh app; the URL format is the same.

Create Socket Mode tokens

  1. In your Slack app settings, enable Socket Mode and create an app-level token with the connections:write scope (xapp-…).
  2. Under OAuth & Permissions, grant the bot scopes below, then install the app and copy the bot token (xoxb-…).
  3. Under Event Subscriptions, subscribe to the bot events app_mention and message.im.
Bot Token Scopes (Socket Mode chat + teammate tools):
Add these only if you use the feature — they are not in the current app config: reactions:write (gateway ack 👀 / ✓ reactions + slack_add_reaction), channels:read / im:read / mpim:read (resolve #channel-name and DM names → ID), and channels:join (slack_join_channel).
Reinstall the app after adding scopes so the bot token picks them up. Invite the bot (/invite @OpenSRE) to private channels it should read or post in.
slack_search_messages is the one tool a bot token can never run — Slack refuses bot tokens for workspace message search, no matter which scopes you grant. To enable search, add search:read under OAuth & Permissions → User Token Scopes, reinstall, and set SLACK_ACCESS_TOKEN to the resulting user token (xoxp-…). Leave it unset and search simply stays hidden from the agent; every other Slack tool works on the bot token alone.

Allow your Slack user

Find your Slack member ID (U…) in the Slack app: profile → Copy member ID.
or set SLACK_ALLOWED_USERS=U0123ABCD in .env. The integration store takes precedence when both are set.
Use the Slack member ID (U…) from Copy member ID, not @display-name. Handles can be reassigned; inbound authorization only matches stable user IDs.
For dogfood only, you may set SLACK_ALLOW_OPEN_WORKSPACE=1 instead.

DM pairing (optional)

Then DM the bot (or mention it) and send /pair <code>.

Investigation tools

Teammate tools (bot token) plus webhook blast. Credentials resolve inside the tools (never in tool-call traces). Shared client: integrations/slack/web_client.py. Prefer slack_reply_message / slack_read_messages when the bot token is configured and the user names a channel or thread. Use slack_send_message only for the fixed webhook channel. For “add task”, “remind me”, and “what should we focus on next” requests, use OpenSRE work management. Gateway turns can default reminders and recurring check-ins to the current Slack channel. Example prompts:
  • “Read the last 20 messages in #incidents and summarize.”
  • “Search Slack for ‘Windows install’ this week.”
  • “Join #ops then reply that mitigation is rolled out.”
  • “Who is on the team, and what does Vaibhav do?”
  • “Add task: ping owners about the deploy window.”
  • “Get GitHub star velocity for the last 30 days on your-org/your-repo and post it to Slack.”
  • “Generate a Slack-ready work status report for your-org/your-repo and post it.”
The last two need GitHub configured and name the repository explicitly (your-org/your-repo) so the GitHub tools can resolve it — see GitHub workflow tools for what they can report on. slack_send_message requires approval before it posts; confirm the prompt when it appears, then check the channel for the message.

Production Engineer schedules (Slack)

Wire morning digests, PR sweeps, and /loops prompt loops to Slack. The gateway daemon (or opensre cron start) must be running so the scheduler can deliver when a tick finishes — the report arrives proactively; you do not need to ask in chat. Destination options: Copy the channel id (C…) from Slack channel details. During opensre integrations setup slack (Socket Mode or Both), you can persist a default channel id for scheduled delivery. The default channel is taken from the same place as the bot token: if the token is in .env, set SLACK_DEFAULT_CHAT_ID there too. A channel saved only in the integration store is not paired with an env or task-level token.
See Scheduled deliveries and Sentry morning digest.

Two-way chat gateway (Socket Mode)

No public inbound HTTPS URL is required — the gateway holds an outbound websocket. Each thread is its own conversation.
Built-in chat commands: /new (fresh session), /help, /pair <code>. While a turn runs, the gateway adds an 👀 (eyes) reaction on the inbound message, then swaps to ✅ (white_check_mark) when the reply is finalized. If Slack is not configured the daemon still runs the other components and opensre gateway status shows slack: not configured.

Deploying the Slack gateway

The Slack gateway backend is deployed and operated separately — not from this repo. Configure the integration here (tokens and scopes above); provisioning the hosted backend is out of scope for this repo. The EC2 gateway path (make deploy-gateway) is Telegram-only and ignores SLACK_* variables with a validation warning: Slack Socket Mode is single-consumer, so a second gateway holding the same tokens would split events.

Verify

A successful run reports the integration as passed. Webhook-only configs confirm the URL is present; Socket Mode configs also run Slack auth.test on the bot token. To also confirm webhook delivery, add the --send-slack-test flag:
This posts a small test message to the configured channel. Delivery test:

Troubleshooting

Security

  • Treat webhook URLs and bot/app tokens like passwords.
  • Prefer least-privilege bot scopes; add optional scopes only when you use those tools.
  • Keep SLACK_ALLOWED_USERS set in production; treat open-workspace mode as dogfood only.
  • Store secrets in the integration store / keyring / secret manager — not in source control.