Weekend Creative Challenge: Tiny Tale Toy – An AI-Powered Choose-Your-Own-Adventure Game
An AI-powered choose-your-own-adventure game where every narrative branch is generated live by Amazon Bedrock, AWS Lambda, and Amplify.
Vision & What the App Does
Storytelling is one of humanity’s oldest forms of creative expression, but interactive storytelling has always been bound by predetermined branch trees written by human authors. With Tiny Tale Toy, I wanted to build an infinite choose-your-own-adventure game where every path, choice, and narrative twist is generated dynamically in real-time by Generative AI on AWS.
When players load Tiny Tale Toy, they pick a fantasy or sci-fi archetype—such as a cunning wizard, a fearless knight, or an ancient robot—and a genre ranging from high fantasy to dystopian cyberpunk or eerie horror. From the very first scene, Amazon Bedrock crafts an engaging opening situation with genuine tension, accompanied by three unique, action-driven decision paths. Every time the player selects an action, the application builds on the cumulative story history, preserving character choices, maintaining narrative continuity, and steering towards an epic conclusion over five chapters. At the conclusion, the player receives a complete narrative chronicle that they can copy and share.
How I Built It
Building a real-time branching narrative with low latency and zero maintenance led me directly to a modern, fully serverless architecture.
- Frontend Experience: The frontend is a lightweight, responsive single-page application built with vanilla HTML5, CSS3, and modern JavaScript. I designed a dark spellbook aesthetic featuring genre-adaptive particle backdrops, a smooth typewriter rendering effect for story pacing, and dynamic choice cards with entrance micro-animations.
- Serverless Orchestration: Rather than managing servers or stateful backend containers, user actions trigger an Amazon API Gateway HTTP API endpoint. This invokes an AWS Lambda function running Python 3.12.
- Bedrock Integration & Prompt Engineering: The Lambda function formats the cumulative player history and state into a carefully structured prompt, which interfaces with Amazon Bedrock using OpenAI-compatible endpoints. The prompt strictly instructs the model to return concise story text (3–5 sentences) alongside exactly three short, punchy action choices formatted as a clean JSON payload.
- Resilience & Safe Parsing: A key engineering hurdle was handling occasional variations in LLM formatting. I implemented custom regex-based fallback extractors in Lambda to guarantee that story segments and options parse cleanly into valid JSON even if minor formatting discrepancies occur.
┌───────────────────────────────┐
│ Client Web Browser │
│ (Interactive Story UI & VFX) │
└───────────────┬───────────────┘
│
HTTPS ▼
┌───────────────────────────────┐
│ AWS Amplify │
│ (Global Static Web Hosting) │
└───────────────────────────────┘
│ API Request (JSON)
▼
┌───────────────────────────────┐
│ Amazon API Gateway (HTTP) │
│ (Low-latency endpoint + CORS) │
└───────────────┬───────────────┘
│
Invoke ▼
┌───────────────────────────────┐
│ AWS Lambda (Py 3.12) │
│ (Prompt Builder & Sanitizer) │
└───────────────┬───────────────┘
│ OpenAI-compatible API
▼
┌───────────────────────────────┐
│ Amazon Bedrock │
│ (Mistral / Nova Foundation) │
└───────────────────────────────┘
- Amazon Bedrock: Serves as the creative storytelling brain, generating narrative branches and choices.
- AWS Lambda: Executes prompt orchestration, stateless session management, and response sanitation.
- Amazon API Gateway (HTTP API): Offers ultra-low-latency API routing with CORS support for browser clients.
- AWS Amplify Hosting: Continuous deployment, SSL provisioning, and global CDN distribution directly from the GitHub repository.
What I Learned
This challenge provided a hands-on opportunity to explore the newest Amazon Bedrock features, specifically multi-model inference and OpenAI-compatible API integration. Connecting lightweight AWS Lambda functions directly to Bedrock models drastically reduced backend complexity—eliminating custom model hosting, complex credential scaffolding, or heavy container deployments.
I also learned how critical prompt design is when building interactive games: keeping choices short and distinct while maintaining conversational memory across previous turns is what creates a believable, engaging story world.
Links & Source Code
- 🚀 Live App: https://main.d3ouaihhnj43p9.amplifyapp.com/
- 💻 GitHub Repository: https://github.com/MdIbuA/tiny-tale-toy
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article