Slack Integration on Localhost
This guide helps you set up Slack integration with your development environment using a local server exposed via ngrok.
1. Create a Slack App
- Visit https://api.slack.com/apps and click Create New App.
- Choose From scratch.
- Provide a name for your app and select your workspace.
2. Add Bot Scopes
- Go to OAuth & Permissions → Scopes.
- Under Bot Token Scopes, add the scopes that your app needs, for example:
chat:write
— allows sending messagesfiles:write
— allows uploading files- Click Save Changes.
3. Install the App to Your Workspace
- Navigate to Install App in the left sidebar.
- Click Install to Workspace and authorize.
4. Update Environment Variables
- Go to the Basic Information section of your app.
- Copy the following values:
SLACK_CLIENT_ID
SLACK_CLIENT_SECRET
SLACK_SIGNING_SECRET
- Add these to your
.env
file:
SLACK_CLIENT_ID=your-client-id
SLACK_CLIENT_SECRET=your-client-secret
SLACK_SIGNING_SECRET=your-signing-secret
5. Install ngrok
- Download and install ngrok from https://ngrok.com/download.
- Start your Django server with a public URL using:
invoke runserver --public
https://abc123.ngrok.io
6. Update Redirect URLs in Slack App
- In your Slack app, go to OAuth & Permissions.
- Under Redirect URLs, add:
https://<your-ngrok-subdomain>.ngrok.io/slack/oauth_redirect
7. Set Up Slack Events Endpoint
- Go to Event Subscriptions in your Slack app.
- Toggle Enable Events.
- Set the Request URL to:
https://<your-ngrok-subdomain>.ngrok.io/slack/events
message.channels
- message.im
- Click Save Changes.
8. Update Local Django Settings
In your settings.py
:
SITE_URL_ROOT = "https://<your-ngrok-subdomain>.ngrok.io"
ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
"<your-ngrok-subdomain>.ngrok.io"
]
CSRF_TRUSTED_ORIGINS = [
"https://<your-ngrok-subdomain>.ngrok.io"
]
9. Configure Messaging Provider in Open Chat Studio
- Go to Team Settings → Messaging Providers.
- Click Add, and select Slack as the provider type.
- Click Connect Slack — you'll be redirected to Slack's authorization screen.
10. Authorize in Slack
- Slack may auto-select a workspace. If the correct workspace isn't shown: Open the link in Incognito mode or clear cookies.
- You'll be redirected to your ngrok URL (not
localhost
). - Log back into Open Chat Studio if prompted.
- Navigate again to Team Settings → Messaging Providers and complete the Slack setup.
✅ Done!
Your Slack app is now integrated with your local development environment!