Turn your iPhone into a powerful automation hub using email triggers and Val Town! This template lets you schedule iOS shortcuts to run at specific times by simply sending an email.
This Val creates a system where:
- You send an email with a specific subject/sender to your iCloud email
- iOS Mail filters detect the email instantly (via push notifications)
- An iOS Shortcut automatically triggers
- The shortcut calls this Val Town endpoint to schedule an action
- Val Town sends you a notification email when it's time to run your automation
- Your iOS Shortcut triggers again to perform the scheduled action
Why iCloud email? iCloud email supports push notifications, meaning emails arrive instantly on your iPhone. This makes it perfect for real-time automation triggers, unlike Gmail which uses periodic polling.
- Fork this Val or copy the code
- Update
sendEmail.tsto use your email address - Note your HTTP endpoint URL (found in
schedule.tsfile details)
- Open Mail app on iPhone
- Go to an email from the sender you want to filter (or send yourself a test email)
- Tap the sender's email address at the top
- Tap "Create VIP" or use a filter app like Mail Rules
- Alternatively, create a filter based on subject line containing specific text
Pro Tip: Use a unique subject prefix like [AUTOMATE] to make filtering reliable.
- Open Shortcuts app
- Create new Automation
- Choose Email trigger
- Configure:
- Sender: specific email address
- Subject: contains "[AUTOMATE]" (or your prefix)
- Run Immediately: ON (critical!)
- Add action: Get Contents of URL
- URL:
https://your-val-endpoint.web.val.run?minutes=X - Method: GET
- URL:
- Parse the email body to extract the minutes value if needed
- Create another Automation
- Choose Email trigger
- Configure:
- Sender: your Val Town email
- Subject: contains "Scheduled Notification"
- Run Immediately: ON
- Add your actual automation actions here (play music, send message, etc.)
Send email to yourself:
- Subject:
[AUTOMATE] Remind me in 30 minutes - Body:
30
Your shortcut extracts "30" and calls: ?minutes=30
- Subject:
[AUTOMATE] Turn off lights in 1 hour - Call:
?minutes=60 - Action shortcut: Triggers HomeKit scene
- Subject:
[AUTOMATE] End focus mode in 90 minutes - Call:
?minutes=90 - Action shortcut: Disables focus mode
GET /schedule.ts?minutes=X
Parameters:
minutes(required): Number of minutes from now to send notification
Response:
{ "success": true, "message": "Email scheduled to send in 30 minutes", "scheduledTime": "2025-11-06T03:35:00.000Z" }
Edit sendEmail.ts and update the default email address.
Edit cron.ts interval settings (currently runs every 1 minute).
Modify cron.ts to trigger webhooks, APIs, or other Val Town functions instead of just sending email.
The SQLite database can store extra fields like:
- Action type
- Custom parameters
- Original email body
- Callback URLs
- Snooze emails: Forward an email with "[SNOOZE 2h]" to get it back in 2 hours
- Medication reminders: Email yourself from calendar events
- Parking meters: Email when you park, get reminded before expiration
- Meeting prep: Email before meetings to trigger prep shortcuts
- Pomodoro timer: Email yourself to start/end focus sessions
- Keep your Val private if it contains sensitive logic
- Consider adding authentication for production use
- Email filters should be specific to avoid false triggers
- Test with small delays first
Built with β€οΈ using Val Town. Fork and customize for your needs!