Skip to content

Stukeley/ArduinoTwitchBot

Repository files navigation

Star this repo

ArduinoTwitchBot

A customizable Twitch chatbot that sends out signals to Arduino whenever an event (eg. follow) occurs.

Built using TwitchLib and MaterialDesign for XAML.

Table of Contents

How it works

The bot connects to a Twitch user's chat and listens to events (such as: follows, subs, bits, raids and chat messages). Whenever an event occurs, a signal is sent over to an Arduino using a serial port.

The type of signal sent, its value, as well as the COM port used can all be configured by the user. The chat messages in particular are highly customizable and support different signals for different triggers (eg. commands, certain emotes).

To make this work, you will need an OAUTH Access Token from Twitch - an explanation on how to get one can be found in the Setup section.

Important - access tokens are channel-unique. That means you can only use the bot on the channel, on which you generated the token. You cannot listen to events on a random stream on Twitch!

Features

  • The ability to select which events are listened to (the ability to choose from: follows, subs, bits, raids and chat messages)
  • Signal type as well as its value can be customized (eg. we can send the value "3" either as a string, an int or a byte)
  • COM ports can be selected from a list of all available ports for your computer - no more guessing!
  • You can send a test signal to your Arduino to see if the connection works, without having to connect to a channel
  • Experimental: a list of events that occured (all follows, subs and raids in one place!)
  • Access Token (which should be kept confidential!) is hidden by default, so it's okay if you accidentally show the app on stream!

Setup

  1. If running the Framework-Dependent version: Make sure you have the .NET 6 runtime installed: you can get it from here under .NET Desktop Runtime. Otherwise (for the Self-Contained app), you shouldn't need any additional dependencies.
  2. Download the code under Releases.
  3. Run the application. Go over to the Settings tab.
  4. You now need to generate an Access Token. Go over here. Select "Bot Chat Token". Authorize the website and copy both the Client ID and the Access Token. Important - while Client ID is public information and can be exposed, Access Token has to be kept confidential. Get Client ID and Access Token from here
  5. Paste Client Id and Access Token in the respective TextBoxes in the Settings tab. Enter your Twitch channel's username. Select your desired COM port from the list below.
  6. Go back to the Home tab. Your settings will be saved automatically (they will be there even if you relaunch the app).
  7. Select desired alerts and make sure to input a value for each of the selected events.
  8. If you're unsure of anything, hover over an element on the UI and a tooltip with more information will appear.

Let me know if you need more help!

Design

Sample schematic

A sample schematic along with the code needed on the Arduino side can be found in the ArduinoTwitchBot.Example folder.
It consists of a simple project that will light up one of four LEDs on the breadboard depending on the signal (String type).
It requires the following in-app setup:

  • Follower Alert - ON (value: "Follow", type: "String")
  • Sub Alert - ON (value: "Sub", type: "String")

Of course, you can read and interpret the incomming signals however you want. This is just an example - feel free to experiment!

Feature requests

Have an idea that you would like to see in the app? Feel free to open an issue and I'll try my best to help :)