Request icon
ForEach icon
Script icon
ChatCompletion icon
SlackIncomingWebhook icon
Schedule icon

Extract, Transform, and Store HackerNews Top Stories with AI-Generated Daily Digest

Fetch HackerNews top stories with Kestra, store them in PostgreSQL, generate an AI trend digest with GPT-4o-mini, and post a daily briefing to Slack.

Categories
AIBusinessData

Build a daily tech intelligence pipeline that pulls trending HackerNews stories, lands them in a PostgreSQL table for historical analysis, and broadcasts an AI-generated digest to your team. This blueprint solves the problem of turning a noisy public feed into a clean, deduplicated, queryable PostgreSQL dataset plus a human-readable summary, all on an automated daily schedule with no manual collection or copy-paste.

How it works

  1. The daily_digest trigger (io.kestra.plugin.core.trigger.Schedule, cron 0 8 * * *) starts the flow every morning at 08:00 UTC.
  2. fetch_story_ids (io.kestra.plugin.core.http.Request) calls the HackerNews Firebase API for the selected feed (topstories, newstories, or beststories).
  3. fetch_stories (io.kestra.plugin.core.flow.ForEach) fans out across the top N story IDs with a concurrencyLimit of 5, fetching each story detail in parallel via a nested io.kestra.plugin.core.http.Request.
  4. summarize_stories (io.kestra.plugin.scripts.python.Script) parses and normalizes the raw Firebase responses, extracting id, title, url, score, author, comments, type, and timestamp, then sorts by score.
  5. summarize_with_ai (io.kestra.plugin.openai.ChatCompletion) sends the story list to gpt-4o-mini to write a concise 3 to 5 bullet trend digest.
  6. store_to_postgres (io.kestra.plugin.scripts.python.Script) upserts every story into a hackernews_stories table using INSERT ... ON CONFLICT DO UPDATE, keeping a clean historical archive.
  7. post_digest_to_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts the AI digest and story count to a Slack channel.

What you get

  • A deduplicated, ever-growing PostgreSQL table of HackerNews stories you can query and join.
  • A daily AI-written digest of the dominant tech themes, delivered to Slack.
  • Parallel, rate-friendly fetching of story details via ForEach with bounded concurrency.
  • Configurable feed type and story count through flow inputs.

Who it's for

  • Data engineers who want a worked ETL example landing in PostgreSQL.
  • Engineering teams tracking emerging tools, libraries, and security topics.
  • Analysts and investors monitoring technology momentum over time.
  • Tech newsletter and content authors who need a daily grounded briefing.

Why orchestrate this with Kestra

PostgreSQL has no built-in scheduler, retrieval, or alerting: it stores rows, nothing more. Kestra supplies the scheduled trigger, parallel HTTP retrieval, Python transformation, AI enrichment, and Slack delivery around the database, with retries, full execution lineage, and a declarative YAML definition you can version control. Event and schedule triggers, per-task observability, and replay close the orchestration gap that the database itself cannot fill.

Prerequisites

  • A running PostgreSQL instance reachable from your Kestra workers.
  • An OpenAI API key with access to gpt-4o-mini.
  • A Slack incoming webhook URL.

Secrets

  • OPENAI_API_KEY
  • POSTGRES_HOST
  • POSTGRES_DB
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • SLACK_WEBHOOK_URL

Quick start

  1. Add the six secrets above to your Kestra instance.
  2. Create the flow from this blueprint.
  3. Adjust the story_type and max_stories inputs if needed.
  4. Execute manually once to verify the PostgreSQL table and Slack post.
  5. Leave the daily schedule enabled to run automatically at 08:00 UTC.

How to extend

  • Filter stories by keyword before storing or summarizing.
  • Add sentiment scoring or per-story tagging in the Python step.
  • Track score trends over time for ranking analysis with SQL queries.
  • Scrape full article bodies to feed a deeper AI summary.
  • Fan out the digest to Notion, email, or other channels.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.