This guide outlines the steps to set up a Twitch chatbot using Node.js and the tmi.js library, aimed at developers with basic JavaScript and command-line knowledge.
The documentation for this configuration is detailed in Twitch Chat Bot Getting Started reference.
- Node.js: Required to run the chatbot. Download and install from Node.js official website.
- tmi.js: A Twitch Messaging Interface library for chat interaction, installed via npm.
Open a terminal and create a new directory for your project, then navigate into it. Or, clone this repo, and start there.
Initialize a new Node.js project within your directory:
This creates a package.json
file in your project directory.
npm init -y
Install the tmi.js package using npm:
npm install tmi.js
Follow the Twitch provided guide for Registering your App
You will need your Twitch application's Client ID and Secret to move forward.
It is recommended you leverage the Twitch CLI for generating your OAUTH token.
After installing the Twitch CLI, the following command reference will help you generate your token:
twitch token --client-id $my_client_id -s "chat:read chat:edit" -u
After updating the "chatbot.js" code to meet your needs, including adding the token generated in the last step, use the following to run your bot:
node chatbot.js