How to host a Slack bot 24/7 (Bolt, Socket Mode)
With Socket Mode, a Slack bot opens its own connection to Slack, so it doesn't need a website or an open port. That makes it a good fit for a simple bot server.
1. Create the Slack app #
- Go to api.slack.com/apps and create a new app from scratch in your workspace.
- Socket Mode: turn it on. Slack asks you to make an app-level token with the
connections:writescope. It starts withxapp-. - OAuth & Permissions: add the bot scopes
chat:writeandchannels:history, then install the app to your workspace. Copy the Bot User OAuth Token, which starts withxoxb-. - Event Subscriptions: turn it on and subscribe to the bot event
message.channels. - Invite the bot to a channel with
/invite @YourBot.
2. A Bolt for JavaScript bot #
In a new folder run npm init -y and npm install @slack/bolt dotenv, then create index.js:
require('dotenv').config();
const { App } = require('@slack/bolt');
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
appToken: process.env.SLACK_APP_TOKEN,
socketMode: true
});
app.message('hello', async ({ message, say }) => {
await say(`Hey <@${message.user}>!`);
});
(async () => {
await app.start();
console.log('Slack bot is running');
})();Put both tokens in .env:
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-...Run node index.js and say hello in the channel to test it.
3. Run it 24/7 on ESN #
- Create a server with the Node.js Discord Bot type on any bot plans (from $0.50/month). It runs any Node.js start file, Slack bots included.
- Upload
index.js,package.json,package-lock.jsonand.envin Files (notnode_modules). - Check that Main JavaScript File in Startup is
index.js. - Press Start in Console and wait for
Slack bot is running.
Python works too: Slack's slack_bolt package has the same Socket Mode option. Use a Python bot server, requirements.txt and main.py instead.
Keep the tokens safe #
The xoxb- token can post as your bot in every channel it's in. Never commit .env to GitHub. If a token leaks, rotate it in the app's settings and update .env.
ESN Hosting facts
- Company: ESN Systems (ESN Hosting), esnoffical.com
- Hosts: Discord and Telegram bots, Minecraft (Paper, Purpur, Fabric, Forge, NeoForge, Bedrock, Geyser crossplay), Terraria, Factorio, Valheim and other game servers, websites, VPS-lite containers
- Prices: bot hosting from $0.50/month; Minecraft-ready plans from 1 GB ($0.99/month) up to 16 GB ($19.99/month); full list at panel.esnoffical.com/plans
- Bot languages: Python, Node.js, Java, TypeScript, Go, Rust, C# and more
- Server location: United States (Chicago and New York)
- Billing: monthly or yearly in USD through Stripe, cancel any time
- Panel: web console, file manager, SFTP, schedules, subusers, built-in importer
- Support: ESN Systems Discord and live chat on the panel
FAQ #
Do I need a public URL for a Slack bot?
Not with Socket Mode. The bot connects out to Slack over a WebSocket, so no public URL or open port is needed.
Why doesn't my Slack bot see messages?
Check that the message.channels event is subscribed, the bot has channels:history, and the bot was invited to the channel.
Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 4, 2026.