Skip to main content

Configuration

The Patter constructor accepts LocalOptions.

Local Mode

import { Patter } from "getpatter";

const phone = new Patter({
  mode: "local",
  twilioSid: process.env.TWILIO_SID,
  twilioToken: process.env.TWILIO_TOKEN,
  openaiKey: process.env.OPENAI_KEY,
  phoneNumber: "+15550001234",
  webhookUrl: "abc.ngrok.io",
});

LocalOptions

ParameterTypeRequiredDefaultDescription
mode"local"YesMust be "local" to enable local mode.
phoneNumberstringYesYour phone number in E.164 format.
webhookUrlstringYesPublic hostname for webhooks (no protocol prefix, no path).
twilioSidstringConditionalTwilio Account SID. Required if not using Telnyx.
twilioTokenstringConditionalTwilio Auth Token. Required when twilioSid is set.
openaiKeystringNoOpenAI API key for the realtime adapter.
telephonyProvider"twilio" | "telnyx"No"twilio"Which telephony provider to use.
telnyxKeystringConditionalTelnyx API key. Required if telephonyProvider is "telnyx".
telnyxConnectionIdstringNoTelnyx SIP Connection ID for outbound calls.
telnyxPublicKeystringNoTelnyx Ed25519 public key (base64 DER/SPKI) for webhook signature verification.
You must provide either twilioSid or telnyxKey. The constructor throws if neither is set.

Webhook URL Format

The webhookUrl must be a bare hostname with no protocol prefix or path:
// Correct
webhookUrl: "abc123.ngrok.io"

// Wrong — will throw
webhookUrl: "https://abc123.ngrok.io"
webhookUrl: "abc123.ngrok.io/webhooks"
The SDK constructs full URLs internally (e.g., https://{webhookUrl}/webhooks/twilio/voice).

Using Telnyx

const phone = new Patter({
  mode: "local",
  telephonyProvider: "telnyx",
  telnyxKey: process.env.TELNYX_KEY,
  telnyxConnectionId: process.env.TELNYX_CONNECTION_ID,
  telnyxPublicKey: process.env.TELNYX_PUBLIC_KEY,
  openaiKey: process.env.OPENAI_KEY,
  phoneNumber: "+15550001234",
  webhookUrl: "abc.ngrok.io",
});
Telnyx delivers 16kHz PCM audio natively, so no transcoding is needed. Twilio uses mulaw 8kHz, which the SDK transcodes automatically.

Environment Variables

We recommend loading credentials from environment variables. Never hardcode secrets:
// .env
TWILIO_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_TOKEN=your_auth_token
OPENAI_KEY=sk-...
PHONE_NUMBER=+15550001234
WEBHOOK_URL=abc123.ngrok.io
Use a library like dotenv or Node’s built-in --env-file flag (Node 20.6+):
node --env-file=.env index.js