Skip to content

GenerationSoftware/avalanche-canada-sms

Repository files navigation

Avalanche Canada SMS Service

Tests

A serverless application that lets users text their GPS coordinates to a phone number and receive a summary of current avalanche conditions from Avalanche Canada for that location.

Currently hosted at https://avalanche-canada-sms.brendan-410.workers.dev/

How It Works

  1. Text your coordinates (e.g. 51.04, -115.06) to the service phone number
  2. The server identifies which Avalanche Canada forecast region covers that location
  3. You receive an SMS reply with the current danger ratings and avalanche problems

Example reply (fits in a single 160-character SMS):

Kananaskis
Feb 23
Alp:Considerable TL:Moderate BT:Low
Storm Slabs, Wind Slabs
avalanche.ca

Tech Stack

  • Runtime: Node.js / TypeScript
  • Framework: Hono (runs on Cloudflare Workers or AWS Lambda)
  • SMS: Twilio
  • Data Source: Avalanche Canada API
  • Summarization: Template-based (no LLM)

Setup

Prerequisites

  • Node.js 20+
  • A Twilio account with a phone number
  • Cloudflare account (for Workers deployment) or AWS account (for Lambda)

Install

npm install

Environment Variables

Copy the example file and fill in your Twilio credentials:

cp .env.example .env

See .env.example for all available variables.

Development

npm run dev

This starts a local Wrangler dev server. Set VALIDATE_TWILIO_SIG=false in your .env to skip Twilio signature checks during local development.

Test

npm test

Deploy to Cloudflare Workers

  1. Authenticate with Cloudflare:

    npx wrangler login

    This opens a browser window for OAuth. You only need to do this once.

  2. Set Twilio secrets:

    npx wrangler secret put TWILIO_ACCOUNT_SID
    npx wrangler secret put TWILIO_AUTH_TOKEN

    You'll be prompted to enter each value. These are stored encrypted and never appear in your code or config.

  3. Deploy:

    npm run deploy

    Wrangler will output the deployed URL (e.g. https://avalanche-canada-sms.<your-subdomain>.workers.dev).

  4. Configure Twilio webhook:

    In the Twilio console, go to your phone number's configuration and set the incoming message webhook to:

    https://avalanche-canada-sms.<your-subdomain>.workers.dev/sms/incoming
    

    Method: HTTP POST

  5. Test end-to-end: Send an SMS with coordinates to your Twilio number and verify you receive a forecast reply.

AWS Lambda: Use your preferred Lambda deployment tool (SST, Serverless Framework, etc.) with the Hono AWS Lambda adapter.

Admin Dashboard

Access the status dashboard at /admin to view live health checks of dependent services:

  • Avalanche Canada API — verifies the forecast endpoint is responding
  • Twilio — verifies credentials are valid and the API is reachable

Shows overall status (ok / degraded / down), per-service status with latency, and auto-refreshes every 30 seconds.

Supported Input Formats

  • Raw coordinates: 51.0447 -115.0632 or 51.0447, -115.0632 or 51.0447N 115.0632W
  • iOS location sharing (Apple Maps links)
  • Android location sharing (Google Maps links, including shortened maps.app.goo.gl URLs)

Documentation

About

Request current conditions from Avalanche Canada via SMS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published