dc-water-filter
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
A Val Town email trigger that filters DC Water emergency alerts by proximity to your home address. Only alerts within a configurable radius in the NE quadrant are forwarded to your inbox.
- DC Water sends emergency alert emails (outages, water main repairs, etc.)
- You forward these to your Val Town email trigger address
- The val extracts the location from the email body
- Locations outside the NE quadrant are dropped
- Remaining locations are geocoded via the US Census Bureau API
- If the location is within your configured radius, the email is forwarded to you
The filter is intentionally fail-open: if location parsing or geocoding fails, the email is forwarded with a note about what went wrong. The only hard filter is the NE quadrant check.
backend/
index.ts # Val Town email trigger entry point
shared/
parsing.ts # Location extraction, parsing, geocoding, distance calc
parsing_test.ts # Deno tests
examples/
*.eml # Sample DC Water alert emails for testing
Set these in your Val Town environment:
| Variable | Required | Description |
|---|---|---|
HOME_LAT | Yes | Your home latitude |
HOME_LNG | Yes | Your home longitude |
ALLOWED_SENDER | No | Only process emails from this address (sender filter) |
The proximity radius is set to 1.0 miles in backend/index.ts.
deno test shared/parsing_test.ts --allow-read --allow-net --no-config
--no-config is needed to avoid deno.json pulling in Val Town types that
aren't available locally.
- Geocoding: US Census Bureau geocoder (free, no API key, handles DC intersections well)
- LLM fallback: When deterministic parsing can't produce a geocodable address, OpenAI gpt-4o-mini rewrites the location string before a second geocode attempt
- Email parsing: Location is extracted from the pattern
located on/in [LOCATION]. Some customersfound in DC Water alert templates