AWS Builder Center

Weekend Showcase Challenge: Story Dice

Story Dice is a whimsical, serverless web application that uses Amazon Bedrock's generative AI to turn randomized dice rolls Place, Object, Trait, and Twist into engaging, 200-word flash fiction stories instantly.

Building the Future of Agentic AI | Full Stack Developer | Cloud Enthusiast
Vision and What It Does
Story Dice is a serverless, interactive web application designed to overcome writer’s block and spark spontaneous creativity for writers, educators, roleplay game masters, and cloud enthusiasts.
Inspired by physical tabletop dice games, Story Dice brings the tactile experience of creative ideation into the cloud using generative AI:
  • Interactive Dice Rolling: Users roll four virtual dice representing fundamental narrative elements: Place, Object, Trait, and Plot Twist.
  • Real-Time Generative Synthesis: The selected dice combinations are processed via Amazon Bedrock (using the Amazon Nova Micro model), generating a coherent, engaging 150–200 word flash fiction story in real time.
  • Persistent Storybook Gallery: Users can curate and save their favorite generated narratives to a persistent story library powered by Amazon DynamoDB, ready to be copied or referenced at any time.
Showcase Challenge Refinements: From Feedback to Production
The Weekend Showcase Challenge was the perfect opportunity to take Story Dice from a functional prototype to a polished, community-tested application.
When I initially published Story Dice for the Creative App challenge, AWS Community Builder Eduardo Lara provided insightful feedback on the narrative output: the temperature was tuned too high, which occasionally caused the AI to produce bizarre, disconnected hallucinations (like "maps redrawing themselves into shapes of dancing turtles").
Thanks to the Weekend Challenge structure, I had the dedicated time to refine these areas and implement high-impact improvements:
  1. AI Temperature Tuning & Prompt Grounding:
  • Reduced the Amazon Bedrock temperature parameter from  0.9  to  0.65 .
  • Restructured the system prompt to explicitly enforce narrative grounding, ensuring character choices and plot twists remain logically tethered to the rolled dice without losing their whimsical spark.
  1. One-Click Clipboard & Workflow Features:
  • Added direct 📋 Copy Story buttons to both the live generated story card and each entry in the Saved Stories library to make exporting stories into external writing tools effortless.
  1. Frontend 3D Visuals & Fluid Interactions:
  • Introduced 3D perspective animations and keyframe rolling effects to simulate real dice tumbling when users click roll or reroll.
  • Improved UI responsive states, smooth transitions, and error feedback handling.
  1. Backend Resilience & Zero-Cost Architecture:
  • Optimized the AWS Lambda  /generate  microservice to use the standard  invoke_model  API payload for Amazon Nova Micro, extending the execution timeout and memory configuration for dependable, sub-second responses.
AWS Services Used & Serverless Architecture
Story Dice runs entirely on a decoupled, 100% serverless architecture designed for zero idle operating cost and high responsiveness under the AWS Free Tier:
  • Amazon Bedrock ( amazon.nova-micro-v1:0 ): Powers the generative AI layer with low latency, predictable inference, and minimal token cost.
  • AWS Lambda (Python 3.12 / 3.11): Houses modular microservices ( /roll ,  /generate ,  /save ,  /stories ) executing logic independently.
  • Amazon API Gateway (HTTP API): Acts as the low-latency API proxy with configured Cross-Origin Resource Sharing (CORS) headers.
  • Amazon DynamoDB ( StoryDiceStories ): Serverless NoSQL table storing user-saved narratives with single-digit millisecond latency.
  • AWS Amplify Hosting: Manages Git-integrated continuous deployment and fast edge-hosted delivery of static frontend assets.
  • AWS SAM (Serverless Application Model): Manages the entire cloud backend infrastructure as repeatable, version-controlled Infrastructure as Code (IaC).
Key Backend Implementation ( backend/generate/handler.py )
import json
import boto3

bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')

def lambda_handler(event, context):
headers = {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type,Authorization",
"Access-Control-Allow-Methods": "OPTIONS,POST,GET"
}

if event.get("httpMethod") == "OPTIONS":
return {"statusCode": 200, "headers": headers, "body": ""}

try:
body = json.loads(event.get('body', '{}') or '{}')
place = body.get('place', 'a candy-cane forest')
obj = body.get('object', 'a jar of fireflies')
trait = body.get('trait', 'never remembers their own name')
twist = body.get('twist', 'but every door leads back to yesterday')

system_prompt = (
"You are a master flash fiction author. Write an engaging, vivid, and grounded "
"150-200 word story incorporating the given setting, object, character trait, and plot twist. "
"Start directly with a bold title on line 1."
)

user_prompt = (
f"Write a flash fiction story using these story dice elements:\n"
f"- Setting: {place}\n"
f"- Object: {obj}\n"
f"- Character Trait: {trait}\n"
f"- Plot Twist: {twist}"
)

payload = {
"messages": [{"role": "user", "content": [{"text": user_prompt}]}],
"system": [{"text": system_prompt}],
"inferenceConfig": {
"temperature": 0.65,
"maxTokens": 450
}
}

response = bedrock.invoke_model(
modelId="amazon.nova-micro-v1:0",
contentType="application/json",
accept="application/json",
body=json.dumps(payload)
)

response_body = json.loads(response['body'].read().decode('utf-8'))
story_text = response_body['output']['message']['content'][0]['text']

return {
"statusCode": 200,
"headers": headers,
"body": json.dumps({"story": story_text})
}
except Exception as e:
return {
"statusCode": 500,
"headers": headers,
"body": json.dumps({"error": str(e)})
}

handler = lambda_handler

What I Learned Across the Summer Build Series
Participating in the summer build challenges provided invaluable practical experience:
  • Hyperparameter Calibration is Essential: Fine-tuning parameters like  temperature  and  maxTokens  is just as critical as prompt engineering. Aligning these settings based on community feedback turns an experimental build into a reliable product.
  • Cost-Efficient Serverless Generative AI: Pairing Amazon Nova Micro on Bedrock with AWS Lambda provides rapid, near-instantaneous inference while staying comfortably within AWS Free Tier thresholds.
  • Community-Driven Growth: The real power of the AWS Builder Series lies in community iteration. Engaging with other builders and incorporating feedback produces far better software than building in a silo.
Links & Acknowledgments
Special Thanks & Builder Shoutouts:
  • A huge thank you to Eduardo Lara for pointing out the temperature calibration issue on the original build and providing actionable feedback that shaped this final update.
  • Big shoutout to Lewis Sawe for the inspiring work on The Museum That Grows during the previous creative agent challenge!
  • Thank you to the AWS Builder Community team and Ben Fowler for hosting this Summer Build Series having these weekend challenges provided the perfect sandbox and motivation to build, refine, and ship!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article