ESN Docs

Docs › Discord bots

How to host a Twitch chat bot 24/7 (Node.js)

1 min readUpdated Nov 4, 2026

A Twitch chat bot is a small Node.js program that connects to chat and answers commands. It only needs to stay running, which is exactly what a bot server does.

1. Make a bot account and a token #

  1. Create a separate Twitch account for the bot (for example YourChannelBot), so your own account's login never sits on a server.
  2. Register an application at dev.twitch.tv/console/apps.
  3. Get a user access token for the bot account with the chat:read and chat:edit scopes, using Twitch's own OAuth flow described in the Twitch authentication docs.

Treat the token like a password. User tokens expire, so note how you made it; when chat stops answering with a login error, make a new one.

2. A small bot with tmi.js #

On your computer, in a new folder, run npm init -y and npm install tmi.js dotenv. Then create index.js:

require('dotenv').config();
const tmi = require('tmi.js');

const client = new tmi.Client({
  identity: { username: process.env.TWITCH_BOT_USERNAME, password: 'oauth:' + process.env.TWITCH_TOKEN },
  channels: [process.env.TWITCH_CHANNEL]
});

client.on('message', (channel, tags, message, self) => {
  if (self) return;
  if (message.trim().toLowerCase() === '!discord') {
    client.say(channel, 'Join the Discord: https://discord.gg/yourinvite');
  }
});

client.connect().then(() => console.log('Connected to Twitch chat'));

And a .env file next to it:

TWITCH_BOT_USERNAME=yourchannelbot
TWITCH_TOKEN=the-token-without-oauth-prefix
TWITCH_CHANNEL=yourchannel

Run node index.js, type !discord in your chat and check that it answers.

3. Run it 24/7 on ESN #

  1. Create a server with the Node.js Discord Bot type on any bot plans (from $0.50/month). It simply runs your start file with Node.js, so a Twitch bot works the same way.
  2. In Files, upload index.js, package.json, package-lock.json and .env. Don't upload node_modules; the server runs npm install on every start.
  3. Check Startup: Main JavaScript File should be index.js.
  4. Press Start in Console and wait for Connected to Twitch chat.

Keep it well behaved #

  • Make the bot a moderator in your channel (/mod yourchannelbot) so it can post faster and its messages don't get held.
  • Don't send the same message over and over; Twitch rate-limits chat and can block a spammy bot.
  • Log what it does with console.log, so the panel console shows you what happened when something breaks.

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 #

Does a Twitch bot need a website or open port?

No. A tmi.js chat bot connects out to Twitch chat, so it doesn't need a public web address or an open port.

Why did my Twitch bot stop answering?

Most often the access token expired or was revoked. Make a new token, update .env and restart the server.

Host your bot on ESN. ESN bot servers run Python or Node.js 24/7 with a live console and file manager. Bot hosting from $0.50/month. See bot plans · or ask in the ESN Systems Discord.

Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 4, 2026.