{"slug": "ai-mystery-game-building-an-interactive-ai-powered-mystery-game-with-amazon", "title": "AI Mystery Game: Building an Interactive AI-Powered Mystery Game with Amazon Bedrock", "summary": "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.", "body_md": "What if you could generate a completely new mystery every time you play, investigate the clues, request hints, and let AI evaluate your answer?\n\nI built AI Mystery Game, a browser-based game that combines generative AI with interactive gameplay using Amazon Bedrock, AWS Lambda, and Amazon API Gateway.\n\nPlayers 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.\n\n🔗 Live Demo: [https://ai-mystery-game-jyo.netlify.app/](https://ai-mystery-game-jyo.netlify.app/)\n\n💻 GitHub Repository: [https://github.com/GunnerJyo/ai-mystery-game](https://github.com/GunnerJyo/ai-mystery-game)\n\n🎯 The Idea\n\nI wanted to build something that used generative AI for more than answering questions or generating ordinary text.\n\nThe idea was to create an interactive experience where AI generates the content and the player becomes part of the story.\n\nThe application allows players to:\n\n🕵️ Generate unique AI-created mysteries.\n\n🎚️ Select different difficulty levels.\n\n🧩 Choose categories such as Logic, Crime, Fantasy, Science, and Adventure.\n\n💡 Request hints when they get stuck.\n\n✅ Submit answers for AI evaluation.\n\n📖 Explore new stories every time they play.\n\nThe mysteries are generated dynamically using Amazon Nova Lite through Amazon Bedrock, making each game a new experience.\n\n🏗️ Architecture Overview\n\nI used a lightweight serverless architecture to connect the browser-based game with a generative AI backend.\n\n```\n      Player\n         |\n         v\n  Web Frontend\n```\n\nHTML / CSS / JavaScript\n\n             |\n\n             | HTTP POST\n\n             v\n\n    Amazon API Gateway\n\n             |\n\n             | Invokes\n\n             v\n\n         AWS Lambda\n\n        Python Backend\n\n             |\n\n             | Bedrock Converse API\n\n             v\n\n      Amazon Bedrock\n\n       Amazon Nova Lite\n\n             |\n\n             v\n\n   Generate / Hint / Check\n\n             |\n\n             v\n\n         AWS Lambda\n\n             |\n\n             v\n\n    Amazon API Gateway\n\n             |\n\n             v\n\n       Web Frontend\n\nThe frontend is hosted on Netlify, while the backend processing and AI generation are handled by AWS.\n\nTechnologies and AWS Services\n\nTechnology / Service\n\nPurpose\n\nHTML, CSS, JavaScript\n\nGame interface and interactions\n\nAmazon Bedrock\n\nGenerative AI capabilities\n\nAmazon Nova Lite\n\nMystery generation, hints, and answer evaluation\n\nAWS Lambda\n\nServerless Python backend\n\nAmazon API Gateway\n\nHTTP API connecting the frontend and backend\n\nAWS IAM\n\nAccess control and permissions\n\nNetlify\n\nFrontend hosting\n\n⚙️ How I Built It\n\nI divided the application into two main components: the frontend game interface and the serverless backend.\n\nI created the interface using HTML, CSS, and JavaScript.\n\nThe 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.\n\nJavaScript collects the player's selections and sends the request to the backend using the Fetch API.\n\nI implemented the backend using Python in AWS Lambda.\n\nRather than creating a separate Lambda function for every game feature, I designed a single function that handles multiple actions based on the incoming request.\n\nThe backend supports three main actions:\n\ngenerate — Creates a new mystery based on the selected category and difficulty.\n\nhint — Generates a helpful clue without directly revealing the solution.\n\ncheck — Evaluates the player's answer and returns feedback and a score.\n\nThis approach keeps the backend relatively simple while supporting the application's main gameplay features.\n\nThe Lambda function communicates with Amazon Bedrock using the Bedrock Converse API.\n\nI used Amazon Nova Lite to generate mysteries, create hints, and evaluate answers.\n\nFor mystery generation, the prompt requests structured output containing fields such as:\n\nTitle\n\nStory\n\nClues\n\nQuestion\n\nAnswer\n\nExplanation\n\nRequesting a structured JSON response makes it easier for the frontend to display the mystery and its associated information.\n\nThe same model can support different interactions by using separate prompts for each action.\n\nAmazon API Gateway exposes the Lambda function through an HTTP endpoint.\n\nWhen a player interacts with the game:\n\nJavaScript sends an HTTP POST request.\n\nAPI Gateway receives the request.\n\nAPI Gateway invokes the Lambda function.\n\nLambda communicates with Amazon Bedrock.\n\nThe generated content or evaluation result is returned to the browser.\n\nThis architecture keeps the frontend separate from the backend and avoids the need to manage a traditional application server.\n\n🧠 Prompt Engineering for Interactive Gameplay\n\nOne of the interesting parts of this project was using prompts to control different AI behaviors.\n\nMystery generation, hint generation, and answer evaluation require different instructions, even though they use the same underlying model.\n\nFor example, a mystery-generation prompt can specify:\n\nGenerate an original mystery game.\n\nCategory: Logic\n\nDifficulty: Medium\n\nInclude:\n\nReturn the result in a structured JSON format.\n\nThe actual prompt can be adjusted to match the application's expected response schema.\n\nFor 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.\n\nThis demonstrates how prompt design can help one foundation model support multiple features within a single application.\n\n🛠️ Challenges I Encountered\n\nBuilding the application involved several practical development challenges.\n\nInitially, the Lambda function expected requests in the format generated by API Gateway.\n\nHowever, events submitted directly through the Lambda console had a different structure, causing errors during testing.\n\nI updated the function to handle both API Gateway requests and direct Lambda test events.\n\nThis made it easier to test individual backend operations before integrating the frontend.\n\nThe frontend and backend were hosted separately, so browser security restrictions affected API communication.\n\nI configured Cross-Origin Resource Sharing (CORS) in API Gateway and redeployed the API.\n\nAfter making the necessary configuration changes, the frontend could communicate with the backend successfully.\n\nInstead of immediately connecting every component, I tested the Lambda function independently first.\n\nThis helped identify problems with event parsing and backend processing before introducing additional frontend and API integration variables.\n\nOnce the backend was working, I connected it to the browser interface and tested the complete workflow.\n\nThe frontend needs predictable data to display the generated story, clues, hints, and evaluation results.\n\nRequesting JSON output made it easier to separate these elements and process them in JavaScript.\n\nIn 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.\n\n🔐 IAM and Permissions\n\nAWS IAM controls the permissions required by the Lambda function to invoke Amazon Bedrock and write execution logs.\n\nThe Lambda execution role should have the minimum permissions needed to perform these operations.\n\nFor production deployments, restrict access to the required Bedrock model and avoid granting unnecessarily broad permissions.\n\nThis follows the principle of least privilege and reduces the potential impact of misconfiguration.\n\n📚 What I Learned\n\nThis project gave me hands-on experience building an interactive generative AI application using AWS.\n\nMy main takeaways were:\n\nIntegrating Amazon Bedrock with AWS Lambda using the Converse API.\n\nUsing prompt engineering to support multiple application features.\n\nBuilding HTTP APIs with Amazon API Gateway.\n\nHandling different Lambda event formats.\n\nProcessing structured AI responses in JavaScript.\n\nConfiguring CORS for browser-based applications.\n\nTesting serverless backends independently.\n\nDeploying a public frontend with Netlify.\n\nCombining AI-generated content with simple game mechanics.\n\nMost importantly, I learned that generative AI can power interactive experiences rather than being limited to chatbots and text-generation tools.\n\n🚀 Future Improvements\n\nThere are several ways I could extend AI Mystery Game:\n\nMultiple endings: Let player decisions influence the outcome.\n\nDifficulty progression: Adjust future mysteries based on player performance.\n\nMystery history: Allow players to revisit previous cases.\n\nScoring and achievements: Introduce points, streaks, and leaderboards.\n\nMultiplayer mode: Allow friends to solve the same mystery together.\n\nMore categories: Add historical mysteries, puzzles, and detective challenges.\n\nImproved answer evaluation: Support alternative correct answers and partial credit.\n\nPersistent player profiles: Save progress and preferences between sessions.\n\nThese improvements could turn the project into a more complete AI-powered gaming experience.\n\n🔗 Try the Game\n\nThe application is publicly available, and the source code is available on GitHub.\n\nSource Code: [https://github.com/GunnerJyo/ai-mystery-game](https://github.com/GunnerJyo/ai-mystery-game)\n\nTry generating a mystery, requesting a hint, and submitting your answer to see how the different AI interactions work together.\n\n🏁 Conclusion\n\nAI Mystery Game combines generative AI with interactive gameplay to create a different experience each time someone plays.\n\nUsing 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.\n\nThis 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.\n\nIf you could build an AI-powered game using Amazon Bedrock, what would you create?\n\nI'd love to hear your ideas!", "url": "https://wpnews.pro/news/ai-mystery-game-building-an-interactive-ai-powered-mystery-game-with-amazon", "canonical_source": "https://dev.to/gunnerjyo/make-this-good-looking-copy-pastable-in-devto-50km", "published_at": "2026-10-24 12:30:00+00:00", "updated_at": "2026-10-24 12:44:25.088339+00:00", "lang": "en", "topics": ["generative-ai", "ai-products", "ai-tools", "ai-infrastructure", "developer-tools"], "entities": ["Amazon Bedrock", "Amazon Nova Lite", "AWS Lambda", "Amazon API Gateway", "Netlify", "AWS IAM"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/ai-mystery-game-building-an-interactive-ai-powered-mystery-game-with-amazon", "markdown": "https://wpnews.pro/news/ai-mystery-game-building-an-interactive-ai-powered-mystery-game-with-amazon.md", "text": "https://wpnews.pro/news/ai-mystery-game-building-an-interactive-ai-powered-mystery-game-with-amazon.txt", "jsonld": "https://wpnews.pro/news/ai-mystery-game-building-an-interactive-ai-powered-mystery-game-with-amazon.jsonld"}}