Request icon
ForEach icon
StructuredOutputCompletion icon
DiscordIncomingWebhook icon
Schedule icon

Batch-Moderate Customer Reviews with Gemini at Controlled Throughput

Fan out a nightly review queue to Gemini for toxicity and spam classification, cap concurrency, write back verdicts, and post one completion notification.

Categories
AI

A queue of unmoderated reviews needs a verdict on every item, not just the first hundred before a rate limit hits. This blueprint pulls the pending review queue, fans out to Gemini for a per-item toxicity and spam classification under a concurrency cap, writes each verdict back to the source system, and posts a single completion notification instead of one message per review. It solves the throughput problem of batch LLM classification: getting through the whole queue without hammering the provider or losing track of which items were already handled.

How it works

  1. fetch_pending_reviews (io.kestra.plugin.core.http.Request) pulls up to 200 pending reviews from the moderation queue API.
  2. moderate (io.kestra.plugin.core.flow.ForEach) iterates the returned reviews with concurrencyLimit: 5, so at most five reviews are classified at once regardless of queue size.
  3. Inside each iteration, classify_review (io.kestra.plugin.gemini.StructuredOutputCompletion) asks gemini-3.5-flash-lite for a verdict (approve, flag, or reject) plus a reason, constrained by a jsonResponseSchema.
  4. write_back (io.kestra.plugin.core.http.Request) posts the verdict to the review's own record in the source system, so the queue does not re-offer already-moderated items on the next run.
  5. notify_batch_complete (io.kestra.plugin.discord.DiscordIncomingWebhook) posts one message when the whole batch finishes.
  6. A disabled nightly_moderation Schedule trigger (io.kestra.plugin.core.trigger.Schedule) shows the cron pattern for running the batch unattended every night.

What you get

  • Typed moderation verdicts instead of free-text model output that needs manual parsing.
  • A concurrency cap that keeps the batch under Gemini's rate limits no matter how large the queue grows.
  • Per-item write-back, so a failed run can resume without re-classifying already-handled reviews.
  • One Discord message per batch instead of notification noise per item.

Who it's for

  • Trust and safety, community, and content teams moderating reviews, comments, or user-generated content at volume.
  • Data and platform engineers who need a governed alternative to an unbounded loop over a moderation API.
  • Teams replacing a hand-rolled cron script that has no concurrency control or resume logic.

Why orchestrate this with Kestra

Gemini can classify one review at a time, but it has no queue, no concurrency limiter, and no way to track which items were already written back. Kestra's ForEach with concurrencyLimit throttles the fan-out declaratively, execution history shows exactly which reviews got which verdict, and a failed run can be retried without reprocessing the whole queue from scratch. That bookkeeping is what turns a batch LLM script into an operable pipeline.

Prerequisites

  • A Google Gemini API key.
  • A moderation queue API exposing pending reviews and accepting a verdict write-back.
  • A Discord incoming webhook for the completion notice.

Secrets

  • GEMINI_API_KEY: API key for the classification calls.
  • DISCORD_WEBHOOK: incoming webhook URL for the batch completion message.

Quick start

  1. Add the secrets above to your Kestra namespace.
  2. Point fetch_pending_reviews and write_back at your own moderation queue API.
  3. Run the flow manually against a small batch and confirm the verdicts and write-backs.
  4. Enable the nightly_moderation trigger to run the batch automatically every night.

How to extend

  • Add an automated If guardrail that pages the team when the reject rate crosses a threshold, instead of relying on a human to notice.
  • Raise or lower concurrencyLimit to match your Gemini quota and queue size.
  • Swap the moderation prompt for a different classification task: language detection, PII flagging, or category tagging.
  • Replace the Discord notification with Slack, Microsoft Teams, or email depending on the team's tooling.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.