How to Build a Twitch Bot Using TMI.JS (a moderator bot).

Let’s build a bot! Not a bad bot like a view bot, but bot for good. Let’s build a Twitch moderator bot using tmi.js! The Twitch API is powerful and and already has lots of great bots however no bot has the flexibility of creating your own! In this video I will show you how to build a Twitch bot using TMI.JS from start to finish. You’ll see how to use the developer portal, set up oauth, set the correct scopes, get an access token, create a bot using JavaScript, NodeJS, and NPM, invite the bot to your Twitch channel, and have it moderate your chat. Also, We have made this bot open source and will continue to contribute to this bot.


If you need help cloning this repo, or setting up your developer machine, see my other video:

GitHub Repo

★ Subscribe!
★ I’m Live Every Tues/Thurs/Sat on Twitch
★ Join our Full Stack Discord Community!
★ Documentation found here

00:00 – Intro
00:19 – Why
00:56 – Prerequisites
01:16 – Twitch Developer Site
02:08 – Bootstrap Our App
05:59 – Install tmi.js
07:21 – Start the App
07:50 – OAuth Token
10:37 – Start Bot with Auth
10:57 – Code Cleanup
13:37 – !hello command
13:47 – Moderator Code
20:32 – DO NOT DO THIS
22:39 – Testing the App
22:59 – Made the Bot Open Source

🔔 Social Media 🔔
► Twitch
► Twitter
► Discord
► Instagram
► Facebook
► GitHub

► Techno Tim Amazon Store:

Techno Tim Kits:
► 4K YouTube Kit:
► Pro Level Live Streaming Kit:
► Budget Gaming Streaming PC 2020:
► Performance Virtualization Server:
► Budget NAS Server:
► Coding & Gaming Keyboards:
► Coding & Gaming Mice:

This description contains affiliate links. If you click on one of them, I’ll receive a small commission at no cost to you. Thank you.

⏯ Recommended Videos ⏯
► 20 Ways to Use a Virtual Machine (and other ideas for your homelab)
► Remote Gaming with Promox
► Let’s Build a Discord Bot Using DiscordJS – Moderator Bot
#tmijs #TwitchBot #TechnoTim #OpenSource #twitch #TwitchDeveloper

Description Tags: Techno Tim, technotim, tmijs, tmi.js, create a chat bot, twitch chat bot, twitch api development, software engineering, software engineer, twitch gaming api, twitch chatting bot, twitch robot, twtch moderator channel, moderators, help your moderators, how to build a twitch bot.

Thank you for watching!



  • Techno Tim 12 months ago

    Which bot do you use in your twitch chat?

    BTW, if you're new here welcome! Subscribe for more content like this! ✨

  • AoXNeR 12 months ago

    great vid, quick question, as of today the request to the process has changed. now you require a code to get a token, but the code is valid for only one use (run). do i have to keep generating codes for the bot to run? how do u make it automatic (getting the new code from get request, they don't give it back)
    hope u could understand…

  • David Lisle 12 months ago

    I can not seem to get Yarn to work on my VS code

  • White Rabbit2 12 months ago

    where is the doc in github?

  • Bruno Gonçalves 12 months ago

    Man, thank you SO MUCH! I had several doubts on authorizing my bot without issues, but your video clarified my ideas and made it so much easier, thanks to you, my exercise bot can work properly! Although I didn't quite managed to change the bot's name on the chat. How do I do that?

  • Drackrath 12 months ago

    For everyone working with a different Editor. Just go into Webstorm or anything else and use "npm" instead of "yarn" for all procedures.

  • Awsomebudderbro gaming 12 months ago

    Hey I am new to this kind of thing and I am trying to figure out how to get a terminal or a GUI. Any help will be appreciated. I can't join the discord because I am already full on servers I believe.

  • xHeaveny 12 months ago

    You got a new subscriber 🙂

  • Will 12 months ago

    I have a question. If I have my bot hosted on Glitch, what would the OAuth redirect URL be? Thanks

  • e2r0r 12 months ago

    Thats amazing! Thanks!

  • Wasied 12 months ago

    thanks a lot

  • OfficialRDB 12 months ago

    Hey great via. I made it so it always logs the messages to a discord channel.
    Is there a way that i can talk inside my discord to sends the message towards twitch chat ?

  • GwnDoggo 12 months ago

    your code is so messy

  • Fevzi Çakmak 12 months ago

    Thx for guide. I have a question. Blocked words not specified. Example: cats or asdacats comments are deleted. How to specified the words ?

  • BloatedNikNak 12 months ago

    I noticed that at 19:43 you added
    "if (userstate.username === BOT_USERNAME) return;"
    this code is not needed, and will never be executed, as the line above that does exactly this.
    "if (self) return;"

  • Anthony Sistilli 12 months ago

    Great video man!

  • Promote Streams 12 months ago

    Hey dude
    How did you set up tthe !hostme command on your twitch account

  • linkygirl7200 12 months ago

    yarn add esm didnt work for me….. idk what to do

  • Ask94 12 months ago

    Hey just using you'r preconfig, its great!
    Its interesting for me because i hadnt written before in Java / Node.js

    Just have a Question.
    Is there a way to auto-update if i put in a new message command? Or do i need to restart the app every time ?

  • Jonathan 12 months ago

    Nice video, it was very helpful an informative just when I'm starting to get interested in custom twitch bots! I am fairly new when it comes to coding and stuff, I was wondering if there was a way to make a bot so you can do something like !timeout600=test as a command to do a 10m timeout for anyone that says the word "test" and maybe something like !timeoutreset to reset the command so that no one else will be timed out for saying "test"? I'm not sure if that is possible, but it would be helpful especially when dealing with twitch chat spam bots.

  • ShadowJuve 12 months ago


  • Digital 12 months ago

    You should vid on how to make custom commands for your twitch bot. @Techno Tim

  • Digital 12 months ago

    Hello, the oauth2 isnt working is there another website to go to??

  • Digital 12 months ago

    Hello, The Yarn add esm didn't work it said there was a error

  • Tybn 12 months ago

    do you have a problem where the bot requires authentication and then reads and replys to everything twice

  • Slepyps 12 months ago

    Hey! I'm having a problem. Every time I send a message, it filters it, no matter what is said. Can you help out?

  • harveydotdotdot 12 months ago

    Since adding delete functionality I get an error everytime I send a message on the chat. I understand I wont be messaging my chat all the time but I dont want the app to fall over whenever I do any help?

  • Arif Mitha 12 months ago

    This video is awesome, and overall your channel is great. You earned yourself a sub.

  • dogdaytv 12 months ago

    Amazing. Was starting to plan out writing a Twitch bot for learning purposes and this video appeared. High quality, thorough and overall very comprehensive. Thanks!

  • Naig Carillo 12 months ago

    Hey! Can you by any chance deploy this on heroku and make a video of it? Would definitely help. Much appreciation on this tutorial.

  • mrPlus 12 months ago

    Good tutorial 😉

  • Markus Meier 12 months ago

    it's a good tutorial, i just have one question, is there any way the bot will run even when the computer is turned off.

  • Tobi 12 months ago

    Please make a !addcom tutorial!!!

  • JoshyPlays 12 months ago

    Thanks! finally i found an up to date tutorial!

  • Rodrigo Gil 12 months ago

    hey is it possible to make it auto asnwering with the browser snippet? like "!blah" and it says "blah blah blah"?
    (total noob)

  • Stepqen Live 12 months ago

    Everytime i start the bot i get an error of `No response from Twitch.` anyone know why

  • FollowSonik 12 months ago

    Johnny Dep is coding.. Now I saw everything!

  • Raj Shrishrimal 12 months ago

    Superb video 💥🎉

Comments are closed.