Overview
The Slack integration covers two surfaces:- Incoming webhook — outbound delivery of investigation findings to a channel.
- 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
Option 1: Direct setup command (recommended)
~/.opensre/integrations.json (and can be merged on re-run). Picking one mode clears the other when you intentionally switch.
Option 2: Onboarding wizard
~/.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).xoxb- and xapp- tokens (prefixes enforced).
Credentials
Create a Slack incoming webhook
- Visit https://api.slack.com/apps and click Create New App → From scratch.
-
Name the app (e.g.
OpenSRE) and pick your workspace. - In the left sidebar, open Incoming Webhooks and toggle the feature On.
- Click Add New Webhook to Workspace.
- Pick the channel where findings should be posted and click Allow.
-
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
- In your Slack app settings, enable Socket Mode and create an app-level token with the
connections:writescope (xapp-…). - Under OAuth & Permissions, grant the bot scopes below, then install the app and copy the bot token (
xoxb-…). - Under Event Subscriptions, subscribe to the bot events
app_mentionandmessage.im.
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)./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.
SLACK_ALLOWED_USERS=U0123ABCD in .env. The integration store takes precedence when both are set.
For dogfood only, you may set SLACK_ALLOW_OPEN_WORKSPACE=1 instead.
DM pairing (optional)
/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-repoand post it to Slack.” - “Generate a Slack-ready work status report for
your-org/your-repoand post it.”
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.
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
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:
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_USERSset in production; treat open-workspace mode as dogfood only. - Store secrets in the integration store / keyring / secret manager — not in source control.