The PIOPIY WebRTC SDK for Javascript enables high-quality voice communication directly within the browser. It supports making and receiving calls to PSTN (Public Switched Telephone Network), App-to-App, and Browser-to-Browser.
- Crystal Clear Audio: High-fidelity WebRTC-based voice.
- Cross-Platform: Seamless communication between browsers and traditional phones.
- Rich Call Control: Mute, Hold, Transfer, and DTMF support.
- Metadata Support: Extract custom SIP headers and transfer information.
npm install piopiyjsyarn add piopiyjsCreate a new PIOPIY instance with your configuration.
import PIOPIY from 'piopiyjs';
const piopiy = new PIOPIY({
name: "Display Name",
debug: false,
autoplay: true,
ringTime: 60,
});| Attribute | Description | Type | Default |
|---|---|---|---|
name |
Your display name shown to other parties | string | none |
debug |
Enable detailed console logging for troubleshooting | boolean | false |
autoplay |
Automatically handle and play remote audio streams | boolean | true |
ringTime |
Maximum duration for an incoming call to ring (seconds) | number | 60 |
Connect to the PIOPIY SBC using your account credentials.
piopiy.login("user_id", "password", "SBC_URI");| Region | SBC URI |
|---|---|
| Asia | sbcsg.telecmi.com |
| Europe | sbcuk.telecmi.com |
| America | sbcus.telecmi.com |
| India | sbcind.telecmi.com, sbcindncr.telecmi.com |
Initiates an outgoing call to a PSTN number or another extension.
phone_number: The target number in E.164 format (e.g.,13158050050).options: (Optional) JSON object containingextra_paramfor webhook headers.
Returns the unique identifier for the current active call.
- Returns: A
string(UUID or SIP ID) orfalseif no active call exists.
Tip
Use this method to track calls or interact with the PIOPIY REST API.
Answers an incoming call.
Rejects/Disconnects an incoming call.
Hangs up an ongoing call.
Places the active call on hold or resumes it.
Mutes or unmutes your local microphone.
Sends a DTMF tone (0-9, *, #) to the remote party.
Transfers the call to another agent or number.
Transfers the call to a specific team or group.
Disconnects from the SBC session.
The SDK uses an event-driven architecture. Listen for events using .on(eventName, callback).
login: Triggered upon successful authentication.loginFailed: Triggered when authentication fails (e.g., code 401: Invalid credentials).logout: Triggered when the user logs out successfully.
inComingCall: Triggered when a new call arrives.
piopiy.on("inComingCall", (data) => {
console.log("Caller:", data.from);
if (data.team_name) console.log("Team:", data.team_name);
if (data.call_id) console.log("Unique ID:", data.call_id);
});| Payload Property | Description |
|---|---|
from |
Display name or number of the caller |
team_name |
(Optional) Name of the assigned team/group |
to_number |
(Optional) The target virtual number |
call_id |
Unique identifier for this call session |
transfer_from |
(Optional) Originating agent if this is a transfer |
transfer_to |
(Optional) Target agent if this is a transfer |
trying: The outgoing call is being initiated.ringing: The call is currently ringing.answered: The call has been picked up.ended: The call has concluded successfully.hangup: The call was terminated or rejected.error: A generic error occurred.
callStream: Triggered when the remote media stream is established.mediaFailed: Triggered if the SDK cannot access local audio devices.
The SDK includes built-in ESLint rules to ensure code quality.
# Run linter
npm run lint
# Auto-fix lint errors
npm run lint:fixApache-2.0 © TeleCMI