• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
drewmcdonald

drewmcdonald

dc-water-filter

Public
Like
dc-water-filter
Home
Code
10
.claude
backend
1
examples
shared
2
.mcp.json
.vtignore
CLAUDE.md
README.md
VALTOWN_GUIDE.md
deno.json
Environment variables
3
Branches
1
Pull requests
Remixes
History
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.
Sign up now
Code
/
Code
/
Search
README.md

DC Water Filter

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.

How It Works

  1. DC Water sends emergency alert emails (outages, water main repairs, etc.)
  2. You forward these to your Val Town email trigger address
  3. The val extracts the location from the email body
  4. Locations outside the NE quadrant are dropped
  5. Remaining locations are geocoded via the US Census Bureau API
  6. If the location is within your configured radius, the email is forwarded to you

Fail-Open Design

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.

Project Structure

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

Environment Variables

Set these in your Val Town environment:

VariableRequiredDescription
HOME_LATYesYour home latitude
HOME_LNGYesYour home longitude
ALLOWED_SENDERNoOnly process emails from this address (sender filter)

The proximity radius is set to 1.0 miles in backend/index.ts.

Testing

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.

Technical Details

  • 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 customers found in DC Water alert templates
Code
.claudebackendexamplesshared.mcp.json.vtignoreCLAUDE.mdREADME.mdVALTOWN_GUIDE.mddeno.json
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.