New to Kestra?
Use blueprints to kickstart your first workflows.
Kestra flow that adapts a Gemini prompt to a user-selected priority using Pebble conditionals and returns a JSON-schema-enforced recommendation from SWAPI data.
A playful dataset, a very reusable pattern. This Kestra blueprint fetches the starship catalog from the public Star Wars API and asks a Gemini-powered AI agent to recommend the best ship for a long-range mission. The twist is that the prompt itself is dynamic: Pebble {% if %} conditionals rewrite the prioritization criteria depending on whether the user selected Cargo Capacity, Speed, or Cost Efficiency from a SELECT input. The answer is forced into a JSON schema with name, justification, potentialDownside, and url, cached with taskCache, persisted to the KV store, and logged in a readable summary. Swap starships for vendors, SKUs, cloud instance types, or job candidates and the exact same skeleton applies.
priority input (SELECT) offers three optimization goals, defaulting to Speed.get_starships task (io.kestra.plugin.core.http.Request) pulls the starship list from swapi.dev with JSON content type. No API key is required.recommend_best_starship task (io.kestra.plugin.ai.agent.AIAgent) builds its prompt with Pebble {% if %} / {% elseif %} blocks so the model receives criteria tailored to the chosen priority, for example lower hyperdrive rating and higher MGLT when Speed is selected. responseFormat: JSON with a required-fields jsonSchema guarantees a parseable answer, and taskCache reuses the response for identical inputs.save_recommendation task (io.kestra.plugin.core.kv.Set) stores the structured JSON under the execution id with kvType: JSON.log_recommendation task (io.kestra.plugin.core.log.Log) renders name, justification, downside, and source URL straight from jsonOutput fields.taskCache.Conditional prompt construction usually means string concatenation in application code. Kestra moves it into the declarative layer: Pebble conditionals live next to the prompt they modify, inputs render as a real form in the UI, and the AIAgent task validates the model's answer against a JSON schema before any downstream task runs. Combined with task caching, secret management for the API key, and full execution logs of the rendered prompt, you get an auditable, repeatable recommendation service instead of a notebook experiment.
GEMINI_API_KEY: Google Gemini API key used by the AIAgent task.GEMINI_API_KEY secret to your Kestra namespace.AIAgent task that critiques the first recommendation for a two-step review.