Jonathan Scott's Work | ContraWork by Jonathan ScottJonathan Scott
AI Automation Engineer. I build bots and tools that deliver
A Telegram tap-and-build game where players grow a business from nothing. Progress earns in-game stars through play. Real Telegram Stars buy something different: actual business assets, generated and delivered for real.
THE DESIGN PROBLEM
Two currencies in one interface. The earned currency drives the game loop. The real one crosses from simulation into fulfillment — a player running a fictional business can buy a real one's worth of assets without leaving the chat. The two have to feel connected enough that the purchase is a natural next step, and separated enough that nobody confuses play money for a payment.
HOW IT WORKS
Node.js, Express, and MongoDB, with a Telegram Mini App front end. The game engine is server-authoritative: the client sends intent — "10 taps" — never outcomes. XP, levels, compounding upgrade costs, passive income, and missions are pure functions, with every balance number in a single catalog file.
The money path is the part worth reading. Telegram Stars invoices run through pre-checkout validation to fulfillment. A unique index on the Telegram charge ID means a replayed payment is caught and ignored. Stars debit through a conditional atomic update, so two concurrent purchases can't both succeed. Generation failures after a successful debit refund automatically.
Claude is treated as untrusted input. The router validates its JSON, overwrites the user ID with the authenticated Telegram ID, re-derives prices from the catalog rather than trusting the model, and rejects any function outside a four-entry allow-list.
Every request carries HMAC-validated Telegram initData, plus a webhook secret. The server returns render-ready screens through a JSON UI contract, so the client holds no prices and no rules.
Verified by 33 unit tests and 20 end-to-end HTTP tests against a real database. Rate limiting, structured logs with secrets redacted, health checks, Docker, deployed on Railway. A product line of three self-contained tools sold through the NuroWorks marketplace: SocialFlow Pro (content planning and caption generation), LeadFlow Pro (client acquisition, outreach scripts, and proposal generation), and NuroFlow Pro (workflow automation). Sold individually or as a bundle.
THE DESIGN DECISION
Each tool is a self-contained HTML application delivered as a ZIP. No server, no account, no install, no subscription. The buyer unzips it, opens it in a browser, and it works — offline, indefinitely, with no dependency on my infrastructure staying up.
That constraint shaped everything. All state lives client-side, every interaction is handled in the browser, and the whole product has to survive being opened from a file path years after purchase. It also means zero hosting cost per customer and nothing for a buyer to lose access to.
DELIVERY
Checkout runs through Payhip, with the package delivered immediately on purchase. Pricing is one-time — no recurring fees, and buyers keep their files. A Telegram bot that took a user from a single message to a finished, paid-for deliverable, with no human in the loop at any step. Built, deployed, and run in production; the bot has since been retired, and the source is public.
WHAT IT DID
A user started a conversation, answered a few questions about their niche, and the bot generated a complete business asset pack — content, copy, and supporting documents. It previewed part of the result, took payment, then delivered the full package as downloadable files.
HOW IT WORKS
A Node.js and Express service receives Telegram webhooks and routes them through modular command handlers, holding conversation state across a multi-step flow. The Anthropic Claude API does the generation, with configurable models, tuned token budgets, and automatic retry on transient failures.
Payment runs on Stripe, and the fulfillment path is idempotent by design: incoming webhook events are deduplicated by event ID, and a unique database constraint on the charge makes double-delivery and double-charging structurally impossible rather than merely unlikely. Session and usage state lives in Redis on Upstash, with an in-memory fallback so the service runs locally without external dependencies.
It ships as a multi-stage Docker image that runs as a non-root user with health checks and correct signal handling for graceful shutdown, behind a GitHub Actions pipeline that builds and validates the image on every push. Most AI site builders hand you one page and a prompt box. This one ask four questions and returns a complete, navigable website — Home, About, Services, Pricing, Contact — with working links between them, delivered as a preview URL and a downloadable .zip.
WHAT IT SELLS
A free homepage (one per day), a full five-page website, or a five-stage sales funnel. Payment runs on Telegram Stars, which is what Telegram requires for digital goods sold inside a bot.
HOW IT WORKS
A Node.js and Express service on MongoDB, running as a Telegram bot, a Telegram Mini App, and a Discord bot from one codebase. Claude generates the site in a three-stage orchestration — brief, then pages, then CSS — behind a single API client with a daily spend breaker.
The payment path is built around one rule: a build that fails after a successful payment must never lose the buyer's money. Generation never throws for content reasons; it returns a result object so the caller can decide. Failures refund automatically, without the buyer having to ask. Pricing is validated server-side from a single catalog, so the client can't propose its own price.
Preview and download routes use capability URLs — an unguessable 16-byte slug is the credential — because Telegram's open Link hands the URL to the system browser, which can't carry an auth header, and generated pages link to each other relatively.
Operationally: tiered rate limits per user, a one-build-at-a-time concurrency guard, a daily spend cap that pauses builds, and a health endpoint reporting uptime, database state, todays spend, and whether builds are paused. Deployed on Railway from a Docker image, behind a CI pipeline that runs syntax, unit, and end-to-end suites on every push — a red suite blocks the merge, so it never reaches production.
Discord runs the free tier as an acquisition channel and routes paying users to Telegram, because Discord has no arbitrary-amount invoice and no bot-callable refund.