A PBX, or private branch exchange, is a business's phone switch. It gives each person an extension, shares a few outside lines or a SIP trunk among them and routes calls through menus, groups and queues. Dograh, the open-source AI voice agent platform, can sit beside it, and you can self-host it or run it on Dograh Cloud.
Key Takeaways
- An extension is an internal number, and a trunk is the shared line outside.
- Hosted PBX costs less upfront, while on-premise can cost less over time.
- An AI agent can be one more PBX extension or answer on the trunk first.
Every office phone with a three-digit extension sits behind a PBX, even when nobody calls it that. We explain what a PBX does, extensions, trunks and routing, the on-premise, hosted and IP types, and the cost trade-off, then we talk about how a Dograh agent sits beside one.
What a PBX does
A PBX is the private phone exchange that sits between a company's phones and the public phone network. The ATIS telecom glossary defines it as a subscriber-owned exchange that usually includes access to the public network, and as a private switchboard that provides on-premises dial service. In plain words, it is the business's own small phone company.
It does two jobs. Inside the building, it connects people to each other, so dialing 204 rings the desk next door without the call ever leaving the office. Toward the outside world, it shares a small number of outside lines among many phones. Twenty staff rarely all talk to customers at the same moment, so a PBX lets them share four or five lines instead of renting twenty.

Everything else a business phone system does sits on top of those two jobs. Transfers, hold music, voicemail, call recording and phone menus are all PBX features. A contact center adds queues, agent desktops and reporting on top of that, which is the layer our explainer on what CCaaS is covers.
Extensions, trunks and outside lines
An extension is an internal number for one phone, one person or one group. Staff dial it directly, usually as three or four digits, and the PBX knows which handset, app or voicemail box it belongs to. Extensions cost nothing to call because those calls never leave the system.
A trunk is the connection to the outside. ATIS defines a trunk as a single transmission channel between two switching centers or nodes. Older PBXs used copper lines or a PRI circuit from the carrier. Most new systems use a SIP trunk, which carries calls over the internet, and its capacity is set in channels, one call each. Our explainer on what SIP trunking is follows one call through a trunk.
Numbers connect the two. The carrier sends calls for each of your phone numbers down the trunk and tells the PBX which number was dialed, so a direct number can ring one person's extension without an operator in between. Those direct numbers are DIDs, and our post on what a DID number is explains how they are bought and routed.
How a PBX routes a call
Routing is the set of rules that decides where each call goes. For an incoming call, the PBX first looks at the dialed number and picks an inbound route for it. That route can check the time, sending calls to the main menu during opening hours and to voicemail or an answering service at night.
From there the call reaches a destination. An IVR menu asks callers to press or say an option. A ring group rings several phones at once, or one after another, until someone picks up. A queue holds callers in order and passes each one to the next free person, with hold music meanwhile. Any of these can end in voicemail if nobody answers.
Outgoing calls follow outbound routes. The PBX matches the digits a person dials against patterns, such as local, long distance or international, and picks the trunk and caller ID for each. That is how one office can send emergency calls on one carrier, international calls on another, and show a different number for sales and support.
Open Source Alternative to Vapi / Retell
Self-hosted voice agent platform — no per-minute fees
dograh-hq/dograh
Star on GitHub
On-premise, hosted and IP PBX
PBX types differ in where the switch runs and who looks after it. A traditional on-premise PBX is a box of hardware in a cupboard, wired to desk phones and to copper or PRI lines. An IP PBX runs as software on a server and talks to phones and trunks over the network. Asterisk, an open-source project, describes itself as a toolkit for building many things, an IP PBX among them, and FreePBX is a common interface built on it. A hosted PBX, often called a cloud PBX, runs in the provider's data center and you rent it per user.
| Traditional on-premise | IP PBX on your servers | Hosted (cloud) PBX | |
|---|---|---|---|
| Where it runs | Hardware in your building | Software on your own server | The provider's data center |
| Who maintains it | Your team or an installer | Your team | The provider |
| Outside lines | Copper or PRI lines | SIP trunks, sometimes PRI cards | Included, or your own trunk |
| How you pay | Hardware upfront, then service | Server and trunk minutes | A monthly fee per user |
| Change a call flow | Installer or admin console | Admin console or config files | Provider's web portal |
Many businesses run a hybrid. The PBX stays on-premise for control, and a SIP trunk replaces the old copper lines, which is the setup most AI agents connect to today.
On-premise vs hosted cost and upkeep
The choice between on-premise and hosted is mostly a choice about cost over time and who does the upkeep. RingCentral, which sells hosted phone systems, says an on-premises PBX has a higher setup and installation cost but reduces expenses over time, while hosted has a lower initial cost but a monthly fee that makes it more expensive in the long run.
The upkeep follows the same line. On-premises, your team runs the hardware, the space, the backups and the security patches, and a failed box can stop calls unless a SIP backup route exists. Hosted, the provider does that work, and call quality depends on your internet connection. Features and customization are also limited to what the provider offers.
A small office with no IT staff usually leans hosted. A larger one, or one with strict rules on where call audio goes, often keeps an IP PBX it controls.
Join the Dograh Community
Dograh is an OSS alternative to Vapi. Join our Slack community for queries, releases, best practices & community interactions.
Where an AI voice agent sits beside a PBX
An AI voice agent fits into a PBX the same way any other destination does. The phone system stays, and the agent becomes one more place its routing rules can send a call, usually in one of two shapes.
In the first, the agent sits behind the PBX as an extension or a route target. The PBX keeps answering every call, and its rules send chosen calls to the agent, such as after-hours calls, overflow when every ring group member is busy, or one menu option like order status. When the caller needs a person, the agent hands the call back to an extension or a queue. Your existing phones, numbers and routing stay in charge.
In the second, the agent sits in front, on the trunk side. The carrier sends calls on certain numbers straight to the agent, which handles them and transfers the rest into the PBX. This suits a new line, such as a booking number, without touching the main phone system. Both shapes usually run over a SIP trunk, which in our experience is the most reliable path for production phone traffic.
Connecting a PBX to Dograh
An Asterisk-based PBX, FreePBX included, connects to Dograh through Asterisk ARI, on Dograh Cloud or on a self-hosted install. Setup moves between the two systems in four parts.
First, in Asterisk you create an ARI user, turn on the HTTP server and add a WebSocket client for the audio. Second, you enter those values in the new telephony configuration and save, which generates a Stasis App Name. Third, you put that name in the Asterisk dialplan and reload. Fourth, you register the extensions that should reach an agent as phone numbers and place a test call. Use Asterisk 22.8 or later, or 20.18 or 23.2 on those release lines, since every call uses a WebSocket option those releases added. Our guide to connecting an existing PBX to an AI voice agent walks through each step.
Other PBXs, such as 3CX or a hosted system, reach the agent by forwarding calls to a number on a carrier account connected to Dograh, or over a trunk into your own Cloudonix account. Our post on the SIP trunk for 3CX shows that route.
Handing the call back works through Transfer Call. On ARI the destination is a SIP endpoint such as PJSIP/1001, and Dograh calls the destination first and connects the caller only when someone answers. Outbound campaigns on an ARI configuration can dial extensions and SIP addresses as well as phone numbers.
Self-hosting Dograh with ARI means no per-minute platform fee, but servers, model keys and the carrier's trunk minutes still cost money, and your team looks after the database and upgrades next to the PBX. Dograh Cloud runs the agent side for a 1¢-a-minute platform fee instead, and the code behind both is BSD 2-Clause open source.
Glossary
- Extension
- An internal number on a PBX for one phone, person or group. Calls between extensions stay inside the system and never use an outside line.
- Ring group
- A PBX destination that rings several extensions at once or in turn until one answers, often used for a sales or front desk team.
- Inbound route
- The PBX rule that matches the dialed number of an incoming call and decides its first destination, such as a menu, a ring group or voicemail.
- Stasis App Name
- The name of the Asterisk dialplan hand-off that passes a call to an outside program over ARI. Dograh generates it when you save the configuration.

