AIAgent icon
GoogleGemini icon
KestraFlow icon
Return icon

Trigger the Right Automation with an AI Agent Based on User Intent

Use a Kestra AI agent with Google Gemini to read user intent and trigger the right flow, returning a direct execution URL. No hardcoded routing logic.

Categories
AI

Route a user's stated intent to the correct automation without writing a single branching condition. This blueprint uses a Kestra AI agent, backed by Google Gemini, to read a high-level use case (business automation, data engineering, analytics, infrastructure, and more) and call the matching flow on your behalf. It is a practical pattern for AI-driven orchestration, self-service automation, internal developer portals, and agentic systems where users should not have to know which workflow to run.

How it works

  1. A SELECT input named use_case lets the user pick their orchestration goal from options such as Business Automation, Data Engineering Pipeline, and Infrastructure Automation (default Just Exploring).
  2. The agent task (io.kestra.plugin.ai.agent.AIAgent) receives a prompt that maps each use case to a target flow id in the tutorial namespace, with the io.kestra.plugin.ai.provider.GoogleGemini provider running gemini-2.5-flash.
  3. The agent is granted the io.kestra.plugin.ai.tool.KestraFlow tool, so it can actually execute the chosen flow rather than just describe it.
  4. The uri task (io.kestra.plugin.core.debug.Return) parses the agent's toolExecutions output and builds a direct execution URL from the returned tenantId, flowId, and execution id.

What you get

  • Intent-based routing with no hardcoded if/switch logic to maintain.
  • Real tool-calling: the agent triggers a downstream Kestra execution programmatically.
  • A ready-to-open execution URL pointing straight at the launched run.
  • A reusable template for adding new use cases by editing one prompt mapping.

Who it's for

  • Platform engineers building self-service automation catalogs.
  • Teams creating internal developer portals where users describe goals, not flow names.
  • Anyone prototyping agentic orchestration patterns on Kestra.

Why orchestrate this with Kestra

Kestra turns the agent's decision into a governed, observable execution. You get event and schedule triggers, automatic retries, full execution lineage across the agent call and the flow it launches, and everything defined in declarative YAML you can version control. An LLM API on its own has no scheduler, no durable execution history, and no way to launch and track other workflows. Kestra supplies the orchestration layer the model lacks.

Prerequisites

  • A Google Gemini API key with access to gemini-2.5-flash.
  • The target flows present in the tutorial namespace (for example business-automation, data-engineering-pipeline, hello-world).

Secrets

  • GEMINI_API_KEY: API key used by the GoogleGemini provider.

Quick start

  1. Add the GEMINI_API_KEY secret to your Kestra instance.
  2. Ensure the referenced flows exist in the tutorial namespace.
  3. Add this blueprint to your namespace.
  4. Execute the flow and select a use_case.
  5. Open the URL returned by the uri task to inspect the launched execution.

How to extend

  • Swap GoogleGemini for another io.kestra.plugin.ai.provider such as OpenAI or Anthropic.
  • Expand the prompt mapping to cover more use cases or additional namespaces.
  • Add more agent tools so it can query data or call APIs before deciding which flow to run.
  • Pass dynamic inputs to the launched flow based on the user's request.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.