Resources
- npm package: vobiz-webrtc-sdk
- Starter kit: vobiz-ai/Vobiz-RTC-demo - a Node.js answer-URL backend and a browser softphone built on the SDK
- Try it without code: WebRTC Playground
- SIP library: vobiz-ai/vobiz-jssip (npm), bundled into the SDK
- Release notes: CHANGELOG.md
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 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
callerIdon<Dial>to a number your account owns. Without a valid caller ID the call fails and the browser receivesonCallFailed. - 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.
<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()andunhold()returntruewhen the request is sent. They returnfalsewhen there is no answered call, or while another hold or resume is still in progress.hold()on a call that is already held returnstrueand sends nothing.onCallHoldandonCallResumefire 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(). Callingunmute()while on hold takes effect when the call resumes.
Events
Upgrade notes
Runnpm 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.