How to make a twitch bot using NodeJS

Here’s how to create a simple Twitch bot using NodeJS.

I’m assuming you already have NodeJS installed.

If not go ahead and do that.

1. Step one make sure Node is installed

$ node -v

2. Run npm init and hit enter for all options

$ npm init

3. We now need to download the tmi.js module

$ npm install --save tmi.js

4. Create a file named index.js and insert this:

var options = {
  options: {
    debug: true
  connection: {
    cluster: "aws",
    reconnect: true
  identity: {
    //Insert your bots username here
    username: "your bots twitch username goes here",

    //Insert your OAuth Token here
    //Keep reading to find out how to get one
    password: "Your oath token goes here"

  //Insert the channel you want your bot to be in here
  channels: ["Channel name goes here"]

var client = new tmi.client(options);


client.on("connected", function(address, port){
  //When your bot connects it will send a message to the chat room
  client.action("Channel name goes here", "Your message");

5. Now your bot needs an OAuth token from twitch

Click connect with Twitch in the link above. Then sign in and copy the OAuth token. Paste the token into the code:

  password: "Your oath token goes here"
  //replace with YOUR token (this one won't work)
  password: "oauth:dsafad898sadf9sd8a9ddfas2"

6. Start your bot

$ node index.js

And that’s it but make sure your replaced the password with your OAuth token and replaced all “Channel name goes here” with the channel you want the bot to be in.