Skip to main content

Introduction

The Plivo Browser SDK lets you make and receive calls using Plivo applications directly from any web browser. Using our SDK, you can create applications such as:
  1. Call Center — Build efficient call center workflow by allowing your agents to make and receive calls via their browsers. Control call flow in your app using our API.
  2. Click to Call — When adding click to call for your CRM app, Plivo runs seamlessly in the background to allow your users to interact via audio communication.
  3. Web-Based Help Desk — Create great service experiences and workflows. Sales and support agents can access customer info while making calls directly from their web browsers.
  4. Web Conferencing — Build rich conference experiences with Plivo’s out-of-the-box features, including unique call flows, recording calls, and branded conference greetings.

How does it work?

  1. From a browser, a Plivo endpoint initiates an internet call to Plivo’s voice platform.
  2. The platform notifies your application server about the call.
  3. Plivo handles the call based on XML documents returned by the application server. In this case, a Dial XML element connects the call with the phone number specified in the XML document.
  4. Plivo initiates a call to the phone number specified in the Dial XML element.
  5. Once the call is answered, the two parties are connected and can talk to each other.
To learn more about managing the call flows and types of call flows, refer to our Voice Overview guide.

Supported browsers

This table shows the browsers supported by the Plivo Browser SDK. Chrome and Firefox: We support the most recent and previous 10 versions.
Safari: We support the most recent and previous five versions.
* Unlike Safari for iOS, Chrome and Firefox for iOS do not have access to WebRTC APIs. ** Safari for Windows and Linux are not supported. *** Edge for Linux is not supported.
Note: On mobile browsers, Browser SDK functionality may be compromised due to limitations imposed by browsers. These limitations include inability to maintain call connectivity if the browser moves to the background, inability to receive incoming call notifications in case the browser was in background, and inability to handle GSM call interruptions. As a result, we highly recommend that you evaluate our mobile SDKs (iOS, Android) while creating mobile voice apps for better user experience.For mobile applications, we recommend using our native iOS and Android SDKs. See our SDK FAQ for more details on browser limitations.
The Browser SDK codebase is publicly available on GitHub.
Browser SDK supports TypeScript (version 4.0.3 and higher).
Try out the demo — get started with examples.

Installation

You can include the Plivo-Browser-SDK NPM package as a dependency in your project. Use the below command:
Also, you can include the latest Plivo-Browser-SDK Beta NPM package using the below command:
After installation, import the SDK in your application:
You can include the plivo javascript file as shown below directly on your webpage
Note: We do not recommend this approach because any recent changes to our SDK will be applied to your production apps automatically without going through your build process and could lead to unexpected behavior for your customers.To mitigate this risk, every new release is first pushed to this beta CDN link before being merged to the master: <https://cdn.plivo.com/sdk/browser/v2/plivobeta.min.js>
Alternatively, you can include a specific release in your app by using it’s specific CDN link. We continue to make our past releases URI accessible and immutable, unless explicitly stated. You can find the latest links on the Changelog section.

Quick Start

Initializing the plivoBrowserSdk Object

The plivoBrowserSdk object needs to be initialized.
For more explanation on options see the Configuration Parameters section.

Event registration

Pass function references to the events produced from the SDK. This is where your UI manipulation should handle the call flows.

Registering using your Plivo endpoint

Register using your Plivo endpoint credentials

Making a call

Making a call to any number/SIP endpoint. The application attached to the registered endpoint should have an answer URL that will return the correct <Dial> element.

Accepting a call

This is how an incoming call should be answered when an onIncomingCall event is received.
callUUID is passed in the onIncomingCall event callback, as we describe in the Reference documentation.

Sending DTMF

This snippet sends a DTMF tone when in a phone call.

Configuration Parameters

Note: enableTracking will be deprecated as part of the next major update. Please use use enableQualityTracking instead.
Note: If enableQualityTracking is configured with a nondefault value, it overrides any configuration of enableTracking.
Note: If clientRegion is not defined, the nearest Plivo data center (PoP) will be picked based on the Browser SDK client registered IP address.

Best Practices for Call Quality

VoIP call quality is influenced by several factors, including device software and hardware and the network a device is connected to. Here we explore the key factors that influence call quality on Browser SDK calls, and offers recommendations for improving call quality.

Network Characteristics

The network the device runs on has a big influence on call quality thanks to factors such as jitter and latency.

Jitter and Latency

VoIP calls involve the transmission of a continuous train of voice data packets. If the network is congested, some of the first packets sent may reach a recipient later than other packets. This out-of-order receipt of packets, known as jitter, can result in the audio sounding jumbled or robotic. Jitter is measured in milliseconds of delay, and jitter values higher than 30 milliseconds on WebRTC calls can lead to poor audio quality. High network congestion can also lead to packet loss, resulting in chunks of audio never reaching the intended recipient. Latency, in the context of VoIP calls, is the spoken-to-heard delay in the transmission of audio. The major contributing factor to VoIP latency is the delay incurred in the transmission of voice packets from origin to destination. When this network latency is more than 300 milliseconds of round-trip time, call participants can experience audio lag.

Recommendations

To minimize network and device issues and improve call quality, Plivo recommends:
  • Using a high-bandwidth fiber connection from a reputed internet provider. Dedicated business internet connections generally come with guaranteed SLAs on bandwidth and latency.
  • Using a physical Ethernet connection instead of Wi-Fi when possible.
  • If using Wi-Fi, limiting the number of devices connected on the same channel.
  • Using high-quality Wi-Fi routers built for enterprises or real-time gaming. Look for routers that come with advanced QoS features.
  • Auditing your network firewall and NAT settings to check for transmission delays due to improper configuration.
  • Avoiding large data transfers on the Wi-Fi network during calls.
  • Limiting bandwidth per connected device to ensure an even allocation of total available bandwidth.
  • Avoiding calls over cellular data connections (4G and older) as they are not optimized for low-latency traffic.
  • Setting the Differentiated Service Code Point (dscp) parameter of Plivo Browser SDK to “true.” DSCP for WebRTC is supported by Chrome only. It informs network routers to prioritize voice packets over other network packets. Corresponding QoS configurations in the router may be also required.
  • Setting Plivo Media Server region selection in auto mode of the Browser SDK. This ensures that calls get routed through the closest geographic PoP based on the device’s IP address.
  • Ensuring uplink and downlink bandwidth availability of at least 50Kbps for voice transmission.
  • If operating in a low-bandwidth environment, capping the bandwidth to be consumed on the call using the maxAverageBitrate configuration parameter of the Browser SDK.
  • Gracefully handling poor call quality experiences in real time by consuming MediaMetrics call quality events emitted by the Browser SDK during the call.
  • Submitting call quality feedback to Plivo programmatically from the Browser SDK or through the Feedback API. Your feedback lets Plivo optimize its network by identifying patterns across calls.

Network Firewalls

Voice data on VoIP calls is transferred over UDP. Ensure that your network firewall allows the transmission of UDP packets between client devices and the public internet. If your firewall requires whitelisting of external IP addresses, make sure to whitelist Plivo’s SIP Signaling and Media Server IP addresses.

Device Characteristics

Certain software and hardware device characteristics have a direct impact on VoIP call quality.

Browser and OS

The Plivo Browser SDK is tested and supported only for the browsers listed in the Supported browsers section. Browser SDK uses WebRTC for voice calls on these browsers:
  • Chrome on Windows, Linux, macOS, and Android
  • Firefox on Windows, Linux, macOS, and Android
  • Safari 11+ on iOS and macOS
  • New Microsoft Edge (based on Chromium) on Windows
Chrome for iOS and Firefox for iOS don’t support WebRTC. Plivo highly recommends using our native iOS and Android SDKs to build app-based calling functionality on mobile devices. Mobile browsers would be required to be in the foreground for the entire duration of a call and lack call interruption handling for cellular calls received while on a browser call. Both these features are supported through the Plivo iOS and Android SDKs.

Device Hardware

While most modern PC and smartphone devices are more than capable of handling VoIP calls, incompatibilities between hardware components such as network drivers, audio cards, and other firmware components can result in unexpected issues with media handling. Attempting to reproduce issues on other devices should be a key step in your debugging process.

The Audio Input and Output Device

Plivo recommends using quality headsets for browser-based calls. Headsets minimize echo by providing acoustic isolation between the speaker and the microphone. High-quality VoIP headsets with noise-canceling features can greatly enhance call quality in noisy environments by eliminating background sounds. Wired headsets generally offer more stable sound quality than wireless or Bluetooth headsets. Wireless headsets are more prone to adapter and driver configuration issues, which can lead to static or white noise on calls. We recommend testing with a different headset, or with a built-in mic and speaker, when troubleshooting audio quality issues.

Next steps

Now that you know the fundamentals, you can build a simple app. Get inspiration from our sample applications and learn implementation details from our Browser SDK Reference documentation.