Public
Daily social feed ingest and summaries.
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Daily Feed Orchestrator

Receives Twitter/X, Reddit, and LinkedIn-style feed payloads through a webhook, stores normalized feed items in Val-scoped SQLite, then runs a daily AI summarization and email workflow using Val Town's standard OpenAI integration.

Webhook

webhookIngest.ts accepts POST requests with JSON.

Batch payload shape:

{ "feeds": [ { "platform": "twitter", "fetchedAt": "2026-06-18T16:00:00.000Z", "items": [ { "externalId": "tweet-123", "title": "Short headline", "body": "Full post text or extracted body", "url": "https://example.com/item", "author": "@author", "publishedAt": "2026-06-18T15:30:00.000Z" } ] } ] }

A single feed object with platform and items is also accepted. Supported platforms are twitter, reddit, and linkedin.

Optional security: set WEBHOOK_SECRET. When configured, callers must send either Authorization: Bearer <secret> or x-webhook-secret: <secret>.

Add WEBHOOK_SECRET here: https://www.val.town/x/michaelkronovet_libretto/daily-feed-orchestrator/environment-variables?key=WEBHOOK_SECRET

AI and Email

  • AI summaries use https://esm.town/v/std/openai with gpt-4o-mini; no OPENAI_API_KEY is required.
  • Email delivery uses https://esm.town/v/std/email.
  • If SUMMARY_EMAIL_TO is not set, email is sent to the Val owner by default.

Add SUMMARY_EMAIL_TO here if you want a specific recipient: https://www.val.town/x/michaelkronovet_libretto/daily-feed-orchestrator/environment-variables?key=SUMMARY_EMAIL_TO

Schedule

  • summarizeDaily.ts: daily at 16:30 UTC

Val Town cron expressions run in UTC.

Files

  • webhookIngest.ts: public HTTP webhook listener for feed payloads.
  • webhookWorkflow.ts: validates and normalizes webhook payloads, then persists them.
  • summarizeWorkflow.ts: summarizes the latest completed ingest run that has not already been summarized.
  • db.ts: owns the SQLite schema and queries.
  • types.ts: shared TypeScript types.
  • feedClients.ts and ingestDaily.ts: mock/reference ingest code, no longer scheduled.

Tables

  • feed_runs: one row per webhook ingest workflow execution.
  • feed_items: normalized feed records keyed by (platform, external_id) for idempotent upserts.
  • feed_summaries: one summary per completed run.