Your first cron val
This is a step-by-step guide to a cron val that sends you a weather email every morning.
If you get stuck, please ask for help in the Val Town Discord. We’re friendly!
Step 1: Sign up to Val Town
Sign up to Val Town. It’s free.
Step 2: Create a Cron val
In the top-right corner of Val Town, click New > Cron.
This will create an schedule a new empty val in your account that looks like this:
This function will be run on a schedule.
Step 3: Get the weather
In the following example code, we are using getWeather
from stevekrouse/getWeather. It uses the free wttr.in service to get weather data.
- Add these lines to your code
- Replace
Brooklyn, NY
with your location - Click Run Now
- View the output in the val’s logs
Step 4: Send yourself an email
We’re going to use std/email to send an email to yourself.
- Add these lines to your code
- Click Run Now
- Check your email inbox
You should have an email with a subject like “Weather now is Sunny and 67°F”.
Step 5: Schedule the val
We want this to run every morning. For example, in NYC, you could use 0 9 * * *
to run at 5am ET every morning.
We recommend crongpt.com to help you write cron expressions. It also handles the timezone conversion from your timezone to Val Town’s server timezone (UTC).
- Go to crongpt.com and generate your cron expression
- Click ⚙ (the gear icon) in the top right corner of the val editor
- Click Cron
- Paste in your cron expression
Next steps
🥳 Congratulations! You’ve created a val that sends you a weather notification every morning. You can customize it to your needs. There are a LOT of weather vals you can use or gain inspiration from:
Which_Jacket
- email alerts about which jacket to wearumbrellaReminder
- email alerts when it’s going to rainweatherGPT
- email alerts with a ChatGPT-written messagepowderNotify
- email alerts when it snowssailingNotifyCron
- email alerts when it’s a good day to saildiscordWebhookWeatherHyd
- send weather updates to Discordweather_forecast_in_the_morning
- weather forecast on TelegramweatherBot
- OpenAI Weather Bot via function callingaqi
- email alerts when AQI is unhealthy near you- …add yours here! (via the edit button below)