A real-time Twitch bot that detects juggling siteswap patterns in chat messages, validates them, and displays animated juggling simulations using the SiteswapJS library. Perfect for juggling streams and interactive audience engagement.
- Real-time Siteswap Detection: Automatically detects and validates siteswap patterns in Twitch chat messages
- Live Animation: Renders juggling animations in real-time using HTML5 Canvas
- AI-Powered Responses: Generates enthusiastic, contextual responses using OpenAI's GPT model
- Speech Bubbles: Displays AI responses as animated speech bubbles over the animation
- Emote Integration: Supports Twitch, BetterTTV, FrankerFaceZ, and unicode emoji as juggling props
- OBS Integration: Easy setup as a browser source in OBS Studio
- Comprehensive Validation: Supports vanilla, multiplex, synchronous, and synchronous multiplex siteswap patterns
- Node.js (v14 or higher)
- A Twitch account with bot credentials
- OpenAI API key (for AI responses)
-
Clone the repository:
git clone https://github.com/JuggleWithTim/siteswap-js-twitch.git cd siteswap-js-twitch -
Install dependencies:
npm install
-
Build the project:
npm run build
-
Copy the example environment file:
cp .env.example .env
-
Edit
.envwith your credentials:TWITCH_USERNAME=your_bot_username TWITCH_PASSWORD=oauth:your_oauth_token OPENAI_API_KEY=sk-0000000000000000000000000000000 CHANNEL_NAME=your_channel_name CHANNEL_ID=your_channel_user_id- TWITCH_USERNAME: Your Twitch bot's username
- TWITCH_PASSWORD: OAuth token from Twitch Token Generator
- OPENAI_API_KEY: Your OpenAI API key for generating responses
- CHANNEL_ID: BTTV uses the ID instead of username. You can convert your username to an ID using Streamweasels
-
Start the server:
npm start
-
The server will run at
http://localhost:3030 -
In OBS Studio:
- Add a "Browser Source"
- Set URL to
http://localhost:3030 - Position and resize as needed in your stream layout
-
The bot will automatically:
- Connect to your Twitch channel
- Monitor chat for siteswap patterns
- Validate detected patterns
- Display animations and AI responses
- Update props based on emotes
- Chat Monitoring: The bot connects to Twitch using TMI.js and monitors chat messages in real-time
- Pattern Detection: Messages are scanned for potential siteswap patterns using regex patterns
- Validation: Detected patterns are validated using the comprehensive siteswap validator
- AI Response: Valid patterns trigger OpenAI API calls to generate enthusiastic responses
- Animation: The frontend receives siteswap data via Socket.IO and renders the animation
- Visual Feedback: Speech bubbles display AI responses, and emotes can be used as props
- Vanilla: Standard siteswap notation (e.g.,
531,97531) - Multiplex: Bracketed throws (e.g.,
[55],[54]) - Synchronous: Parenthesized throws (e.g.,
(4,4),(6x,4)*) - Synchronous Multiplex: Combined sync and multiplex (e.g.,
([44],6))
- Original SiteswapJS: Tom Whitfield
- Siteswap Validator: Extracted and adapted from the original SiteswapJS project
- Animation Engine: Built on the SiteswapJS library with custom enhancements
Try these siteswap patterns in chat:
5- 5 ball cascade441- A 3 ball pattern(4,4)- Synchronous fountain[33]- Multiplex stacked cascade