StructuredOutputCompletion icon
If icon
SlackIncomingWebhook icon
InsertEvent icon
Schedule icon

Decide When to Take Action Using AI, Check Real-Time Weather and Trigger Automations

Use Kestra and Google Gemini to turn a natural-language weather question into a structured go/no-go decision that notifies Slack and blocks your calendar.

Categories
AI

Turn a plain-English weather question into an automated decision. This blueprint asks Google Gemini for the current wind speed at a location, returns a structured JSON answer with a clear boolean recommendation, and then acts on that recommendation: it posts a Slack notification and blocks time on a Google Calendar when conditions are right. It solves the gap between AI reasoning and real action, where a model can answer a question but cannot reliably drive downstream systems on a schedule with retries and audit trails.

How it works

  1. The ask_ai task (io.kestra.plugin.gemini.StructuredOutputCompletion) sends a natural-language prompt to the gemini-2.5-flash-preview-05-20 model. A jsonResponseSchema forces the answer into a fixed shape with content (text), wind (number), and go_sailing (boolean), so downstream tasks get machine-readable fields instead of free text.
  2. The if task (io.kestra.plugin.core.flow.If) evaluates the model output by parsing go_sailing from the prediction with a jq expression, branching only when the decision is true.
  3. When the branch runs, notify_me (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) sends the model's content message to Slack.
  4. block_calendar (io.kestra.plugin.googleworkspace.calendar.InsertEvent) inserts an all-day event into a Google Calendar, embedding the live wind value in the event description.
  5. A disabled check_daily Schedule trigger (io.kestra.plugin.core.trigger.Schedule) shows how to run the whole check automatically on a cron each morning.

What you get

  • A structured, typed AI answer instead of fragile free-text parsing.
  • Conditional execution so actions fire only when criteria are met.
  • An automatic Slack heads-up and a calendar block in one run.
  • A ready cron pattern to run the decision unattended every day.

Who it's for

  • Builders prototyping AI-driven decision support and smart assistants.
  • Data and automation engineers wiring LLM output into real systems.
  • Anyone who wants context-aware personal or operational automations.

Why orchestrate this with Kestra

Gemini answers a single question, but it has no scheduler, no retry logic, and no way to chain notifications and calendar writes. Kestra adds event and Schedule triggers, automatic retries, full execution lineage and logs across the AI call and every downstream system, and a declarative YAML definition you can version and review. The conditional If branch keeps actions gated on the AI verdict, something a standalone model API cannot coordinate on its own.

Prerequisites

  • A Google Gemini API key with access to the chosen model.
  • A Slack incoming webhook URL.
  • A Google service account and a target Calendar ID.

Secrets

  • GEMINI_API_KEY: API key for the Gemini model call.
  • SLACK_WEBHOOK: incoming webhook URL for Slack notifications.
  • CALENDAR_ID: the target Google Calendar identifier.
  • GOOGLE_SA: Google service account JSON for Calendar access.

Quick start

  1. Add GEMINI_API_KEY, SLACK_WEBHOOK, CALENDAR_ID, and GOOGLE_SA as secrets.
  2. Edit the prompt to match your location and activity thresholds.
  3. Run the flow once and confirm the structured output and Slack message.
  4. Enable the check_daily trigger to run it automatically each morning.

How to extend

  • Swap sailing for any condition-based decision (running, cycling, field work).
  • Replace the calendar step with email, PagerDuty, or a database write.
  • Add inputs for location and thresholds to reuse the flow across users.
  • Branch on wind thresholds to send different messages per condition.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.