Record weather from an API on a schedule.
Fetch current conditions in Madrid every 15 minutes. Store temperature and humidity with the source and observation time.
THE FLOW
From trigger to outcome.
A history of the conditions reported by one API at one location.
- 01 →
Schedule
Set interval to 15m, or choose another polling interval.
- 02 →
Collect
Read the time, temperature and relative humidity from the API response.
- 03 →
Store
Insert one row per metric under the source open-meteo:madrid.
USE THIS RECIPE
Your workflow,
in YAML.
- Create the shared weather_readings table using the setup guide.
- Set DATABASE_DSN to a PostgreSQL connection that can insert into the table.
- Choose the coordinates and use the Open-Meteo endpoint appropriate for your account.
Create the table and test the recipes →
Configure secret references →Copy or download the manifest, configure your values, and add it through Workflows or your AI workspace. Opening the console does not create or enable a workflow.
- Call APIs
- Parse requests
- Query databases
name: Poll Madrid weather
enabled: true
triggers:
- type: schedule
interval: 15m
steps:
- step_id: fetch
kind: http
command:
method: GET
url: "https://api.open-meteo.com/v1/forecast?latitude=40.42&longitude=-3.70¤t=temperature_2m,relative_humidity_2m&temperature_unit=celsius&timeformat=unixtime"
- step_id: reading
kind: request-parser
dependencies: [fetch]
command:
extract:
time: .steps.fetch.value.current.time
temp_c: .steps.fetch.value.current.temperature_2m
humidity_pct: .steps.fetch.value.current.relative_humidity_2m
- step_id: store
kind: sql
dependencies: [reading]
command:
driver: postgres
dsn: secret://DATABASE_DSN
write: true
query: |
WITH reading AS (
SELECT convert_from(decode('{{ printf "%x" .steps.reading.output }}', 'hex'), 'UTF8')::jsonb AS data
)
INSERT INTO weather_readings (source, observed_at, metric_type, metric_value, unit)
SELECT 'open-meteo:madrid', to_timestamp((data->'time')::double precision), metric_type, metric_value, unit
FROM reading
CROSS JOIN LATERAL (VALUES
('temperature', (data->'temp_c')::numeric, '°C'),
('relative_humidity', (data->'humidity_pct')::numeric, '%')
) AS metrics(metric_type, metric_value, unit)
ON CONFLICT (source, observed_at, metric_type) DO NOTHING
Setup Create the weather_readings table from the workflow docs and set DATABASE_DSN. Change the coordinates and source label together when polling another location.
EXPECTED RESULT
Know what to look for.
A new observation creates two rows, one in °C and one in percent.
The primary key keeps the first reading for each source, observation time and metric.
TEST YOUR SETUP
Check a complete run.
- Run once and compare the fetch output with the stored values.
- Check that the two rows share the time reported by Open-Meteo.
- Repeat with the same observation time. The store step should report zero new rows.
Adapt this recipe with your AI agent
Adapt this weather poll to my API fields, units and polling interval. Show the expected database rows before enabling the schedule.
KEEP CONNECTING
More workflow recipes.
Webhook processing
Receive an event, transform its payload, and hand it to the next service.
Explore →◷Scheduled reports
Count yesterday’s orders in PostgreSQL and email the total through SendGrid every 24 hours.
Explore →↳Write a webhook to PostgreSQL
Receive a station’s JSON over HTTPS and write its temperature and humidity to the same table as scheduled API readings.
Explore →✓Approval workflows
Have an agent prepare a product update, pause for a human decision, then send the approved result to your API.
Explore →