Skip to content

Daily Content Generation Pipeline

To run this pipeline you need:

  • Anthropic API key — for Claude Sonnet 4.6 (claude-sonnet-4-6), used to structure posts and extract event data
  • Perplexity API key — for Sonar web search
  • Higgsfield API key — for Nano Banana image generation
  • Google Cloud project with:
    • Vertex AI enabled (for text-embedding-004 embeddings)
    • Geocoding API enabled (every event must geocode to a real address or it’s rejected)
  • Firebase project with Cloud Functions and Firestore
  • Google Cloud Scheduler to trigger the daily generators (6 AM PST for posts, 7 AM PST for events) and the social poster (8 AM, 1 PM, 4 PM PT)
  • Facebook Page access token (FACEBOOK_PAGE_ACCESS_TOKEN) and Page ID (FACEBOOK_PAGE_ID) for posting to the Facebook page
  • Instagram Business account ID (INSTAGRAM_BUSINESS_ACCOUNT_ID) — linked to the same Facebook page, so the same Page access token authorizes both

ParentConnect needs a constant stream of fresh, locally relevant content across three cities — Las Vegas, Salt Lake City, and Los Angeles. Manually sourcing and writing this is not scalable. Two types of content are needed daily: structured events (with date, time, venue, and address) and freeform community posts (local news, safety recalls, new businesses, family programs).

Can a pipeline discover real content from the web, write it in the right voice, generate an appropriate image, and publish it — with no human involvement?

Two separate scheduled Cloud Functions run each morning, one for posts and one for events.

Daily Post Generation Pipeline

Posts pipeline — runs at 6 AM PST

Each run searches 3 of 6 rotating categories (playgrounds, family businesses, school news, safety recalls, programs, community development) across all three cities using Perplexity. The search results go to Claude Sonnet, which structures them into typed posts — announcement, offer, ask, or question — with a title, body written in a warm community voice, and an image prompt. A word-overlap deduplication check (14-day window, 0.6 threshold) filters anything too similar to recent posts. Higgsfield Nano Banana generates the image, and the post is saved to Firestore.

Daily Event Generation Pipeline

Events pipeline — runs at 7 AM PST

Events require more structure. Perplexity searches for upcoming family-friendly events per city, and the pipeline also scrapes curated local sources (e.g. vegaskidszone.com). Each candidate event URL is fetched, the HTML is stripped down to readable content, and Claude extracts structured data using a Zod schema:

title, description, type, tags,
startDate, startTime, endDate, endTime,
street, city, state, zip, imagePrompt

Every event must pass a Google Geocoding validation — if no real street address can be found and geocoded, the event is rejected. Vertex AI then generates a 768-dimension embedding for the event, and cosine similarity deduplication (30-day window, 0.75 threshold) runs against both pending and already-approved events. Images are extracted from the source page (og:image first, validated for minimum size and quality) with Higgsfield as a fallback. Approved events land in events_generated for human review.

Social distribution — runs at 8 AM, 1 PM, 4 PM PT

A separate scheduled function (autoPostToSocialMedia, cron 0 8,13,16 * * *) pushes generated content to Facebook and Instagram three times a day.

Selection per run:

  • Events — future events ordered ascending by startDate, takes the next auto_post_event_limit (default 3) that don’t already have a facebookPostId
  • Posts — posts created in the last 24 hours ordered descending, takes the next auto_post_post_limit (default 2) without a facebookPostId

Each item is posted to two platforms:

  1. Facebook — a caption is built from the structured doc, images are pulled from Cloud Storage (using imageFolder for events, imageUrls for posts), and the post is sent to the Page via Graph API v21. The Firestore doc is stamped with facebookPostId, facebookPostedAt, and facebookPostedBy: "automated".
  2. Instagram — only runs if the item has at least one image (IG requires images). Uses Instagram’s three-step Graph API flow: create a media container, then publish it. The doc is stamped with instagramPostId, instagramPostedAt, and instagramPostedBy: "automated".

Authentication uses three secrets: FACEBOOK_PAGE_ACCESS_TOKEN, FACEBOOK_PAGE_ID, and INSTAGRAM_BUSINESS_ACCOUNT_ID. Because the Instagram account is linked to the Facebook page, a single Page access token authorizes both platforms.

A kill switch at app_config/main.enable_auto_social_posting = false disables the whole social poster without redeploying. The platform-ID stamps mean items are never re-posted on the next run.

  • Both pipelines run daily, fully unattended
  • Posts publish directly to the app with zero human involvement
  • Events are discovered from the open web, geocoded, embedded, deduplicated, and queued each morning — ready for a quick human review before going live
  • Image generation is context-aware: Claude outputs two styles of image prompt — product-style (clean, neutral background) for recalls and specific items, scene-style (warm, photorealistic, families) for parks and activities
  • Generated posts and events are auto-distributed to Facebook and Instagram three times a day, with platform IDs stamped back on the Firestore docs so nothing is ever re-posted