SIP vs WebRTC vs a Discord bot: how to call a phone
Every "call a phone from my computer" project picks one of three routes: a SIP client, a WebRTC bridge, or a finished bot with a SIP stack inside. All three produce a ringing phone, and they fail in completely different ways.
The three routes in plain words
SIP client (softphone). A desktop app registers directly with your provider, dials and handles the audio. Honest and simple, but it lives on one machine and belongs to one person.
WebRTC bridge. A web page captures your microphone over WebRTC, a server terminates that stream and re-originates the call towards the phone network through a gateway or second SIP leg. It looks elegant because there is nothing to install.
Bot with an embedded SIP stack. A headless service runs a real SIP endpoint, joins your voice channel as a participant and bridges the two media streams. In CallBot that is PJSUA2 (PJSIP) in a Docker container: nothing runs on your laptop, nothing depends on a browser tab.
Side-by-side comparison
| Criterion | SIP softphone | WebRTC bridge | Bot with SIP stack |
|---|---|---|---|
| Audio quality | Good; depends on the local network | Fair; two media conversions and browser jitter buffering | Good; one Opus to G.711 or G.722 hop per direction |
| Working behind NAT | Usually fine; the app handles it | Hardest part; needs ICE, STUN and often a TURN relay | Server-side, one steady registration |
| Recording and logs | Manual, per call, per machine | Retrofit: mixing browser streams never built for it | Built in: direction, number, duration, recording |
| Number of participants | One person per device | One browser session, awkward for a group | Whole voice channel; mute and mono mode keep order |
| Setup complexity | Lowest: install and type credentials | Highest: page, signalling, gateway, TURN, certificates | Low: add the bot, add SIP credentials, dial |
| Cost of ownership | Provider minutes plus a machine kept awake | Provider minutes plus gateway and relay infrastructure | Provider minutes plus one hosted instance |
| What breaks most often | The laptop sleeps, or the firewall blocks media | Permissions, TURN capacity, one-way audio | Provider limits: concurrency caps, blocked destinations, expired credentials |
Why the WebRTC bridge is a compromise
WebRTC is excellent at what it was designed for: browser to browser through NAT. The moment a call must reach the public telephone network, that elegance becomes plumbing.
- Extra conversions. Microphone to Opus, Opus to the gateway, gateway to G.711, then the carrier: every hop adds latency and one more place for audio to vanish.
- The tab problem. A page must stay open, awake and unsuspended, yet browsers deliberately slow background tabs, fatal for a call meant to last twenty minutes.
- NAT and ICE. The browser works hard to find a path, and the server still needs a relay or a public media port. Both fail quietly.
- Recording is a retrofit. Capturing both directions cleanly means mixing streams that were never meant to be mixed.
WebRTC is not wrong; it is a bridge, not infrastructure.
Why a full SIP stack holds up in production
A SIP stack is what the telephone network expects to talk to. PJSUA2 treats registration, dialog state, codec negotiation, RTP, DTMF and hangup as protocol work rather than logic you invent and debug. Headless in a container, the endpoint stays registered whatever anybody's laptop is doing.
Transcoding becomes a known quantity too: Discord's Opus on one side, the trunk's G.711 or G.722 on the other, at one point in the chain. That is the difference between a system you can reason about and a chain where any link may be the culprit.
Choosing for the long run
The subscription is the smallest line in the budget. The real cost is the hours keeping the path alive: a softphone needs a machine that never sleeps, a WebRTC bridge needs a gateway, a relay and someone who understands ICE, a bot needs only a SIP account.
Pick the route whose failure you could debug at two in the morning. For a community server that dials real numbers regularly, that is the route where SIP is first-class and no browser stands in the middle of every call.