How it Works
The Slack bot will listen to messages mentioning it in channels and direct messages. It will send replies to a dedicated thread or DM depending on the context.
Supported Features
| Message | Streaming | Elements | Audio | Ask User | Chat History | Chat Profiles | Feedback |
|---|---|---|---|---|---|---|---|
| ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ |
Install the Slack Bolt Library
The Slack Bolt library is not included in the Chainlit dependencies. You will have to install it manually.Create a Slack App
To start, navigate to the Slack apps dashboard for the Slack API. Here, you should find a green button that says Create New App. When you click this button, select the option to create your app from scratch. Create a name for your bot, such as “ChainlitDemo”. Select the workspace you would like your bot to exist in.
Connection Modes
Chainlit supports two ways to connect to Slack:- HTTP Mode (default): Slack sends events to your Chainlit server via HTTP. Requires a public URL.
- Socket Mode (since 2.7.0): Chainlit connects to Slack via WebSocket. No public URL needed — ideal for local development or restrictive networks.
SLACK_WEBSOCKET_TOKEN environment variable (see Environment Variables). When set, Socket Mode takes priority over the HTTP handler.
Working Locally
With Socket Mode (recommended)
If you use Socket Mode, no public URL or ngrok is needed. Chainlit connects to Slack over WebSocket directly. See the Socket Mode app manifest below.With HTTP Mode
If you are working locally with HTTP mode, you will have to expose your local Chainlit app to the internet to receive incoming messages from Slack. You can use ngrok for this.Set the App Manifest
Go to App Manifest and paste the following Yaml.Replace the
{placeholders} with your own values.
Socket Mode
If you are using Socket Mode, apply these changes to the manifest above: remove bothrequest_url fields and set socket_mode_enabled to true.
[Optional] Allow users to send DMs to Chainlit
By default the app will only listen to mentions in channels. If you want to allow users to send direct messages to the app, go to App Home and enable “Allow users to send Slash commands and messages from the messages tab”.
[Optional] Emoji Reaction on Message Received
Adds an optional feature to show emoji reactions when Slack messages are received, providing immediate user feedback while the bot processes the request.This feature requires the
reactions:write OAuth scope. If you enable this feature, you’ll need to add this scope to your Slack app’s OAuth configuration.chainlit.md file:

Install the Slack App to Your Workspace
Navigate to the Install App tab and click on Install to Workspace.Set the Environment Variables
Set the environment variables outside of your application code.
Bot Token
Once the slack application is installed, you will see the Bot User OAuth Token. Set this as an environment variable in your Chainlit app.
Signing Secret
Navigate to the Basic Information tab and copy the Signing Secret. Then set it as an environment variable in your Chainlit app.
App-Level Token (Socket Mode only)
If you are using Socket Mode, you also need an App-Level Token. Navigate to Basic Information > App-Level Tokens, create a token with theconnections:write scope, and set it as an environment variable.
When
SLACK_WEBSOCKET_TOKEN is set, Chainlit uses Socket Mode and the HTTP /slack/events endpoint is not registered. You do not need SLACK_SIGNING_SECRET in Socket Mode.Start the Chainlit App
Since the Chainlit app is not running, the Slack app will not be able to communicate with it. For the example, we will use this simple app:my_app.py
Reminder: Make sure the environment variables are set. If using HTTP mode,
your local Chainlit app must be exposed to the internet via ngrok.
Using -h to not open the default Chainlit UI since we are using Slack.
Chat History
Chat history is directly available through thefetch_slack_message_history method.
It will fetch the last messages from the current thread or DM channel.