Log icon
Request icon
Script icon
Parallel icon
AIAgent icon
Webhook icon
SlackIncomingWebhook icon
GoogleGemini icon

AI Day Planner from Weather and Air Quality APIs

Webhook-triggered pipeline that geocodes a city, calls weather and air quality APIs in parallel, and asks a Gemini AI agent for a short daily plan.

Categories
AI

A compact, end-to-end pattern for AI-assisted API orchestration. This Kestra blueprint takes a city name, resolves it to coordinates with the Open-Meteo geocoding API, fans out to the weather and air quality APIs in parallel, and hands the raw JSON to an AI agent that writes a 3 to 5 sentence plan for the day, including cautions such as high PM2.5 or strong wind. It demonstrates the operational scaffolding real AI pipelines need: per-task retries, graceful degradation when one API fails, an execution SLA, a failure alert to Slack, and a typed flow output that downstream flows or callers can consume.

How it works

  1. The incoming_webhook trigger (io.kestra.plugin.core.trigger.Webhook) lets any HTTP caller request a plan on demand, secured by PLAN_MY_DAY_WEBHOOK_KEY. The flow also runs manually with the city input, defaulting to Austin.
  2. The geocode_city task (io.kestra.plugin.core.http.Request) resolves the city name, and parse_geo (io.kestra.plugin.scripts.python.Script) extracts latitude and longitude, failing fast with a clear error when the city is unknown.
  3. The parallel_tasks task (io.kestra.plugin.core.flow.Parallel) calls weather_api and air_quality_api concurrently. Both requests inherit retry and header policy from pluginDefaults and are allowed to fail individually.
  4. The day_brief task (io.kestra.plugin.ai.agent.AIAgent) prompts gemini-3.5-flash-lite with both response bodies, substituting "not available!" for any missing data so the agent still produces a useful plan on partial failures.
  5. log_output records the answer, the flow exposes it as the brief output, the errors branch posts to Slack on failure, and a MAX_DURATION SLA cancels runs over 10 minutes.

What you get

  • A working webhook-to-AI pipeline in about 100 lines of declarative YAML.
  • Parallel API fan-out with retries and partial-failure tolerance baked in.
  • A reusable pattern: geocode, enrich in parallel, summarize with an agent, alert on failure.
  • A typed brief flow output that subflows, apps, or API callers can consume directly.

Who it's for

  • Teams learning how to combine HTTP orchestration with the Kestra AI agent.
  • Developers building personal assistant or notification products on public APIs.
  • Solutions engineers who need a small but production-shaped AI demo.

Why orchestrate this with Kestra

The interesting part of this flow is not any single API call, it is the failure handling between them. Kestra provides Parallel for concurrent enrichment, pluginDefaults to declare retry and header policy once for every HTTP request, allowFailure for graceful degradation, an errors branch for alerting, and SLA enforcement, all without a line of orchestration code. The AIAgent task turns the LLM call into an observable task with logged requests, so you can see exactly what the model was given when a plan looks off.

Prerequisites

  • A Google AI Studio API key with access to Gemini models.
  • A Slack incoming webhook URL for failure alerts.
  • No API keys are needed for the Open-Meteo geocoding, weather, and air quality endpoints.

Secrets

  • GEMINI_API_KEY: Google Gemini API key used by the AIAgent task.
  • SLACK_WEBHOOK: Slack incoming webhook URL for the failure alert.
  • PLAN_MY_DAY_WEBHOOK_KEY: shared secret guarding the Webhook trigger.

Quick start

  1. Add the secrets above to your Kestra namespace.
  2. Run the flow manually with the default city and read the plan in the logs.
  3. POST to the webhook URL with the configured key to trigger it from any client.
  4. Change the city default or pass it in the webhook payload to plan for other locations.

How to extend

  • Add a Schedule trigger to deliver the plan every morning instead of on demand.
  • Post the brief to Slack, email, or Telegram with the corresponding notification task.
  • Add more parallel sources such as calendar events or commute times before the agent call.
  • Return structured JSON from the agent with responseFormat and branch on fields like a rain flag.
  • Cache geocoding results in the KV store to skip repeat lookups for the same city.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.