Relay is a self-hosted communications inbox and softphone built with Telnyx, Cloudflare Workers, React, and SwiftUI. It keeps SMS, MMS, calls, and voicemail in one timeline per phone number and provides both a responsive web client and a native iPhone client.
Built on Cloudflare Workers, Durable Objects, D1, and R2 by workrr.ai.
Important
Relay is an early-stage project, not a turnkey telephone service. Operators are responsible for their Telnyx account, messaging registration, emergency-calling obligations, abuse prevention, data retention, and regulatory compliance. Do not rely on Relay for emergency calls.
- Unified call, SMS, MMS, and voicemail history
- Browser calling through the Telnyx WebRTC SDK
- Native iOS calling with SwiftUI, CallKit, PushKit, and DTMF
- Password authentication, optional passkey fallback, and revocable iOS device credentials
- Real-time updates over Cloudflare Durable Object WebSockets
- APNs alerts for incoming SMS/MMS, missed calls, and ready voicemail, with shared unread badges
- Cross-client conversation archive and full-history search
- Multi-tenant D1 schema and R2 media storage
apps/api Cloudflare Worker API, Telnyx webhooks, D1 migrations
apps/web React/Vite progressive web application
apps/ios Native SwiftUI iPhone application
docs Architecture and design notes
- Node.js 22 or newer
- Cloudflare Workers, D1, R2, and a public HTTPS hostname
- A Telnyx API key, webhook public key, phone number, messaging profile, outbound voice profile, and Credential Connection
- Xcode 16 or newer for iOS
- Apple Developer Program membership for production PushKit/APNs delivery
git clone https://github.com/shawnbure/relay-voice.git
cd relay-voice
npm install
cp apps/api/.dev.vars.example apps/api/.dev.vars
cd apps/api
npx wrangler d1 migrations apply DB --local
cd ../..Replace the examples in apps/api/.dev.vars, then run the API and web client in separate terminals:
npm run dev:api
npm run devThe web client runs at http://localhost:5173; the Worker runs at http://localhost:8787. The local bearer-token bypass only works with ENVIRONMENT=development. Never commit .dev.vars.
-
Authenticate and create storage:
npx wrangler login cd apps/api npx wrangler d1 create relay-voice npx wrangler r2 bucket create relay-voice-media -
Replace the all-zero
database_idinapps/api/wrangler.jsoncwith the returned D1 ID. -
Set
ENVIRONMENTtoproductionandWEB_ORIGINto your public HTTPS origin. Keepworkers_dev: trueor configure your own Cloudflare custom domain. -
Store secrets interactively:
npx wrangler secret put TELNYX_API_KEY npx wrangler secret put TELNYX_PUBLIC_KEY
-
Apply migrations and deploy:
npx wrangler d1 migrations apply DB --remote cd ../.. npm run build npm run deploy -w @relay/api -
Open the deployed site and create the owner account with a password of at least 12 characters. Public registration closes immediately after the hostname is assigned to that workspace.
Relay can serve multiple isolated workspaces from one Worker and D1 database. Migration 0010_domain_password_auth.sql adds the hostname-to-workspace mapping. Every request resolves its tenant through tenant_domains, so sessions cannot cross into a workspace assigned to another hostname.
Add each hostname as a Worker custom domain, then either open an unassigned hostname to complete its one-time owner setup or insert a mapping administratively:
INSERT INTO tenant_domains (hostname, tenant_id)
VALUES ('voice.example.com', '<TENANT_ID>');Passwords are salted PBKDF2-SHA256 hashes; Relay never stores plaintext passwords in D1. Owners can set or rotate their web password in Settings. Login attempts are throttled by hostname and a hash of the client address. Existing passkeys continue to work only on the RP hostname where they were created.
See Cloudflare's current documentation for D1 creation, R2 bindings, and custom domains.
Relay stores provider resource IDs in D1—not in source code.
-
Buy or port a Telnyx number with voice and messaging capabilities.
-
Create a messaging profile, assign the number, and configure this webhook:
https://relay.example.com/v1/webhooks/telnyx -
Create an outbound voice profile, Credential Connection, and telephony credential.
-
Configure voice and messaging call-control events to use the same webhook.
-
Insert the resulting IDs after creating the owner account:
INSERT INTO phone_numbers (id, tenant_id, e164, telnyx_number_id, messaging_profile_id, connection_id) VALUES ('phone_1', '<TENANT_ID>', '+15551234567', '<TELNYX_NUMBER_ID>', '<MESSAGING_PROFILE_ID>', '<VOICE_APPLICATION_OR_CONNECTION_ID>'); INSERT INTO telephony_credentials (id, tenant_id, user_id, telnyx_credential_id) VALUES ('credential_1', '<TENANT_ID>', '<USER_ID>', '<TELNYX_TELEPHONY_CREDENTIAL_ID>');
Find the generated owner IDs with:
cd apps/api
npx wrangler d1 execute DB --remote --command \
"SELECT tenant_id, user_id FROM memberships WHERE role='owner';"An authenticated workspace owner can also attach a number that is already present in the same Telnyx account. Relay reuses the configured messaging and voice applications while creating a tenant-specific WebRTC credential:
POST /v1/admin/phone-number
Content-Type: application/json
{"e164":"+15551234567"}The endpoint accepts only one unassigned E.164 number per workspace and records the change in the audit log.
Telnyx requirements differ by region and number type. Follow the current Telnyx documentation before carrying production traffic.
-
Replace
com.example.relayinapps/ios/project.ymlwith your own bundle identifier. -
Replace the example
RELAY_API_BASE_URLwith your deployed HTTPS origin. -
Generate and open the project:
cd apps/ios xcodegen generate open Relay.xcodeproj -
Select your Apple development team, enable automatic signing, connect an iPhone, and run.
-
Create a mobile token with authenticated
POST /v1/mobile/token, then add it to the app Keychain through your own secure onboarding flow.
The current iOS client is owner-oriented and does not yet provide a public account-linking screen. Production background ringing requires the Push Notifications capability, VoIP background mode, an APNs VoIP credential, and matching Telnyx push configuration. CallKit's incoming-call interface is required for PushKit VoIP wakeups.
npm test
npm run typecheck
npm run buildRead SECURITY.md before exposing Relay to the internet. Issues and pull requests are welcome; see CONTRIBUTING.md.
Relay is available under the MIT License.