Inspiration

Once a Twitch chat passes a few hundred viewers, it scrolls too fast to read. The streamer catches a handful of messages, and everyone else's opinion is lost. We asked: what if the whole chat could speak with one voice?

What it does

Hivemind turns a busy Twitch chat into a single live AI character on stream.

  • Listens to everyone. It reads every chat message in real time through Twitch EventSub.
  • Filters toxicity first. Every message goes through OpenAI moderation. Flagged messages are dropped and never shape what the Hivemind says.
  • Finds the consensus. Every window (20 seconds by default; the streamer can set 5 to 120 seconds) it groups messages by meaning rather than exact wording, so "LEFT!!", "take the left door" and "go left at the statue" count as one opinion.
  • Speaks for the crowd. An animated face on the overlay talks to the streamer with text-to-speech: "We're all in agreement — it's time to head left!"
  • Shows the room's mood. The face changes between hyped, bored, salty, confused, wholesome and chaotic, and gets more intense as chat does.
  • Live consensus meter. The top 3 opinions with their share of chat, plus a messages-per-minute counter.
  • Reacts to Twitch events. Raiders get "absorbed" into the Hivemind, and subs, cheers and follows trigger in-character shoutouts.
  • Streamer dashboard. Pause, mute TTS, change the persona, set the window length, or press Ask Chat to pose a question and get chat's consensus answer.

Try it

Live demo, no login needed: https://hivemind-qefg.onrender.com. Open it and you get your own private sandbox room. Type as chat, or start a scenario (such as a boss fight) with hundreds of simulated viewers, and watch the meter and the face react. Streamers can log in with Twitch and add the overlay link to OBS as a browser source. The first load can take about 30 seconds while the free Render service wakes up.

Code: https://github.com/Blop77/Codex

How we built it

  • Backend: Node.js and TypeScript with Express and WebSockets. It uses Twitch OAuth and EventSub over WebSocket, so it needs no public webhook endpoint. It runs locally or on Render.
  • AI pipeline: for each window it makes one batched moderation call, then one embeddings call followed by cosine clustering, then one structured-output chat call for labels, mood and the spoken line, then TTS.
  • Overlay: plain HTML, CSS and SVG, loaded as an OBS browser source.
  • Chat simulator: generates realistic chat with typos, emotes, spam and shifting opinions at 500+ messages a minute, so it can be tested and demoed at scale.

How we used Codex

Codex wrote the application. We split the work into an AGENTS.md rulebook and a SPEC.md with a fixed WebSocket message format, then ran the build as a sequence of prompts in one main Codex thread:

  1. Scaffold the server, the WebSocket broadcast and a mock endpoint, so the overlay could be built in parallel.
  2. Add Twitch OAuth with token refresh, and the EventSub WebSocket with keepalive, reconnect and revocation handling.
  3. Build the Hivemind pipeline (moderation, deduplication, embeddings, clustering, structured output, TTS) with unit tests.
  4. Build the overlay, dashboard and chat simulator.
  5. Debug and fix the clustering. Live tests showed one opinion split into three bars, so Codex added an intent-merging step, and later a regression test for it.
  6. Make Hivemind multi-room, with a private sandbox for each visitor, and deploy it to Render.

The AGENTS.md rules kept Codex consistent across prompts: secrets only in .env, model names from config, batched API calls, and an overlay that keeps working if OpenAI is down. We also used Claude for planning, code review and editing the demo video. All the application code was written by Codex. Codex session ID: 01a190c3-5edf-7081-9102-d4f2e1628172

Challenges we ran into

  • Same opinion, different words. Embedding similarity alone split "go left" into several clusters, and we fixed it with an AI intent-merging step.
  • Real-time at scale. Sending one API call per message would be slow and expensive, so everything is batched per window.
  • Safety. One voice for the whole chat could be used to amplify trolls, so moderation runs before anything else, and chat text is treated as untrusted data to block prompt injection.

Accomplishments that we're proud of

  • It works end to end on real Twitch chat, with live audio, giving a fresh consensus every window.
  • It degrades gracefully: if OpenAI fails, the overlay keeps showing the last state instead of crashing.

What we learned

EventSub over WebSocket is the fastest way to build Twitch tools without running a webhook server. Giving Codex a strict spec and a fixed message format let our team build the backend and the overlay in parallel.

What's next

Hivemind Clash: when one channel raids another, both communities' Hiveminds appear on screen and debate, and both chats vote on the winner. After that, multi-language chat and per-channel personas.

Built With

Share this project:

Updates

Submission history