AI Mystery Game: Building an Interactive AI-Powered Mystery Game with Amazon Bedrock A developer built AI Mystery Game, a browser-based game that uses Amazon Bedrock's Amazon Nova Lite model to generate original mysteries, produce hints, and score player answers. The frontend runs on Netlify in HTML, CSS and JavaScript, while a single Python AWS Lambda function behind Amazon API Gateway handles three actions — generate, hint and check — via the Bedrock Converse API, with prompts requesting structured output such as title, story, clues, question, answer and explanation. What if you could generate a completely new mystery every time you play, investigate the clues, request hints, and let AI evaluate your answer? I built AI Mystery Game, a browser-based game that combines generative AI with interactive gameplay using Amazon Bedrock, AWS Lambda, and Amazon API Gateway. Players can choose a difficulty level and mystery category, generate an original case, investigate the story, ask for hints, and submit their answers for AI-powered evaluation. 🔗 Live Demo: https://ai-mystery-game-jyo.netlify.app/ https://ai-mystery-game-jyo.netlify.app/ 💻 GitHub Repository: https://github.com/GunnerJyo/ai-mystery-game https://github.com/GunnerJyo/ai-mystery-game 🎯 The Idea I wanted to build something that used generative AI for more than answering questions or generating ordinary text. The idea was to create an interactive experience where AI generates the content and the player becomes part of the story. The application allows players to: 🕵️ Generate unique AI-created mysteries. 🎚️ Select different difficulty levels. 🧩 Choose categories such as Logic, Crime, Fantasy, Science, and Adventure. 💡 Request hints when they get stuck. ✅ Submit answers for AI evaluation. 📖 Explore new stories every time they play. The mysteries are generated dynamically using Amazon Nova Lite through Amazon Bedrock, making each game a new experience. 🏗️ Architecture Overview I used a lightweight serverless architecture to connect the browser-based game with a generative AI backend. Player | v Web Frontend HTML / CSS / JavaScript | | HTTP POST v Amazon API Gateway | | Invokes v AWS Lambda Python Backend | | Bedrock Converse API v Amazon Bedrock Amazon Nova Lite | v Generate / Hint / Check | v AWS Lambda | v Amazon API Gateway | v Web Frontend The frontend is hosted on Netlify, while the backend processing and AI generation are handled by AWS. Technologies and AWS Services Technology / Service Purpose HTML, CSS, JavaScript Game interface and interactions Amazon Bedrock Generative AI capabilities Amazon Nova Lite Mystery generation, hints, and answer evaluation AWS Lambda Serverless Python backend Amazon API Gateway HTTP API connecting the frontend and backend AWS IAM Access control and permissions Netlify Frontend hosting ⚙️ How I Built It I divided the application into two main components: the frontend game interface and the serverless backend. I created the interface using HTML, CSS, and JavaScript. The interface includes controls for selecting a mystery category and difficulty level, along with buttons to generate a mystery, request a hint, and submit an answer. JavaScript collects the player's selections and sends the request to the backend using the Fetch API. I implemented the backend using Python in AWS Lambda. Rather than creating a separate Lambda function for every game feature, I designed a single function that handles multiple actions based on the incoming request. The backend supports three main actions: generate — Creates a new mystery based on the selected category and difficulty. hint — Generates a helpful clue without directly revealing the solution. check — Evaluates the player's answer and returns feedback and a score. This approach keeps the backend relatively simple while supporting the application's main gameplay features. The Lambda function communicates with Amazon Bedrock using the Bedrock Converse API. I used Amazon Nova Lite to generate mysteries, create hints, and evaluate answers. For mystery generation, the prompt requests structured output containing fields such as: Title Story Clues Question Answer Explanation Requesting a structured JSON response makes it easier for the frontend to display the mystery and its associated information. The same model can support different interactions by using separate prompts for each action. Amazon API Gateway exposes the Lambda function through an HTTP endpoint. When a player interacts with the game: JavaScript sends an HTTP POST request. API Gateway receives the request. API Gateway invokes the Lambda function. Lambda communicates with Amazon Bedrock. The generated content or evaluation result is returned to the browser. This architecture keeps the frontend separate from the backend and avoids the need to manage a traditional application server. 🧠 Prompt Engineering for Interactive Gameplay One of the interesting parts of this project was using prompts to control different AI behaviors. Mystery generation, hint generation, and answer evaluation require different instructions, even though they use the same underlying model. For example, a mystery-generation prompt can specify: Generate an original mystery game. Category: Logic Difficulty: Medium Include: Return the result in a structured JSON format. The actual prompt can be adjusted to match the application's expected response schema. For hints, the instructions need to guide the player without immediately revealing the answer. For answer evaluation, the model needs to compare the submitted response with the intended solution and provide useful feedback. This demonstrates how prompt design can help one foundation model support multiple features within a single application. 🛠️ Challenges I Encountered Building the application involved several practical development challenges. Initially, the Lambda function expected requests in the format generated by API Gateway. However, events submitted directly through the Lambda console had a different structure, causing errors during testing. I updated the function to handle both API Gateway requests and direct Lambda test events. This made it easier to test individual backend operations before integrating the frontend. The frontend and backend were hosted separately, so browser security restrictions affected API communication. I configured Cross-Origin Resource Sharing CORS in API Gateway and redeployed the API. After making the necessary configuration changes, the frontend could communicate with the backend successfully. Instead of immediately connecting every component, I tested the Lambda function independently first. This helped identify problems with event parsing and backend processing before introducing additional frontend and API integration variables. Once the backend was working, I connected it to the browser interface and tested the complete workflow. The frontend needs predictable data to display the generated story, clues, hints, and evaluation results. Requesting JSON output made it easier to separate these elements and process them in JavaScript. In a production application, the response should also be validated before it is used by the frontend, since generative AI models do not guarantee perfectly formatted output on every request. 🔐 IAM and Permissions AWS IAM controls the permissions required by the Lambda function to invoke Amazon Bedrock and write execution logs. The Lambda execution role should have the minimum permissions needed to perform these operations. For production deployments, restrict access to the required Bedrock model and avoid granting unnecessarily broad permissions. This follows the principle of least privilege and reduces the potential impact of misconfiguration. 📚 What I Learned This project gave me hands-on experience building an interactive generative AI application using AWS. My main takeaways were: Integrating Amazon Bedrock with AWS Lambda using the Converse API. Using prompt engineering to support multiple application features. Building HTTP APIs with Amazon API Gateway. Handling different Lambda event formats. Processing structured AI responses in JavaScript. Configuring CORS for browser-based applications. Testing serverless backends independently. Deploying a public frontend with Netlify. Combining AI-generated content with simple game mechanics. Most importantly, I learned that generative AI can power interactive experiences rather than being limited to chatbots and text-generation tools. 🚀 Future Improvements There are several ways I could extend AI Mystery Game: Multiple endings: Let player decisions influence the outcome. Difficulty progression: Adjust future mysteries based on player performance. Mystery history: Allow players to revisit previous cases. Scoring and achievements: Introduce points, streaks, and leaderboards. Multiplayer mode: Allow friends to solve the same mystery together. More categories: Add historical mysteries, puzzles, and detective challenges. Improved answer evaluation: Support alternative correct answers and partial credit. Persistent player profiles: Save progress and preferences between sessions. These improvements could turn the project into a more complete AI-powered gaming experience. 🔗 Try the Game The application is publicly available, and the source code is available on GitHub. Source Code: https://github.com/GunnerJyo/ai-mystery-game https://github.com/GunnerJyo/ai-mystery-game Try generating a mystery, requesting a hint, and submitting your answer to see how the different AI interactions work together. 🏁 Conclusion AI Mystery Game combines generative AI with interactive gameplay to create a different experience each time someone plays. Using Amazon Bedrock, Amazon Nova Lite, AWS Lambda, and Amazon API Gateway, I built a serverless application where players can generate mysteries, investigate clues, request hints, and submit answers for AI evaluation. This project was a practical exploration of how managed AWS services and generative AI can be used to build creative applications without managing traditional server infrastructure. If you could build an AI-powered game using Amazon Bedrock, what would you create? I'd love to hear your ideas