Dograh

Asterisk VoIP Guide: Architecture, Features and AI Use

Asterisk VoIP Guide: Architecture, Features and AI Use
TechnicalDecember 4, 2026·15 min read

Asterisk VoIP Guide: Architecture, Features and AI Use

Pritesh Kumar
Pritesh Kumar·Co-founder, Dograh AI

Building Dograh, the open-source alternative to Vapi. OSS and Voice AI. Exit founder and YC alum.

Asterisk VoIP is open-source software that turns a Linux server into a phone system, handling SIP signaling, RTP audio and call routing. For AI voice agents it is the telephony edge, with ARI handing live calls to outside code. Dograh, the open-source AI voice agent platform, connects over ARI, and you can self-host it or run it on Dograh Cloud.

Key Takeaways

  • Asterisk works best as a programmable call and media edge for your software.
  • Codec transcoding cuts call capacity long before SIP signaling runs out.
  • Keep AMI and ARI on private networks and alert on toll-fraud spikes.

Teams usually reach Asterisk when they want a phone line their own code can control. We cover how it moves a call, where it sits under an AI voice agent, and what sizing, security and upgrades ask of your team, then show how Dograh connects to it over ARI.

What Asterisk is and where it came from

Asterisk is software that does the job of an office phone switch on an ordinary Linux server. A traditional PBX is a locked cabinet of vendor circuit boards that only the vendor can extend, and Asterisk rewrites that switchboard as code you can read, change and run on hardware you pick.

Voice over Internet Protocol (VoIP) carries audio as data packets across IP networks instead of dedicated copper circuits. If private phone switching is new to you, our guide on how a PBX routes business calls covers the basics. Asterisk splits the work into layers. Signaling sets up, transfers and ends calls over the Session Initiation Protocol (SIP), so phones and carriers agree on who is calling whom. Media moves live voice over the Real-Time Transport Protocol (RTP) and converts between audio codecs when two ends use different formats. Logic decides where each call goes, from the dialed number, the time of day, the caller ID or instructions from an outside application.

According to the official Asterisk project history, Mark Spencer was finishing a computer engineering degree at Auburn University when he founded Linux Support Services in 1999. Phone system quotes for the company were too expensive, so he wrote the core engine himself within a few months and released it under the GNU General Public License. In 2001 the company changed its name to Digium to build hardware and support around the project, and the open license let thousands of contributors extend the engine far past a basic office switch.

The parts that move one call

You only need nine building blocks to follow any call through Asterisk, even though a fresh configuration directory holds dozens of files. Each one has a clear job.

ComponentWhat it doesWhy it matters
ChannelRepresents one leg of a call from a phone, trunk or applicationEvery call is made of channels, and each one can be monitored
BridgeJoins channels so audio flows between themUsed for two-party calls, conferences and agent handoffs
DialplanHolds the rules that route calls by number, time or contextWhere routing logic lives in a classic PBX
PJSIPHandles SIP registration, signaling and trunk connectionsConnects phones, carriers and session border controllers
CodecsCompress and decode voice, for example G.711 and iLBCTrade bandwidth against CPU load
ModulesOptional features that can be loaded or disabledControl which features are present and the attack surface
ApplicationsVoicemail, queues, IVR menus and call recordingBuilt-in call handling for common needs
ARIREST and event interface for application control of live callsLets outside code create, bridge and monitor calls
AMIManagement interface for administration and channel monitoringUsed for operational and administrative tasks

Follow one call to see them work together. A customer dials your support number and the call reaches the server through PJSIP, the SIP stack that handles registrations, carrier trunks and signaling. If carrier connectivity is new to you, read up on what SIP trunking does to see how your provider hands calls to PJSIP. Once PJSIP accepts the invite, Asterisk opens an inbound channel for the caller's leg. The dialplan checks the dialed number, the time and the routing context. If its rule rings an agent's desk phone, Asterisk opens a second channel to that phone, and when the agent picks up, a bridge joins the two so audio flows both ways.

While they talk, the codec shapes the audio. G.711 is the uncompressed telephony baseline and light on CPU, while iLBC compresses harder to save bandwidth at the cost of more processing.

Almost all of this loads as optional modules, and turning off unused ones shrinks your security exposure. Outside software talks to Asterisk through two interfaces. The Asterisk Manager Interface (AMI) handles administration and live channel monitoring, such as watching queue depth. The Asterisk REST Interface (ARI) lets your own code own live call objects through REST requests and asynchronous events. A small office build runs PJSIP, one trunk, a static dialplan and voicemail, often managed through a web GUI like FreePBX, while an AI voice agent build centers on PJSIP, ARI and an outside service that runs the conversation.

Dograh

Open Source Alternative to Vapi / Retell

Self-hosted voice agent platform — no per-minute fees

dograh-hq/dograh

Star on GitHub

Where Asterisk runs in practice

Open-source telephony has carried real call volume for a long time. A 2008 market assessment reported by Connections Magazine put open-source PBX systems at 18 percent of North American PBX lines, about 2.85 million endpoints, more than any single legacy vendor such as Nortel, Cisco, Avaya or NEC. Asterisk made up about 85 percent of that open-source segment.

Carriers, universities and small businesses adopted it because a team that owns its stack stops renting it per seat, and the same engine shows up in very different jobs.

Use caseAsterisk's roleMain requirement
Small office PBXExtensions, SIP trunks and voicemailReliable SIP trunk and correct firewall rules
Call centerQueues, agent routing and call recordingCapacity planning and reporting
IVR and self-serviceDialplan or ARI-driven menusClear call flow and speech integration
SIP gateway or carrier edgeSignaling and media interworkingCodec and session border controller compatibility
Outbound dialingOriginates and bridges callsCalling-hour rules, retry limits and consent records
AI voice agentMedia edge plus application controlLow latency and no unnecessary transcoding

Every row works for the same reason. Asterisk is good at moving, mixing and controlling calls while the business logic lives somewhere else, like a railway yard that routes the cars but never becomes the cargo. It shines when call logic must be custom or when you mix several carriers and old hardware, and it is a poor match when nobody on staff wants to patch Linux servers or read SIP traces.

Picture a medical clinic's appointment line. Asterisk answers the call, plays a greeting and routes urgent requests to the front desk, while the scheduling rules and the patient calendar stay in a web application that talks to Asterisk over an API. Asterisk moves the call and your app runs the rest. Before choosing a design from the table, settle who will patch the servers at night and which carrier will supply your SIP trunk.

How Asterisk sits under an AI voice agent

Connecting a language model to a live phone line looks nothing like setting up a desk phone. You stream audio out of a call, turn speech into text, generate a reply and play audio back within a few hundred milliseconds.

Every live turn on that call moves through five steps. A caller dials your number and the carrier sends the SIP invite into Asterisk over a SIP trunk. Asterisk answers, agrees on an audio codec with the carrier and opens an RTP media stream. Then comes the media handoff, where Asterisk bridges the channel or sends its live audio to an outside application under ARI control while it pushes channel events. Your application passes the audio to speech-to-text (STT), sends the transcript to a language model (LLM) and turns the reply back into audio with text-to-speech (TTS). That audio streams back onto the caller's channel, and the application logs latency, transcript and call state for the turn.

The Asterisk ARI documentation describes ARI as an asynchronous interface for building your own communications applications instead of relying on built-in dialplan behavior. It exposes channels, bridges, endpoints and media as objects, sends state changes as JSON events over a WebSocket, and recommends putting your own application server in front of Asterisk for security, logging and multi-tenancy. That sets a clear boundary. Asterisk is your programmable telephony and media edge, handling SIP signaling and RTP audio, while your application owns authentication, tenant isolation, workflow state, model calls and observability. Keeping that logic out of Asterisk stops the voice server from turning into a brittle monolith.

For the orchestration layer itself, you can compare AI agent software options from AI Tool Seekers to see which runtime features match your stack, then map the telephony plumbing with our guide on integrating voice agents with your stack.

A classic mistake is building the conversation inside dialplan scripts. Dialplan is fine for a touch-tone menu like "press 1 for billing", but turn-taking, interruptions and API lookups belong in application code driven through ARI, with AMI kept for monitoring. Watch codec alignment between the carrier trunk and the speech pipeline as well. Converting audio back and forth burns CPU on every active channel, and heavy transcoding often becomes the first bottleneck, long before SIP signaling runs out of capacity.

Sizing a server around codecs and jitter

No single number tells you how many calls one Asterisk server carries. Codec choice, transcoding, network layout and call patterns change the answer, so published figures are a starting point for your own test.

Lab measurements in a Tecnico Lisboa Asterisk performance evaluation, run on a standard PC with short load tests, show how much the codec path matters.

Test on one standard PCReported valueWhat it tells you
Simultaneous G.711 calls, same codec both sides125Baseline for codec comparisons
Simultaneous iLBC calls, same codec both sides145, about 13.8 percent moreCompression shifts load from bandwidth to CPU
G.711 on one side, GSM on the other50, about 60 percent fewerThe cost of transcoding on every call
Average jitter on the G.711 test5.59 msHealthy delay variation on a clean network

Moving from G.711 to iLBC raised capacity from 125 to 145 calls in that test, because the codec changes the balance between bandwidth and processing. The bigger swing came from mixing codecs. When the caller's side used G.711 and the far side used GSM, Asterisk had to convert every packet and the same machine carried only 50 calls. In that test, transcoding cut capacity more than any codec choice.

Two side-by-side views of the same Asterisk server on a standard PC. On the left, audio arrives as G.711 and must leave as GSM, so every packet passes through a converter inside the server, and the machine carries 50 calls at once. On the right, the same codec is used on both sides, the audio needs no conversion on the way, and the same machine carries 125 calls at once. A line at the bottom says adding RAM rarely fixes a load test that fails on audio quality.
A call that needs converting spends CPU for as long as it runs, so one mismatched trunk taxes every call on it. List the codec of each leg and remove conversions before you size up the server.

Average jitter only says the network looks healthy on paper. Tail jitter, read at a high percentile or the maximum, says whether callers hear clipped, robotic audio, so alert on the tail instead of a smooth five-minute average.

Run your own load test before customers reach the box. Write down every codec on the trunk and inside the system, and whether any leg forces transcoding. Mirror real traffic, with realistic call length, setup rate and peak bursts, and measure CPU, packet loss and RTP jitter together to see which saturates first. Leave headroom and scale out behind a SIP proxy like Kamailio well before CPU hits the red line. Adding RAM rarely fixes a load test that fails on audio quality. Removing needless codec conversions, tuning jitter buffers or capping channels per server usually does.

Security duties you take on with Asterisk

Running Asterisk makes your team responsible for patching, exposed ports and toll fraud from the first day. Two test phones ringing each other is where the operating work starts.

The CyStack Asterisk vulnerability database keeps listing new Asterisk advisories, many of them rated high or critical, which is why security can't be a one-time setup task. Public code helps security teams audit behavior, but your team owns the patching and hardening.

Start by separating public telephony traffic from internal control. Only SIP signaling and RTP media toward approved carriers and remote endpoints belong on internet-facing interfaces, and SIP should accept signaling only from known carrier ranges or authenticated proxies. Keep AMI and ARI on private networks or behind a hardened, authenticated reverse proxy so nobody outside can take over live call control. Turn off modules your workload doesn't need, and rotate SIP and API secrets on a schedule, since weak or static extension passwords remain the fastest way in.

Toll fraud deserves its own alert. Set alerts on sudden spikes in international or high-cost outbound calling, the classic sign of an overnight compromise. Write down emergency patch triage and rollback steps before an urgent CVE lands, so the on-call engineer isn't improvising during an outage. Keep system logs, SIP traces and call detail records off the server, so you still have clean evidence if a node is compromised.

Picking a release, staging upgrades and going live

Choosing an Asterisk release is an engineering decision, because defaults, security algorithms and optional modules change between releases. Skipping that check is how teams end up with broken transfers and silent calls.

Coverage in the Enable Security RTCSEC newsletter shows how security and interoperability meet. Asterisk added RFC 8760 support, which replaces legacy MD5 digest authentication with SHA-256 and SHA-512/256. It is a welcome upgrade that still needs coordinated changes across endpoints, carrier trunks, session border controllers (SBCs) and older hardware. Before picking a release, confirm it matches your carriers' and SBCs' SIP transport, TLS and NAT settings, and keep a written list of loaded modules so you can tell at once whether a new advisory touches you. Find every device that still needs MD5 so you can upgrade, bridge or retire it before you enforce SHA-256 or SHA-512/256.

Never test a version jump on live customer traffic. Stand up a staging server with the target release and the exact module list, test every call path for each device class, including transfers, and rehearse the rollback from your previous configuration files and database snapshot. Then schedule the cutover outside peak hours with carrier support contacts ready, and upgrade production only once every legacy endpoint and trunk has passed staging or has a retirement date.

The go-live decision comes down to who runs the server. Raw Asterisk suits teams that need custom call logic and have engineers who can patch Linux telephony servers, a managed voice service suits standard calling needs, and an open-source voice agent platform suits teams that want programmable AI agents without building every media hook themselves. Go live once the carrier's trunk requirements are confirmed, the codec path is clean, a load test at peak concurrency passes on tail jitter, and staging and rollback are rehearsed. Hold the rollout if nobody can own the security runbook for patching, credential rotation, module audits and toll-fraud alerts.

Join the Dograh Community

Dograh is an OSS alternative to Vapi. Join our Slack community for queries, releases, best practices & community interactions.

Connecting Asterisk to an AI agent with Dograh

Dograh is the orchestration layer that runs the call flow, tools and telephony, and the speech and language models are a separate layer you choose. With Asterisk it plays the application role described above. Your dialplan sends calls into a Stasis application whose name is generated when you save the configuration, each call arrives as a StasisStart event on the ARI WebSocket, and the platform answers it and bridges the caller to an external media channel that streams the audio. The Asterisk ARI integration guide lists the Asterisk settings, and our step-by-step build on Asterisk walks through a first test call.

That media channel carries G.711 μ-law, so the trunks and endpoints that reach the agent must allow ulaw, and a trunk that already uses it needs no conversion on the way, which matters given the transcoding cost above. Each extension maps to its own agent through its Inbound workflow setting, and outbound calls follow a Dial String Template. On FreePBX the template Local/{number}@from-internal lets your existing outbound routes pick the trunk, as our FreePBX setup guide shows. Transfer Call works on Asterisk ARI as well. Dograh calls the destination first and connects the caller only when someone answers.

Where you run the platform decides what stays on your network. Self-host Dograh beside Asterisk and the ARI port never needs to face the internet, which fits the hardening advice above. Call audio and transcripts stay on your servers only when the speech and language models run there too. With your own key for a hosted model, the contract is between you and that provider, and the audio still reaches its servers. Dograh's other telephony providers include Twilio, Vonage, Telnyx, Plivo, Vobiz, Exotel and Cloudonix, for teams that want a carrier connection without a PBX in between.

Self-hosting the platform means no per-minute platform fee. Servers, model keys and phone minutes still cost money, and your team looks after the database and upgrades, much like the Asterisk duties in this guide. Support comes from the open-source community, and Enterprise adds custom SLAs. Dograh Cloud runs it for you for a 1¢-a-minute platform fee. The code is open under the BSD 2-Clause license, and Dograh is the place to start, with one test extension routed into the Stasis application.

Glossary

ARI
The Asterisk REST Interface. Outside code uses it to answer, bridge and control live calls, and it sends call events back over a WebSocket.
Transcoding
Converting call audio from one codec to another on the server. It costs CPU on every channel that needs it.
Tail jitter
The worst variation in packet arrival times, read at a high percentile or the maximum. Callers hear it as clipped or robotic audio.
Toll fraud
Attackers using a compromised phone system to place expensive calls, often international and often overnight when nobody is watching.

Frequently Asked Questions

Built with Outrank tool

Get started with Dograh

Build, deploy, and scale AI agents with Dograh. Join the community of developers building the future.