Deploy a Slack bot in Socket Mode
Host a Bolt app for JavaScript or Python, configure the two Slack tokens, and verify a threaded reply to an app mention.
Configure the Slack app and both tokens
- Open Slack app settings and create an app in your test workspace, or open your existing app. Enable Socket Mode. Generate an app-level token with
connections:writeand save it asSLACK_APP_TOKENin Bothosting Variables. - In OAuth & Permissions, add the bot scopes
app_mentions:readとchat:writefor the supplied example. Under Event Subscriptions, enable events and subscribe to the bot eventapp_mention. - Install the app to your workspace. If you changed its scopes, reinstall it to grant the updated scopes. Copy the Bot User OAuth Token into
SLACK_BOT_TOKENin Variables.
Socket Mode delivers requests through the connection the bot opens to Slack. It works with workspace installations. Slack Marketplace distribution has separate requirements. Slack’s Socket Mode setup.
Choose a worker and add your project
On Slack bot hosting, select Node.js Socket Mode bot または Python Socket Mode bot. Upload or connect your own project, or add the example files from Overview before your first start.
For a manual upload, download the Bolt for JavaScript archive または Bolt for Python archive. Keep index.js の隣に package.json and its lockfile, or main.py の隣に requirements.txt, at the deployment root.
For an existing app, confirm it reads both environment variables and uses the Bolt Socket Mode receiver for your language. Bolt for JavaScript と Bolt for Python.
Verify the reply in your workspace
- Stop the copy running on your computer if it uses the same installation. Start the hosted deployment and check Console for a Socket Mode startup message.
- Invite the Slack app to a test channel. Select it by name in an
@mention and send the message. - Open the message thread. The example replies with “Your Slack bot is running.”
If the reply is missing, check which role each token has, confirm the event subscription, and verify the bot has permission to post. Troubleshoot a missing Slack reply.