hackernews-top10-workersai-browserrendering-email
hackernews-top10-workersai-browserrendering-email copied to clipboard
This Cloudflare Worker emails me an analysis/summary of the top 10 Hacker News stories every hour using Cloudflare Email, Workers AI, AI Gateway, and Browser Rendering. On this page, you can select a...
Hacker News Top 10 Stories with AI Analysis w/ Hourly Email Summaries
This is a Cloudflare Worker that scrapes the top 10 stories from Hacker News using Browser Rendering, analyzes/summarizes them using Cloudflare Workers AI, displays that according to tone users select via button click, and sends the results via Cloudflare Email Routing every hour (using Cloudflare Cron Triggers).
Features
Scrapes Top 10 Hacker News Stories: Uses Cloudflare's Browser Rendering API to fetch the latest top stories from Hacker News.
AI-Powered Analysis: Generates summaries of the stories using Cloudflare Workers AI with customizable tones (e.g., Ted Lasso or Stephen A. Smith).
Email Delivery: Sends the top stories and AI-generated summaries via Cloudflare Email.
Interactive Web Interface: Provides a web interface to view the top stories and generate AI summaries in different tones.
Setup
Prerequisites
-
Cloudflare Account: Create one today for free: https://dash.cloudflare.com/sign-up
-
Wrangler CLI: Install and authenticate:
npm install -g wrangler
wrangler login
- Clone the repo and install dependencies:
git clone https://github.com/elizabethsiegle/marchmadness-prediction-analysis-worker
cd marchmadness-prediction-analysis-worker
npm install
-
Cloudflare Email Setup: Configure your domain for Cloudflare Email and set up the necessary bindings.
-
Add the following bindings to your wrangler.jsonc file to interact with your Worker:
"triggers":
{
"crons": ["46 * * * *"]
}, // Edit how often you wish the email to send. This runs every hour at the 46th minute
"send_email": [ //email binding to send the email
{
"name": "SEB"
}
],
"browser": { // browser rendering binding to scrape Hacker News
"binding": "MYBROWSER"
},
"ai": { // AI binding to analyze and summarize the stories with Workers AI
"binding": "AI"
},
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [
{
"name": "BROWSERDO",
"class_name": "BrowserDo"
}
]
},
"migrations": [
{
"tag": "v1",
"new_classes": [
"BrowserDo"
]
}
]
- Deploy the Worker:
npx wrangler deploy
or run locally with npm run dev --remote