Skip to main content

Carrier

The carrier delivers the phone call to Patter. Patter supports Twilio and Telnyx with full feature parity (DTMF, call transfer, recording, AMD, status callbacks, cost tracking). You configure one carrier per Patter instance by passing an instance to the carrier field. Each carrier class falls back to environment variables when constructor arguments are omitted. Each carrier ships as both a flat alias (import { Twilio } from "getpatter") and a namespaced class (import * as twilio from "getpatter/carriers/twilio"new twilio.Carrier()). They are equivalent.

Twilio

import { Patter, Twilio } from "getpatter";

const phone = new Patter({
  carrier: new Twilio(),                              // reads env
  phoneNumber: "+15550001234",
});

// Or explicitly:
const phone = new Patter({
  carrier: new Twilio({ accountSid: "AC...", authToken: "..." }),
  phoneNumber: "+15550001234",
});
ParameterTypeDefaultDescription
accountSidstringTwilio Account SID (starts with AC). Reads from TWILIO_ACCOUNT_SID when omitted.
authTokenstringTwilio Auth Token. Reads from TWILIO_AUTH_TOKEN when omitted.
Namespaced form:
import * as twilio from "getpatter/carriers/twilio";

const carrier = new twilio.Carrier();                 // reads env
const carrier = new twilio.Carrier({ accountSid: "AC...", authToken: "..." });
On serve(), Patter automatically sets the voice_url on the Twilio number to https://<webhookUrl>/webhooks/twilio/voice via the Twilio REST API — no manual Console configuration needed.

Signature verification

The Auth Token is also used to verify every Twilio webhook with HMAC-SHA1 against the X-Twilio-Signature header. Requests with invalid signatures are rejected with HTTP 403.

Telnyx

import { Patter, Telnyx } from "getpatter";

const phone = new Patter({
  carrier: new Telnyx(),                              // reads env
  phoneNumber: "+15550001234",
});

// Or explicitly:
const phone = new Patter({
  carrier: new Telnyx({
    apiKey: "KEY...",
    connectionId: "2000000000000000000",
    publicKey: "...",   // optional — enables Ed25519 signature verification
  }),
  phoneNumber: "+15550001234",
});
ParameterTypeDefaultDescription
apiKeystringTelnyx API v2 key. Reads from TELNYX_API_KEY when omitted.
connectionIdstringCall Control Application ID. Reads from TELNYX_CONNECTION_ID when omitted.
publicKeystringOptional. Ed25519 public key for webhook signature verification. Reads from TELNYX_PUBLIC_KEY when omitted.
Namespaced form:
import * as telnyx from "getpatter/carriers/telnyx";

const carrier = new telnyx.Carrier();                 // reads env

Signature verification

When publicKey is set (or TELNYX_PUBLIC_KEY is present), every Telnyx webhook is verified with Ed25519. Requests older than 5 minutes are rejected (replay protection).

Webhook Endpoints

The embedded server exposes these endpoints regardless of carrier choice:
EndpointPurpose
POST /webhooks/twilio/voiceIncoming Twilio call → returns TwiML to start streaming.
POST /webhooks/twilio/statusCall lifecycle status callbacks (initiated, ringing, answered, completed).
POST /webhooks/twilio/recordingRecording completion callbacks.
POST /webhooks/twilio/amdAsync AMD (answering machine detection) results.
POST /webhooks/telnyx/voiceIncoming Telnyx call → returns Call Control commands.

What’s Next

STT

Speech-to-text providers.

LLM

Language model providers.

TTS

Text-to-speech providers.

Tunneling

Expose your local server publicly.