Back to Insights
VoIP Engineering

FreeSWITCH Event Socket (ESL) Guide: Inbound vs Outbound Mode

Telephony Engineering Team
4 min read
FreeSWITCH Event Socket (ESL) Guide: Inbound vs Outbound Mode

The Event Socket Library (ESL) lets your own application connect to FreeSWITCH over TCP to receive call events and issue commands, which is how most custom call-control logic is built. It turns FreeSWITCH into a programmable media engine controlled from Python, Node.js, Go, or any language that can speak the protocol.

Two Modes

Inbound mode. Your application connects to FreeSWITCH (default port 8021, with a password). You subscribe to events and send API or sendmsg commands, typically for originating calls and monitoring everything on the system. Good for dialers, dashboards, and click-to-call.

Outbound mode. The dial plan uses the socket application to connect to your server for a specific call. Your application then controls that one channel from start to finish. Good for IVRs, per-call logic, and AI voice agent bridges.

InboundOutbound
ConnectionApp connects to FreeSWITCHFreeSWITCH connects to app for each call
ScopeSystem-wide events and commandsOne call at a time
Typical useOriginate calls, monitor eventsIVR flow, per-call application
ScalingOne long-lived connection per nodeOne connection per active call

Common Commands

  • originate to create a call
  • uuid_bridge, uuid_transfer, uuid_kill to manipulate existing channels
  • playback, record, say, play_and_get_digits through dial plan applications
  • event plain ALL or specific events to subscribe to

Useful Events

CHANNEL_CREATE, CHANNEL_ANSWER, CHANNEL_HANGUP_COMPLETE (with variables that feed CDRs, see CDR explained), DTMF, CUSTOM sofia::register for registration tracking, and HEARTBEAT for node health.

Design Patterns That Hold Up

  1. Never block the event loop. Do database and HTTP work asynchronously or on workers.
  2. Reconnect automatically and resubscribe. Connections will drop.
  3. Handle every channel's full lifecycle, including unexpected hangups mid-operation.
  4. Correlate with a UUID or custom variable so logs, CDRs, and signaling traces tell one story.
  5. Limit blast radius. One bad call handler must not crash the node's controller.
  6. Secure port 8021. Bind to localhost or a private network, with a strong password (see FreeSWITCH hardening).

Where It Fits

Choosing ESL vs Scripts

Embedded scripts (Lua) avoid network hops and suit simple, high-volume logic. ESL suits complex applications with their own state, deployment, and language preferences.


Need custom call-control applications on FreeSWITCH? Our FreeSWITCH development team builds ESL-based services for IVR, dialing, and voice AI.

Discussion

0

Join the conversation

Sign in with your preferred account to comment, reply, and keep the discussion useful for other engineers.

Takes a few seconds. No separate password required.

C

Controva LLC

Engineering Team

We build digital empires that scale. Specializing in high-performance web architecture, AI automation, and headless commerce.

Work with us

Share this article