Number Watcher

  • Voice AI and telephony
  • Telephony Automation
  • 2026
  • Open source

TypeScript, Node.js, Zod, AWS Lambda and 4 more

Number Watcher is a TypeScript CLI and background worker that watches US local phone number inventory on Twilio and Telnyx. A request names area codes, required capabilities, a quantity and a mode. In notify mode it sends one alert through Slack, email or a signed webhook once a single round finds enough matches. In purchase mode it buys matching numbers one at a time, up to the quantity.

Numbers in a particular area code come and go. Refreshing a provider console every few minutes stops working past one area code. A cron script that buys on sight is worse, because a timeout during a purchase leaves me unsure whether I was charged. So the core of this project is not search. It is accounting for every write that spends money.

A CLI and Lambda worker that watches Twilio and Telnyx for local phone numbers, then alerts or buys them under a price ceiling.

nodesession

# mocked transports: no real number was boughtnode dist/cli.js check --config requests/buy.json --offlinevalid: purchase mode, quantity 2, area codes 210 and 726node dist/cli.js add --config requests/buy.jsonqueued: no provider calls, no notificationsnode dist/cli.js --env-file .env workerpreflight: twilio and telnyx routes verifiedround: fresh quote within ceiling, intent savednumber.acquired: routing verified, 1 of 2 slots used

3 commands5 lines of output

numbersfrom the write-up

3reconciliation attempts before a job needs attention

24 h
longest a request may watch
180 s
DynamoDB lease per cloud tick
65
committed Vitest tests, all against mocked transports
Chapter
Voice AI and telephony
Category
Telephony Automation
Year
Availability
Open source
Last commit
stack8 parts
  • TypeScript
  • Node.js
  • Zod
  • AWS Lambda
  • DynamoDB
  • EventBridge Scheduler
  • Terraform
  • Vitest

Telephony, TypeScript, Twilio, Telnyx, AWS Lambda, Terraform

architecturethe purchase guard
A schedule wakes one polling round that searches Twilio and Telnyx, filters the results, and either notifies or buys through a guard that saves an intent firstEventBridgeone schedule per jobLambda tickone bounded round120 s timeoutDynamoDBlease · checkpoint180 s leaseTwilioREST searchexact E.164 buyTelnyxbest_effort offnumber_ordersmatching.tsdedupe by E.164within the ceilingOutboxslack · emailsigned webhookPurchase guardintent saved firstreconcile, no retrypollleasesearchresultsnotifypurchaseone ordernot deployed to AWS yettelnyx untested liveA schedule wakes one polling round that searches Twilio and Telnyx, filters the results, and either notifies or buys through a guard that saves an intent firstpollsearchsearchresultsresultsnotifypurchaseEventBridgeone schedule per jobLambda tickone bounded round180 s DynamoDB leaseTwilioREST searchTelnyxbest_effort offmatching.tsdedupe by E.164within the ceilingOutboxnotify modePurchase guardintent firstnot deployed to AWS yettelnyx untested live
Each round searches both providers, and a purchase saves its intent before it places one order.

Rounds and slots

A request is JSON, validated by Zod in src/config.ts. Unknown fields are errors, and purchase mode without a monthly price ceiling fails before anything runs. add saves an immutable copy under .state and contacts no provider. The worker in src/engine.ts runs a preflight, searches at once, then searches on fixed interval slots until an absolute deadline: every five minutes by default, for at most 24 hours. searchRound queries every provider and area code concurrently. src/matching.ts then rechecks country, type, exact area code and capabilities on each result, drops numbers a selected account already owns, and deduplicates by E.164. Telnyx searches run with best_effort=false, so nearby area codes never sneak in. Prices compare as fixed point bigint values, so a quote exactly at the ceiling passes and an unknown price never does. Quantity is one shared set of slots across both providers.

The cloud runtime

src/cloud/handler.ts takes submit, status, poll, cancel, resume and retry-notifications as IAM authorized Lambda invocations. Each submission carries a caller generated UUID, so resending the same file cannot reset quantity or extend the deadline. src/cloud/schedules.ts gives every job its own EventBridge Scheduler rate schedule, with a hard end date and a dead letter queue. Each tick takes a 180 second conditional lease in DynamoDB, runs one round inside a 120 second timeout, and saves a compressed checkpoint with a revision check. Terraform in infra/terraform marks the jobs table prevent_destroy, since losing checkpoints could lead to duplicate purchases. Notifications live in their own outbox. Each event has one delivery record per channel, so a failed email never resends a Slack message that was already acknowledged.

Decisions and costs

  • Persist an intent before every provider write. The engine records an acquisition in state intent and saves it before calling acquire. If the adapter throws, the outcome becomes unknown, and settle reconciles against the provider up to three times instead of retrying the order. Any unresolved acquisition blocks further purchases on both providers. The cost is that one lost response can park a job at needs_attention until I look.
  • No implicit purchase. mode is required, a notify job can never resume as a purchase job, and a fresh quote is checked against the ceiling before each order. Queuing a purchase request is the authorization, with no prompt when inventory appears. That is exactly why the ceiling is mandatory.
  • Never release a number automatically. Expiry and cancellation leave owned numbers and pending orders alone. A number that fails configuration still occupies its slot, so nothing buys a replacement. Cleanup is manual.
  • Pin Telnyx credentials by a SHA-256 hash of the API key, not an organisation lookup. Rotating the key mid job is rejected on resume, even for the same account. That is the decision I would revisit.

A notify run

Starting with notify mode proves inventory and delivery before anything spends money. The offline check needs no credentials, and add only queues.

bash8 lines
npm ci && npm run build
mkdir -p requests
cp examples/notify.json requests/watch.json   # then set your account SID and notify targets
node dist/cli.js check --config requests/watch.json --offline
node dist/cli.js --env-file .env check --config requests/watch.json
node dist/cli.js add --config requests/watch.json
node dist/cli.js --env-file .env worker
node dist/cli.js status --job <job-id>

The second check makes real read only calls: no purchase, no reservation, no notification. Switching to purchase mode means copying examples/purchase.json, setting the ceiling and pointing it at existing webhooks, Messaging Services or Telnyx profiles. The tool verifies those and never rewrites them.

Status and limits

It started on 25 October 2026 and has four commits. It handles US local numbers only, and Twilio setup fees are unknown, so a one time fee ceiling excludes its candidates. The 65 committed tests mock every transport. A read only check against a real Twilio account passed and caught a capability key casing bug, now a regression test. Telnyx has never run live, and no real purchase, Slack message or email has been sent. No AWS resources have been deployed. A local audit found two bugs in committed code, both fixed in uncommitted work. The lease update writes ttl, a DynamoDB reserved word, without an alias. The Telnyx quote lookup passes the whole number as a prefix filter. Until those land, I treat the cloud runtime as unproven. The repository carries no licence file.

All 43 projects