Chatbot (Backend)
Node.js server with mini-games and AI responses
This is the backend server code for a feature-rich Twitch chatbot. It handles EventSub WebSocket connections, processes commands, manages an RPG system with SQLite persistence, runs trivia games with smart answer validation, and provides AI-powered conversation via local LLM integration.
See It In Action
This bot runs behind the scenes. To interact with it, visit the Chat Interface project where it responds to user messages in real-time.
View Chat Interface Demo →Tech Stack
Node.js
🔌EventSub WebSocket
🗄️better-sqlite3
🤖Ollama AI
RPG System
- •Character progression with levels, HP, attack, defense
- •Quest system with combat mechanics
- •Shop, inventory, and equipment system
- •Player-vs-player duels
- •Gold economy with daily bonuses
Trivia Game
- •CSV-based question database
- •Smart answer checking (fuzzy + semantic)
- •Hint system with progressive reveals
- •3-minute cooldown between questions
- •Integrates with Word Similarity API
AI & Utilities
- •Local LLM via Ollama for conversations
- •Conversation history management
- •Dice roller with complex notation (d20+2)
- •Random fact & advice APIs
- •Message queue for rate limit handling
Backend Architecture
Core Components
- •EventSub WebSocket Client: Maintains persistent connection to Twitch (or mock server)
- •Command Router: Parses chat messages and routes to appropriate handlers
- •SQLite Persistence: Stores character data, wallets, inventory, and duel challenges
- •Rate Limit Queue: Prevents Twitch API throttling with 1.5s message delay
Dual-Mode Operation
- •Live Mode: Connects to real Twitch API and EventSub WebSocket
- •Custom Mode: Connects to local Chat Interface emulator for testing
Sample Commands (keyword "bot" is configurable)
bot rpg charView character statsbot rpg questGo on adventurebot triviaStart trivia questionbot ask [question]AI-powered responsebot roll d20+5Roll dice with modifierbot rpg shopBrowse items to buy