AWS Builder Center
Weekend Creative Agent Challenge: The Newspaper Herald

Weekend Creative Agent Challenge: The Newspaper Herald

A vintage front page that writes by itself, once a day. An unattended agent assembles a new headline and files it away, so the paper is always waiting for you, never generated on the spot.

Cloud Enthusiast
Vision and What the App Does This week's challenge asks for a tool you do not need to manually operate that makes something new and simply has it ready automatically. The Newspaper Herald is something different that matches the prompt. It has a frontend that regenerates on its own, styled like a newspaper. Each day, on a schedule, the app assembles news headlines and files them as the edition for that day. So visiting the site after that leaves one to read what the agent has already written for the day. The user interface has no generate button. The site displays the paper.
How You Built It The app runs without any clicks and has a place to hold the output between runs. Amazon EventBridge Scheduler fires a Lambda function once daily. The Lambda then does one of two things depending on how it was invoked: if EventBridge triggered it directly, it runs a headline and writes it to DynamoDB for storage; if a browser triggered it through the function URL, it reads whatever was written in DynamoDB. One Lambda function, two responsibilities, split evenly depending on the presence of "event.requestContext.http". The DynamoDB table setup went through one revision: the first version had a latest record which would be overwritten daily, which is functionally fine, but meant the previous edition was removed the moment a new one was written. It was fixed by writing two items per run: a permanent archival record with the actual date, and a separate latest record that the frontend points to for a fast fetch.
AWS Services Used The four distinct services used in building the app include: Amazon EventBridge Scheduler: the unattended agent that fires the generation process. AWS Lambda: contains the zipped node app that holds both the read and write logics that are triggered by the scheduler and the request from the frontend function URL. Amazon DynamoDB stores every edition and has a pointer to the current one. AWS Amplify houses the static index.html, newspaper-style frontend app.
Architecture Overview The architecture diagram maps out the AWS services used in the building of the app. The flow branches at Lambda. An EventBridge Scheduler that runs based on CRON invokes a Lambda function, which hits DynamoDB to generate two writes: a dated archive and a latest pointer, and the browser, displaying the deployed app on Amplify, which hits the Lambda function URL to generate a read from DynamoDB latest to display on the app. The two paths share the same Lambda function but never run in the same invocation.
AWS Services Used

Screenshots of the App
DynamoDB Table Newspaper

AWS Lambda

AWS EventBridge

Amplify has app

Amplify App

Filled DynamoDB Table

What You Learned The clearest lesson was making it autonomous. The second lesson was splitting the Lambda into a write path and a read path, drive by two completely different triggers. The third lesson was modelling the data obtained for a time-based content. The simple single record was overwritten
Link to App or Repo The code contains index.html, package.json, index.mjs files and can be found here  https://github.com/KathleenCode/nehl 
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