💻 Technology 10 min read

Building AI-Powered Content Pipelines with Supabase and Edge Functions

Automating Content at Scale

What if your blog could generate draft content, queue it for review, and publish on schedule — all automatically? With Supabase Edge Functions and modern AI APIs, this is not just possible, it is surprisingly straightforward.

The Architecture

Our pipeline has four stages:

Source → Generate → Review Queue → Publish

Each stage is handled by a Supabase Edge Function triggered on a schedule or by database changes.

Stage 1: Content Sourcing

Edge Function runs on a cron schedule to find trending topics:

Deno.serve(async () => {
  const trends = await fetchTrendingTopics("technology");
  
  for (const topic of trends) {
    await supabase.from("content_queue").insert({
      title: topic.title,
      metadata: { keywords: topic.keywords, source: topic.url },
      source_type: "scrape",
      status: "pending"
    });
  }
  
  return new Response("OK");
});

Stage 2: AI Generation

A database webhook triggers when new items enter the queue:

const { data: item } = await supabase
  .from("content_queue")
  .update({ status: "processing" })
  .eq("id", queueId)
  .select()
  .single();

const article = await generateArticle(item.title, item.metadata);

await supabase.from("content_queue").update({
  content: article,
  status: "ready"
}).eq("id", queueId);

Stage 3: Review Queue

Ready items appear in your admin panel for human review. You can approve, edit, or reject.

Stage 4: Scheduled Publishing

A cron function checks for approved items whose target_publish_at has passed:

const { data: ready } = await supabase
  .from("content_queue")
  .select()
  .eq("status", "ready")
  .lte("target_publish_at", new Date().toISOString());

for (const item of ready) {
  await createAndPublishPost(item);
}

Key Lessons

  1. Always have a human in the loop — AI-generated content needs review
  2. Track provenance — The source field on posts lets you audit what was AI-generated
  3. Rate limit everything — AI APIs have costs, so build in circuit breakers
  4. Monitor quality — Set up alerts for posts with low engagement

This pipeline can reduce your content creation time by 80% while maintaining quality through human oversight.



More from Technology