Slack OAuth Setup
OAuth setup steps for the Slack integration
Overview
The Slack integration supports two methods:
- OAuth Integration (Recommended): Connect Slack workspace via OAuth for full API access
- Webhook (Legacy): Use incoming webhooks (limited functionality)
OAuth Setup Steps
1. Create Slack App
- Go to https://api.slack.com/apps
- Click "Create New App" → "From scratch"
- Name your app (e.g., "OpsKnight") and select your workspace
- Click "Create App"
2. Configure OAuth & Permissions
-
In your app settings, go to OAuth & Permissions
-
Under Redirect URLs, add:
https://yourdomain.com/api/slack/oauth/callback http://localhost:3000/api/slack/oauth/callback (for development) -
Under Scopes → Bot Token Scopes, add every scope below.
Required — incident features break without these:
chat:write- Send messageschannels:read- List channelschannels:join- Join channels the bot was not invited tochannels:manage- Create, retitle and archive war-room channelschannels:history- Read a pinned message so it can be saved as a notereactions:read- Receive 📌 reactionsusers:read- Read user informationusers:read.email- Match Slack users to OpsKnight accounts, so responders are auto-invited to war rooms
Optional — private channel and DM coverage:
groups:read,groups:write,groups:history- Private channelsim:read,mpim:read- Direct and group messages
-
Under Scopes → User Token Scopes (optional):
- No user scopes needed for basic functionality
Faster alternative. Settings → Integrations → Slack shows a generated App Manifest for your deployment. Creating the app from that manifest configures every scope, Event Subscriptions, interactivity and the
/incidentcommand in one step, with nothing to tick by hand.
2b. Enable Event Subscriptions
Required for 📌 emoji pin sync. This is a separate setting from Interactivity — buttons can work perfectly while events do nothing.
- Go to Event Subscriptions and turn it on
- Set the Request URL to
https://yourdomain.com/api/slack/events - Under Subscribe to bot events, add
reaction_added
Slack verifies that URL with a signed challenge, so configure the Signing Secret (step 5) before saving it, or verification is rejected.
3. Install App to Workspace
- Go to OAuth & Permissions page
- Click Install to Workspace
- Review permissions and click Allow
- Copy the Bot User OAuth Token (starts with
xoxb-)
4. Get Signing Secret
- Go to Basic Information in your app settings
- Under App Credentials, find Signing Secret
- Click Show and copy the secret
5. Enter Credentials in OpsKnight
Slack credentials are entered in the app, not in environment variables, and are stored encrypted. Go to Settings → Integrations → Slack and provide:
| Field | Where to find it in Slack |
|---|---|
| Client ID | Basic Information → App Credentials |
| Client Secret | Basic Information → App Credentials |
| Signing Secret | Basic Information → App Credentials |
The Signing Secret is required, not optional. OpsKnight verifies that every inbound request genuinely came from Slack and rejects those it cannot verify. Without it, slash commands, interactive buttons and events all fail with
401and the logs showRejected unverified request.Slack does not return this value during OAuth — it is an app-level credential, so reconnecting will not fill it in. It must be copied manually.
SLACK_SIGNING_SECRET is still honoured as an environment override, which is
convenient for local development, but is not needed in a normal deployment.
Legacy fallbacks, only for installs not using OAuth:
# Optional: legacy webhook URL (fallback if OAuth is not configured)
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
# Optional: legacy bot token (fallback if OAuth is not configured)
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
6. Generate Encryption Key
ENCRYPTION_KEY is required in production — it encrypts the stored bot token
and signing secret. A development fallback is used automatically when it is unset
outside production.
Generate one with:
openssl rand -hex 32
Add this to your ENCRYPTION_KEY environment variable.
Usage
Connect Slack to Service
- Go to Service Settings → Notifications
- Click "Connect Slack Workspace"
- Authorize the app in Slack
- Select a channel for notifications
- Save settings
Connect Slack Globally
- Go to Settings → Integrations
- Click "Connect Slack Workspace"
- Authorize the app
- This becomes the default Slack integration
How It Works
- OAuth Flow: User clicks "Connect Slack" → Redirected to Slack → Authorizes → Callback stores encrypted token
- Token Storage: Bot tokens are encrypted and stored in
SlackIntegrationtable - Service-Specific: Each service can have its own Slack workspace connection
- Global Fallback: If no service-specific integration, uses global integration
- Env Fallback: If no OAuth integration, falls back to
SLACK_BOT_TOKENenv var
Security
- Bot tokens are encrypted using AES-256-CBC before storage
- Encryption key should be stored securely (env var, secret manager)
- Tokens are decrypted only when needed for API calls
- Never log or expose decrypted tokens
Troubleshooting
"Slack bot token not configured"
- Ensure OAuth integration is connected
- Or set
SLACK_BOT_TOKENenvironment variable - Check that integration is enabled
"Failed to decrypt token"
- Ensure
ENCRYPTION_KEYis set correctly - Key must be same across all instances
- If changed, re-connect Slack integrations
"Invalid OAuth state"
- OAuth state expired (10 minutes)
- Try connecting again
- Clear cookies if issue persists
Endpoints
GET /api/slack/oauth- Initiate OAuth flowGET /api/slack/oauth/callback- OAuth callback handlerGET /api/slack/channels- List available channelsPOST /api/slack/actions- Handle interactive button clicksDELETE /api/slack/disconnect- Disconnect integration
Last updated for v1.2
Edit this page on GitHub