Slack Integration on Localhost
This guide is for developers running Open Chat Studio (OCS) locally. It walks through creating a Slack app and connecting it to your local OCS server, which you expose with ngrok, so that you can use and test the Slack integration.
Slack can be used as an OCS messaging provider so that participants can interact with the chatbot directly from Slack. In addition it can be used to deliver OCS notifications to a team's Slack channel.
Note
Slack's app settings screens change often. If a screen doesn't match the steps below, check Slack's guide, Creating an app from app settings.
1. Create a Slack app
- Visit the Slack API apps page 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_IDSLACK_CLIENT_SECRETSLACK_SIGNING_SECRET - Add these to your
.envfile:
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 the ngrok download page.
- Start your Django server with a public URL using:
invoke runserver --public
https://abc123.ngrok.io
6. Update redirect URLs in the 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
5. 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 the messaging provider in Open Chat Studio
- Go to Team Settings → Integrations.
- Click Add integration, expand Messaging, and select Slack.
- Click Connect Slack — you'll be redirected to Slack's authorization screen.
See the user guide on OCS Messaging Providers.
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 → Integrations and complete the Slack setup.
What this enables
With Slack connected to your local environment, OCS Admin users can: