1. Create a Slack App#
- Go to https://api.slack.com/apps
- Click "Create New App" → "From scratch"
- Name it "Aexy" and select your workspace
- Click "Create App"
2. Configure OAuth & Permissions#
-
Go to OAuth & Permissions in the sidebar
-
Under Redirect URLs, add:
http://localhost:8000/api/v1/slack/callbackFor production:
https://your-domain.com/api/v1/slack/callback -
Under Bot Token Scopes, add these scopes:
Basic Scopes:
channels:history- Read channel messageschannels:read- List channelschat:write- Send messagescommands- Slash commandsusers:read- Read user infousers:read.email- Read user emails (for auto-mapping)
Additional Scopes for Escalation Notifications:
chat:write.public- Send messages to channels without joininggroups:read- List private channelsgroups:write- Post to private channelsim:write- Send direct messages to usersmpim:write- Send messages to group DMs
-
Under User Token Scopes (optional, for user-level actions):
channels:readusers:read
3. Set Up Slash Commands#
- Go to Slash Commands in the sidebar
- Click "Create New Command":
- Command:
/aexy - Request URL:
http://localhost:8000/api/v1/slack/commands - Description: "Aexy tracking commands"
- Command:
4. Enable Events#
- Go to Event Subscriptions
- Turn on "Enable Events"
- Request URL:
http://localhost:8000/api/v1/slack/events - Subscribe to bot events:
message.channelsmessage.groupsapp_mention- When bot is @mentionedmember_joined_channel- Track channel membership
5. Enable Interactivity (for Buttons/Actions)#
- Go to Interactivity & Shortcuts
- Turn on "Interactivity"
- Request URL:
http://localhost:8000/api/v1/slack/interactions
6. Get Your Credentials#
- Go to Basic Information
- Copy these values:
- Client ID
- Client Secret
- Signing Secret
7. Add to Backend .env#
# Add to backend/.env
SLACK_CLIENT_ID=your_client_id
SLACK_CLIENT_SECRET=your_client_secret
SLACK_SIGNING_SECRET=your_signing_secret
SLACK_REDIRECT_URI=http://localhost:8000/api/v1/slack/callback
# For production
# SLACK_REDIRECT_URI=https://your-domain.com/api/v1/slack/callback
8. Restart Backend#
docker compose restart backend temporal-worker
9. Install to Workspace#
Navigate to:
http://localhost:8000/api/v1/slack/install?organization_id=YOUR_WORKSPACE_ID&installer_id=YOUR_USER_ID
Token Management & Refresh#
How Tokens Work#
Slack uses OAuth 2.0 with bot tokens that do not expire by default. However, if you enable token rotation:
- Access Token: Used to make API calls (expires if rotation enabled)
- Refresh Token: Used to get new access tokens
- Bot Token: The primary token for bot actions (
xoxb-...)
Updating Scopes (Re-authorization Required)#
If you add new scopes to your Slack app, existing installations need to re-authorize:
- Update scopes in Slack App settings (OAuth & Permissions)
- Users must reinstall the app to grant new permissions
- Direct them to the install URL:
http://localhost:8000/api/v1/slack/install?organization_id=WORKSPACE_ID&installer_id=USER_ID
Token Rotation (Optional but Recommended)#
To enable automatic token rotation for enhanced security:
- Go to OAuth & Permissions in your Slack app
- Scroll to Advanced Token Security
- Enable Token Rotation
- Backend handles refresh automatically via
slack_service.py
Checking Token Status#
# Test if token is valid
curl -X POST https://slack.com/api/auth.test \
-H "Authorization: Bearer xoxb-your-bot-token"
Escalation Notifications Setup#
Channel Configuration#
For escalation notifications to work, the Aexy bot must be:
- Invited to the target channel (for private channels)
- Has
chat:write.publicscope (for public channels without joining)
Notification Channels#
Escalation rules can notify via:
- Slack Channel: Posts to a specific channel
- Direct Message: Sends DM to specified users
- Email: Falls back to email if Slack unavailable
Setting Up Escalation Channels#
- Go to Settings > Escalation Matrix in Aexy
- Create/edit an escalation rule
- Select notification channels (email, slack, in_app)
- For Slack notifications:
- Specify channel ID or use default escalation channel
- Ensure bot is in the channel
Default Escalation Channel#
Set a default channel for all escalation notifications:
# In workspace settings or environment
DEFAULT_ESCALATION_SLACK_CHANNEL=#escalations
Message Format#
Escalation messages include:
- Ticket number and form name
- Severity level with color coding
- Assignee info (if any)
- Direct link to ticket
- Acknowledge button (interactive)
Troubleshooting#
"missing_scope" Error#
The bot token is missing required scopes. Re-install the app after adding scopes.
"channel_not_found" Error#
- Ensure the channel exists
- Invite the bot to the channel:
/invite @Aexy
"not_in_channel" Error#
Bot needs to be in the channel. Either:
- Invite the bot:
/invite @Aexy - Use
chat:write.publicscope for public channels
Token Expired#
If using token rotation and token expired:
- Check
slack_integrationstable forrefresh_token - Call
/api/v1/slack/refreshto get new token - Or have user re-install the app
Testing the Integration#
# Send a test message
curl -X POST http://localhost:8000/api/v1/slack/test-notification \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{"channel": "#general", "message": "Test from Aexy"}'