Engineering case study
SkyBrief: a Weather and Air-Quality Telegram Bot
Personal project
Runs serverless within a free plan, with a backup weather source and around 250 automated tests.
A Telegram bot that sends a morning weather and air-quality report at the time you choose, in your city's local time, and answers on demand. It covers hourly and weekly forecasts, rain and air-quality alerts, and official MetMalaysia warnings, in English, Malay and Chinese.
The problem
Checking the weather, the haze level and any official warning each morning means opening several apps. SkyBrief puts them in one message that arrives before you leave home, in the chat app you already have open.
My contribution
Designed and built solo, including a full rewrite from a single-user Python script into a multi-user serverless bot.
How it works
The bot runs on Cloudflare Workers with a D1 database and calls the Telegram Bot API directly, with no bot library and no runtime dependencies.
Telegram delivers messages by webhook; the Worker answers at once and finishes the work in the background. A scheduled job runs every minute and sends each user's report when their own local time reaches the time they chose. A claim in the database stops a report being sent twice, and a two-hour catch-up window covers outages.
Weather and place search come from Open-Meteo. Air quality comes from the nearest measuring station when one is within 40 km and under three hours old, otherwise from a model. Official warnings come from MetMalaysia's open data feed and are matched to the user's state and district.
Users choose their location by GPS, a preset city or any city name, pick which of seven report sections to see, and set units, clock format and language. Rain and air-quality alerts are opt-in, with a cooldown and quiet hours at night.
Engineering decisions
Built to stay within a free hosting plan: per-run caps on reports and alert checks, short caches, and no server left running.
It keeps working when a data source fails. If Open-Meteo is down the bot switches to MET Norway and says so in the report footer. Requests time out after ten seconds and are retried once, and a health check every five minutes tells the admin when a problem starts and when it ends.
Warnings err on the side of showing. The official feed has no coordinates, so warnings are matched by place name; when the district is unknown the warning is shown anyway, because a missed flood warning is worse than an extra message. Sea warnings are never shown to people on land.
Evidence and evaluation
Around 250 automated tests cover report formatting, the weather and backup sources, warnings matching, alerts, admin tools and translation coverage in all three languages. Type checks and tests run on every push before the automatic deploy, and a separate end-to-end script runs the bot against mock Telegram and weather services.
Limitations and next steps
Official warnings cover Malaysia only, and the bot does not replace them. Air quality uses the US EPA scale, not Malaysia's official index. The data is hourly, so "rain soon" means within one to two hours. The backup source has no rain probability, so it is estimated from forecast rainfall.