Skip to content
AI Engineering
AI Engineering10 min read0 views

FreeSWITCH for Self-Hosted AI Receptionists: 2026 Architecture

How to bridge FreeSWITCH to an AI agent using mod_audio_fork, mod_unimrcp, or a SignalWire AI Agent connect, with concrete dialplan examples.

FreeSWITCH remains the open-source choice for teams who want full control of their telephony stack. In 2026 the cleanest AI integration paths are mod_audio_fork to a model proxy, a SignalWire AI Agent bridge, or a direct dial to an OpenAI SIP URI.

Background: FreeSWITCH in 2026

flowchart LR
  Phone["PSTN caller"] --> Carrier["Carrier"]
  Carrier -- "SIP INVITE" --> SBC["Session Border Controller"]
  SBC -- "SIP" --> PBX["Twilio / Asterisk"]
  PBX -- "RTP · Opus" --> Bridge["AI Voice Gateway"]
  Bridge --> AI["OpenAI Realtime"]
  AI --> Bridge
  Bridge --> PBX
CallSphere reference architecture

FreeSWITCH was created by the same team that now runs SignalWire, and the project still has the most flexible scripting and call-routing model of any open-source PBX. It excels at edge cases: media transcoding, large-scale conferencing, custom dialplans, and complex SIP topologies. Asterisk wins on community size; FreeSWITCH wins on the kind of workloads where you need surgical control of audio.

For AI agents in 2026, FreeSWITCH offers three viable patterns:

Hear it before you finish reading

Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.

Try Live Demo →
  1. mod_audio_fork — fork RTP audio to a WebSocket server which proxies to your AI model.
  2. SignalWire AI Agent bridge — let SignalWire's hosted AI Agent take over the call after a dialplan handoff.
  3. Direct SIP dial to AI — bridge the leg straight to OpenAI Realtime's SIP endpoint or to a CallSphere SIP URI on Twilio.

How VoIP and SIP work for this use case

A call arrives on a FreeSWITCH SIP profile (typically external on UDP 5080 or TLS 5081). The dialplan matches the destination and routes through XML or Lua. For AI handoff, the simplest pattern is bridge to a SIP URI that terminates on the AI. For finer control, fork audio out to a WebSocket and run the model on your own infrastructure. mod_audio_fork sends 16-bit linear PCM at 8 or 16 kHz over a websocket, including dialog metadata in the first frame.

CallSphere implementation

CallSphere is Twilio-first end-to-end, and the supported pattern for FreeSWITCH customers is the same as for Asterisk customers: the FreeSWITCH dialplan bridges out to a CallSphere-provided SIP URI, which terminates on Twilio Elastic SIP Trunking and bridges to OpenAI Realtime. CallSphere's 37 agents across 90+ tools and 115+ database tables work the same whether the call originates on FreeSWITCH, Asterisk, or directly on a Twilio number. HIPAA and SOC 2 controls apply to all paths. Pricing remains $149, $499, and $1499 for 1, 3, and 10 numbers, with a 14-day trial and a 22% affiliate. The Healthcare AI receptionist on FastAPI :8084, the Sales Calling AI with five concurrent outbound, and the After-Hours AI with simultaneous call plus SMS and 120 second timeout all behave identically regardless of front-end PBX.

Build and integration steps

  1. Install FreeSWITCH 1.10+ with mod_audio_fork and mod_sofia enabled.
  2. Provision a SIP profile bound to your carrier on the external interface.
  3. Decide on integration pattern: audio_fork to your own AI proxy, or SIP dial to a managed AI endpoint.
  4. For audio_fork: set up a WebSocket server that bridges to OpenAI Realtime, ElevenLabs, or your model of choice.
  5. For SIP dial: configure a gateway to OpenAI's SIP URI or to a managed provider's SIP URI.
  6. Update the dialplan to match destination numbers and route them to the AI.
  7. Add CDR logging and a fallback action for AI service unavailability (route to voicemail or human).
  8. Smoke test interruption handling, music-on-hold, and graceful hangup.

Code or config snippet

<!-- FreeSWITCH dialplan: bridge inbound to a managed AI SIP URI -->
<extension name="ai_receptionist">
  <condition field="destination_number" expression="^(15555550100)$">
    <action application="set" data="hangup_after_bridge=true"/>
    <action application="set" data="continue_on_fail=true"/>
    <action application="set" data="effective_caller_id_name=CallSphere AI"/>
    <action application="bridge"
      data="sofia/external/[email protected];transport=tls"/>
    <action application="answer"/>
    <action application="playback" data="ivr/ivr-call_cannot_be_completed.wav"/>
    <action application="hangup"/>
  </condition>
</extension>

FAQ

Why pick FreeSWITCH over Asterisk for AI? Pick FreeSWITCH if you need fine-grained media control, large conferencing, or you already have FreeSWITCH expertise. Otherwise Asterisk's larger community is usually the safer default.

Does mod_audio_fork affect call quality? Forking audio adds a WebSocket hop. Run the proxy in the same data center as FreeSWITCH and the added latency is under 5 ms.

Still reading? Stop comparing — try CallSphere live.

CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.

Can I run FreeSWITCH and Twilio in the same architecture? Yes. Many CallSphere customers run FreeSWITCH as their internal PBX and bridge out to Twilio for the AI agent leg.

Is SignalWire's AI Agent a drop-in replacement for building it yourself? For many use cases, yes. It is hosted, opinionated, and works with any FreeSWITCH dialplan via a single bridge action.

What about high-availability? Run two FreeSWITCH nodes behind a Kamailio dispatcher with shared registrar; bridge to two AI termination URIs and fail over on 5xx responses.

Sources

Start a 14-day trial, book a demo, or read more about the Twilio integration.

Share

Try CallSphere AI Voice Agents

See how AI voice agents work for your industry. Live demo available -- no signup required.