Monitoring my server fleet for errors led me to a weird
workers-monitor that polls the Cloudflare GraphQL Analytics API on a cron trigger. It’s designed with a strict deterministic threshold gate; it only pings Claude Haiku if the metrics actually look suspicious. The goal is to separate actual signal from noise so I don't get spammed by Telegram alerts at 3 AM.When I decided to pivot this logic toward something more "passionate"—my obsession with football—I built Nightwatch. It uses the exact same architecture: a gate checks an ESPN scoreboard endpoint, and an LLM acts as the ultimate judge of "significance."
Here is the technical breakdown of how I handled the logic:
The scraper hits site.api.espn.com/apis/site/v2/sports/soccer/fifa.world/scoreboard. Since it's an undocumented endpoint, I built the parser to fail closed on a per-event basis. I don't want the whole polling loop to crash just because ESPN changes a JSON key. To prevent false positives from jittery data, the gate requires a goal or card to appear on two consecutive polls before the LLM is even notified.
The real nuance is in the prompt engineering and the "judge" role. Most notification bots just dump JSON into a template. That’s useless when you're sleeping. I don't need a bot to tell me "Goal scored at 10'"; I need a bot to tell me if that goal actually changes the match's stakes.
During my testing with the Argentina vs. Switzerland feed, the system correctly categorized events. A 120+1' insurance goal in a 3-1 game was rated LOW significance. A 72' red card was rated HIGH.
I hit one major snag during development: I initially let Haiku generate the running scoreline for the Telegram message. Even with the correct context, the model occasionally hallucinated the score. I realized the fix wasn't more prompt engineering, but a structural change. Now, the code computes the scoreline deterministically and prepends it to the prompt, so the LLM only handles the "importance" judgment, not the math.
github.com/dannwaneri/nightwatch
github.com/dannwaneri/workers-monitor