Skip to main content

Configuration

The Patter constructor accepts PatterOptions. Pass a carrier instance and a phone number — everything else flows through environment variables unless you override it.

Minimal config

The carrier instance reads credentials from environment variables when you don’t pass them explicitly. See Carrier for the full list.

Constructor parameters

Webhook URL Format

The webhookUrl must be a bare hostname with no protocol prefix or path:
The SDK constructs full URLs internally (e.g., https://{webhookUrl}/webhooks/twilio/voice).
Telnyx: Telnyx is a fully supported alternative to Twilio, with feature parity for DTMF, call transfer, recording, and cost tracking.

Environment variables

Every credential resolves from an env var when the matching argument is omitted. See .env.example in the repo for a complete list.

Runtime env vars

These tune SDK runtime behaviour (no credential lookup).
PATTER_BIND_HOST defaults to loopback on purpose — exposing the embedded server on 0.0.0.0 outside a containerised deployment puts the dashboard and webhook routes on every interface. Pair PATTER_BIND_HOST=0.0.0.0 with the dashboardToken option on serve() (or skip the dashboard) before going public.
PATTER_DASHBOARD_NOTIFY only gates the standalone-dashboard ingest webhook. It does not disable the embedded dashboard you can serve from phone.serve({ dashboard: true }) — that route runs in-process and is unaffected.

Examples

OpenAI Realtime on Twilio

OpenAI Realtime on Telnyx

Pipeline mode

Persistent dashboard history

By default the dashboard is an in-memory ring buffer — restart the process and the call list is empty. Pass persist to keep per-call records (metadata.json, transcript.jsonl, events.jsonl) on disk and rebuild the dashboard on the next startup. No external database required. When persist is set explicitly the env var is ignored. When persist is undefined, PATTER_LOG_DIR continues to work as a deployment-time override.

Platform default location

Simplest opt-in

Custom path

Env-var override (deployment-time)

Leave persist unset in code and let ops decide per environment:

Programmatic hydration on startup

phone.serve() calls MetricsStore.hydrate(logRoot) automatically when persistence is enabled, so the dashboard repopulates from disk before the first call lands. You can call it directly if you build the store yourself:
hydrate() is idempotent — callIds already in the store are skipped, and unparseable records are logged at debug level rather than aborting.

Retention

Retention defaults to 30 days and phone numbers in metadata.json are masked by default (last 4 digits) via PATTER_LOG_REDACT_PHONE. If you need to keep call history indefinitely or store full E.164 numbers, set those env vars explicitly — and gate access to the log root, since transcript.jsonl is never redacted and may contain customer PII spoken during the call.
See Call logging for the full layout, schema, and reading patterns.

Loading from .env

Telnyx delivers 16 kHz PCM audio natively, so no transcoding is needed. Twilio uses mulaw 8 kHz, which the SDK transcodes automatically.
Never hardcode API keys, tokens, or secrets in your source code. Always use environment variables or a secret manager.