Twitch

How to make a Twitch chat bot

Build a Twitch chat bot with tmi.js: getting an OAuth token, handling commands and cooldowns, loyalty points, and generating the bot from a description with Devellix.

5 min read · Updated Jul 28, 2026

A Twitch chat bot connects to a channel's chat and responds to commands, runs giveaways, tracks loyalty points, or moderates. It joins chat like any user, using an OAuth token tied to a bot account.

The common stack is Node.js with tmi.js. This guide covers authentication, the shape of a bot, and how to generate one from a sentence so you can focus on the commands your community wants.

Step by step

  1. 1

    Make a bot account and get an OAuth token

    Create a separate Twitch account for the bot, then generate a chat OAuth token for it. The token lets your code connect to chat as that account. Keep it in an environment variable.

  2. 2

    Understand a tmi.js bot

    A tmi.js bot creates a client with the bot's identity and the channel to join, connects, and listens for message events. Each message handler checks the command and replies with client.say.

  3. 3

    Add commands with cooldowns

    A command like !dice checks a per-user cooldown so it cannot be spammed, does its work, and replies. Cooldowns and simple rate limits keep chat readable and are worth adding from the start.

  4. 4

    Track points or watch time

    A loyalty bot rewards active chatters on an interval and answers a !points command from a stored balance. Persisting balances to a file or database keeps them across restarts.

  5. 5

    Generate the bot with Devellix

    Describe the bot on Devellix and pick Twitch. It writes a tmi.js project with your commands and cooldowns, installs the dependencies, and bundles it. You add the bot's token and channel and run it.

What you can build

  • A !dice or !roll command with a per-viewer cooldown
  • A loyalty points bot that rewards watch time
  • A giveaway bot that draws from active chatters
  • A shoutout or !so command for raids
  • A moderation bot that filters banned phrases
Describe yours

Frequently asked

tmi.js is the standard Node.js library for Twitch chat. It connects to a channel and dispatches message events. Devellix generates tmi.js bots.
It is best practice to make a dedicated bot account and generate its chat OAuth token, so the bot posts under its own name. Devellix generates the code that uses that token.
The bot stores the last time each user ran a command and ignores repeats until the cooldown passes, which stops spam. Devellix includes per-user cooldowns in generated commands.
With Devellix you describe the bot in plain English and it writes the full tmi.js project. You add the token and channel and run it, and you own the code to edit.

Keep reading

Stop reading. Start building.

Describe what you want and Devellix writes it, builds it, and hands you the source. Free credits to start.