Source
yaml
id: ai-check-weather-gemini
namespace: company.team
tasks:
- id: ask_ai
type: io.kestra.plugin.gemini.StructuredOutputCompletion
apiKey: "{{ kv('GEMINI_API_KEY') }}"
model: "gemini-2.5-flash-preview-05-20"
prompt: "I like to go sailing when the wind is above 10 knots but below 30
knots. I sail in Cambridgeshire. If the wind is within that range, I want
to know if I should go sailing or not. Also tell me the current wind speed
speeds"
jsonResponseSchema: |
{
"type": "object",
"properties": {
"content": {
"type": "string"
},
"wind": {
"type": "number"
},
"go_sailing": {
"type": "boolean"
}
}
}
}
- id: if
type: io.kestra.plugin.core.flow.If
condition: "{{ outputs.ask_ai['predictions'] | first | jq('.go_sailing') | first }}"
then:
- id: notify_me
type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
url: "{{ kv('SLACK_WEBHOOK') }}"
payload: |
{
"text": "{{ outputs.ask_ai['predictions'] | first | jq('.content') | first }}"
}
- id: block_calendar
type: io.kestra.plugin.googleworkspace.calendar.InsertEvent
calendarId: "{{ kv('CALENDAR_ID') }}"
serviceAccount: "{{ kv('GOOGLE_SA') }}"
summary: Out of office
description: "Gone sailing because the wind is {{ outputs.ask_ai['predictions']
| first | jq('.wind') | first }} knots"
startTime:
dateTime: "{{ now() | date(\"yyyy-MM-dd'T'09:00:00+01:00\") }}"
timeZone: "Europe/London"
endTime:
dateTime: "{{ now() | date(\"yyyy-MM-dd'T'18:00:00+01:00\") }}"
timeZone: "Europe/London"
creator:
email: [email protected]
triggers:
- id: check_daily
type: io.kestra.plugin.core.trigger.Schedule
cron: "* 8 * * *"
About this blueprint
Getting Started Notifications AI Kestra
This flow runs daily to check real-time weather conditions for any location and automatically execute follow-up actions. It utilizes Gemini's Structured Output combined with its internal Google Search capabilities to:
- Fetch Real-time Data: Gemini interprets a natural language request (e.g., "What is the wind speed in Cambridgeshire?") and internally fetches the current conditions.
- Structured Output: The model returns a structured JSON object containing the weather data and a clean boolean decision (e.g.,
go_sailing
), adhering to a defined schema. - Conditional Workflow: The flow uses the Kestra If task to execute subsequent steps only if the structured condition is met.
Configuration:
- Provide a key-value pair for the Gemini API key (
GEMINI_API_KEY
). - Configure email credentials (
EMAIL_USERNAME
,EMAIL_PASSWORD
) for SMTP delivery. - Optionally adjust the AI prompt to change the sport and location criteria.
This blueprint is ideal for any automation that requires external data combined with structured, AI-driven logic to control workflow branches based on real-time conditions.