Skip to main content
The Vobiz WebRTC SDK turns a browser tab into a phone. It registers with Vobiz over a secure WebSocket, places and receives calls, and gives you in-call controls: mute, DTMF, and hold/resume. Source code: vobiz-ai/vobiz-browser-sdk

Resources

Use 1.0.6 or later. In 1.0.5, hold() could drop an incoming call, and on outbound calls audio kept flowing while the call showed as held. See Upgrade notes.

Installation

Import it with import Vobiz from 'vobiz-webrtc-sdk' and create a client with new Vobiz(options).client. Add an <audio id="remoteAudio" autoplay> element to your page; the SDK plays the other party’s audio through it. TypeScript declarations are included.

Log in

Use one login method per user: onLogin fires once the browser is registered, and client.isRegistered() then returns true. A wrong password fires onLoginFailed. Never put your account Auth Token in the browser.

Make and receive calls

Outbound. client.call(number, extraHeaders) dials a number in E.164 format. Vobiz then requests the answer URL of the user’s application, which decides where the call goes, usually with <Dial>:
  • To reach a phone, set callerId on <Dial> to a number your account owns. Without a valid caller ID the call fails and the browser receives onCallFailed.
  • To reach another browser user, dial a Vobiz number whose application rings that user with <Dial><User>sip:USERNAME@registrar.vobiz.ai</User></Dial>. Dialing another user’s SIP address directly from the SDK is rejected.
Incoming. A call rings the browser when an application <Dial>s the user, or when you place a call to sip:USERNAME@registrar.vobiz.ai with the Voice API. The SDK fires onIncomingCall. Answer with client.answer(callUUID), decline with client.reject(callUUID), or stop ringing locally with client.ignore(callUUID). client.getIncomingCalls() lists ringing calls; when two ring at once, client.answer(callUUID, 'reject') answers one and rejects the other.

In-call controls

Hold and resume

Available from 1.0.6, on incoming and outbound calls, with either login method.
  • hold() and unhold() return true when the request is sent. They return false when there is no answered call, or while another hold or resume is still in progress. hold() on a call that is already held returns true and sends nothing.
  • onCallHold and onCallResume fire once Vobiz confirms the change. Update your UI on these events, not on the return value.
  • While the call is on hold, the SDK stops sending your microphone and you stop receiving the other party’s audio.
  • On resume, the microphone comes back on unless you muted the call with mute(). Calling unmute() while on hold takes effect when the call resumes.

Events

Upgrade notes

Run npm install vobiz-webrtc-sdk@latest. No code changes are needed. 1.0.6 fixes hold and resume. In 1.0.5, hold() on an incoming call dropped the call without onCallTerminated, after which unhold() and hangup() did nothing; on outbound calls the hold events fired but audio kept flowing. 1.0.6 also mutes the microphone while the call is on hold.

Next steps