Weather API Integration
WEATHER and FORECAST are BASIC keywords in botbasic_comms that call the OpenWeatherMap HTTP API and return typed weather data to a script.

When to use
- A bot must answer a question about current conditions or a short forecast.
- An operator needs to check why a weather call times out or reports "not configured".
- A scheduled report needs weather data alongside other BASIC operations.
Before you start
| Check |
Requirement |
| API key |
Set weather-api-key in the bot configuration; the keyword reports a configuration error when it is absent. |
| Provider |
OpenWeatherMap; the keyword builds https://api.openweathermap.org/data/2.5/... with units=metric. |
| Authority |
botserver/crates/botbasic_comms/src/keywords/weather.rs. |
| Ports |
API 8080, suite 3000, cloud 4000, login 5000 (root AGENTS.md). |
Steps
- Obtain a key from the OpenWeatherMap API and store it as
weather-api-key in the bot configuration, not in a committed file.
- Use
WEATHER <location> for current conditions. The keyword evaluates the location expression, calls the current-weather endpoint and returns a WeatherData value.
- Use
FORECAST <location>, <days> for a forecast. When the day count cannot be read as an integer, the keyword defaults to 5 days.
- Combine the result with other keywords where useful: GET for other data, SEND MAIL or SMS for delivery, and SET SCHEDULE for a daily report. See also USE TOOL.
w = WEATHER "São Paulo"
TALK w.description + ", " + w.temperature + " C"
f = FORECAST "São Paulo", 3
FOR EACH day IN f.forecast
TALK day.date + ": " + day.description
NEXT
Verify
| Check |
Expected result |
| Configured key |
A call returns data; no key value appears in the answer or the log. |
| Current weather |
WeatherData carries location, temperature, temperature_unit, description, humidity, wind_speed, wind_direction, feels_like, pressure, visibility and an optional uv_index. |
| Forecast |
Each ForecastDay carries date, temp_high, temp_low, description and rain_chance. |
| Timeout |
A call that takes longer than 10 seconds fails with a runtime error rather than blocking the session. |
| Missing key |
The error names weather-api-key as the configuration to set. |
Roll back
- Remove or rotate the
weather-api-key value. The keyword will report the missing configuration rather than calling the provider with a stale key.
- Remove the scheduled job or script that consumed the data if it is no longer wanted.
- Re-run the Verify table. No weather value or key is retained in documentation.