Architecture
pixel-phone answers the Pixelbar doorbell. See the overview for the call state diagram.
Parts
| Part | Role |
|---|---|
| OpenR intercom | Calls a list of numbers when the doorbell is pressed, and moves on only when a call goes unanswered |
| Telnyx | Owns the number and sends call events to pixel-phone's webhook (Call Control) |
| pixel-phone | Tracks the call, flips the Home Assistant switch, tells Pixel, and answers when someone accepts |
| Home Assistant | Owns the siren and the button. Turns the siren on and off from the switch, and calls the accept API when the button is pressed |
| Pixel | Reads call events from a queue, posts the doorbell in Discord with an Answer button, and calls the accept API |
Call flow
pixel-phone sends Telnyx no command until someone accepts (ADR 0002). If nobody accepts, the call rings out and OpenR tries the next number.
sequenceDiagram
autonumber
participant O as OpenR intercom
participant T as Telnyx
participant P as pixel-phone
participant H as Home Assistant
participant Q as phone-events queue
participant X as Pixel (Discord)
O->>T: calls the doorbell number
T->>P: webhook call.initiated
P->>P: save call as ringing (accept window 15 s)
par ring the space
P->>H: input_boolean.turn_on (pixel_phone_ringing)
and tell Pixel
P->>Q: ringing
Q-->>X: polled about once a second
X->>X: post the doorbell with an Answer button
end
alt someone accepts in time (button or Discord, first wins)
H->>P: POST /api/v1/calls/current/accept (button)
Note over X,P: or Pixel: POST /api/v1/calls/{callId}/accept
P->>T: answer
P->>T: play the accept recording
P->>H: input_boolean.turn_off
P->>Q: accepted (via, by)
T->>P: webhook call.playback.ended
P->>T: hang up
P->>Q: ended
else window passes, or the caller hangs up
P->>H: input_boolean.turn_off
P->>Q: missed (timeout or caller_hung_up)
Note over O,T: no command was sent, so the call rings out<br/>and OpenR calls the next number
end
Decisions
| ADR | Decision |
|---|---|
| 0001 | TypeScript, ports and adapters, fastify |
| 0002 | Telnyx Call Control, and we answer only on accept |
| 0003 | Azure Container Apps, one always-warm replica (amended by #29), public ingress, two environments |
| 0004 | Call state in Table storage, one call at a time, first accept wins |
| 0005 | Home Assistant owns the siren |
| 0006 | Pixel through an Azure Storage Queue |
| 0007 | Telnyx config by a script, not Terraform |
| 0008 | Recordings in our own Blob container |
| 0009 | Sentry and pino; phone numbers aren't treated as private |
| 0010 | Terraform bootstrap and GitHub OIDC |
Configuration
Every setting is read in src/config.ts. This table grows as features land.
| Variable | Required | Description |
|---|---|---|
PIXEL_PHONE_ENV | no (local) | local, dev or prod. Terraform sets it |
PORT | no (3000) | HTTP port |
LOG_LEVEL | no (info) | pino level |
PIXEL_PHONE_VERSION, PIXEL_PHONE_GIT_SHA | no | Baked into the image; /version reports them |
ACCEPT_WINDOW_SECONDS | no (15) | How long after a call arrives it can still be accepted (5–120) |
TELNYX_API_KEY, TELNYX_PUBLIC_KEY | together | Telnyx Call Control. Without them the webhook answers 503 |
HOME_ASSISTANT_URL, HOME_ASSISTANT_TOKEN, HOME_ASSISTANT_RINGING_ENTITY | together | Home Assistant. Outside prod the entity must end in _dev |
API_KEYS_YAML | no | The accept API's callers |
SENTRY_DSN, SENTRY_TRACES_SAMPLE_RATE | no | Sentry |
AZURE_CLIENT_ID | in Azure | The app's managed identity |
AZURE_STORAGE_ACCOUNT_NAME | in dev and prod | Storage for calls, webhook IDs, the queue and recordings |
AZURE_STORAGE_CONNECTION_STRING | local only | UseDevelopmentStorage=true for Azurite (just azurite). Unset locally: state is kept in memory |
PHONE_EVENTS_QUEUE, MEDIA_CONTAINER | no | Queue and blob container names |
RECORDING_ACCEPTED | no (accepted.mp3) | The accept recording's blob name in the media container (.mp3 or .wav) |