Overview

WavetelRTC is a lightweight JavaScript wrapper to easily integrate SIP calling into your browser-based applications. This documentation explains how to load the library, initialize it, handle events, and implement a complete softphone UI.

1. Including the Library

Simply load the compiled UMD version of the wrapper in your HTML:

Json ▼
 <script src="https://webphone.wavetelbusiness.co.uk/webphone/wavetel-rtc.umd.cjs"></script>
  

This exposes a global class WavtelRTC for you to use.


2. Initializing the Client

Create a new instance by passing the required authentication parameters:

JavaScript ▼
const rtc = new WavtelRTC({
  api_key: "YOUR_API_KEY",
  username: "SIP_USERNAME",
  password: "SIP_PASSWORD",
});
  

After that, call:

JavaScript ▼
await rtc.init();
  

This starts the RTC session and performs SIP registration.


3. Event Listeners

Your application should listen to various WebRTC/SIP events that WavtelRTC emits.

Registration Events

JavaScript ▼
rtc.on("login_failed", (message) => { ... });
rtc.on("registered", () => { ... }); rtc.on("disconnected", () => { ... });
  • Fired when SIP registration succeeds or fails.

Call Flow Events

JavaScript ▼
rtc.on("incomingcall", ({ jsep, caller }) => { ... });
rtc.on("ringing", () => { ... });
rtc.on("answered", () => { ... });
rtc.on("failed", () => { ... });
rtc.on("hangup", () => { ... });
  
  • Provides complete lifecycle of any call.

  • incomingcall contains jsep required for answering.

Hold / Resume Event

JavaScript ▼
rtc.on("hold", (isOnHold) => { ... });
  

4. Making Calls

JavaScript ▼
rtc.call("NUMBER");
  

This sends an outgoing SIP INVITE.


5. Answer, Reject, Hangup

Answer incoming call

JavaScript ▼
rtc.answer(incomingJsep);
  

Reject incoming call

JavaScript ▼
rtc.reject();
  

Hangup active call

JavaScript ▼
rtc.hangup();
  

6. Hold & Resume

JavaScript ▼
rtc.hold(true);  // Hold
rtc.hold(false); // Resume
  

7. Blind Transfer

JavaScript ▼
rtc.transfer("DESTINATION_NUMBER");
  

8. Example: Minimal Implementation

HTML ▼
<script>
let rtc = new WavtelRTC({ api_key, username, password });

rtc.on("login_failed", () => console.log("Invalid Credentials")); rtc.on("registered", () => console.log("Registered")); rtc.on("incomingcall", ({ jsep, caller }) => rtc.answer(jsep)); await rtc.init(); rtc.call("12345"); </script>

9. UI Helper Notes (From Demo)

The demo shows how to:

  • Display dialpad

  • Show live call timer

  • Animate incoming call popup

  • Update connection status badges

  • Manage call states

You may use the same UI or customize as needed.


10. Full Demo Included

The provided demo HTML contains:

  • Login screen

  • Complete softphone interface (dialpad, call buttons, transfer, hold, resume)

  • Incoming call popup

  • Call timer

  • Real-time call state updates

You can modify the UI while keeping the same WavtelRTC method calls.


11. Summary of Public Methods

Method Description
init() Initialize RTC session and register SIP
call(number) Make outgoing call
answer(jsep) Answer incoming call
reject() Reject incoming call
hangup() Terminate call
hold(boolean) Hold/resume call
transfer(number) Blind transfer call
on(event, callback) Listen for events

12. Supported Events

Event Description
login_failed When login failed due to Invalid credentials, Invalid API Key or IP Blocked
registered SIP registered
disconnected SIP disconnected
incomingcall New incoming call
ringing Remote ringing
answered Call answered
failed Call failed
hangup Call terminated
hold Hold/resume notification

13. Notes

  • Must be hosted on HTTPS.

  • Requires microphone permissions.

  • Works on Chrome, Edge, Firefox.

  • When user fails to login 3 times in a row then user's IP will be blacklisted, to unblock the IP you need to contact our support at support@wavetelbusiness.co.uk

For further integration help or bug reporting, contact the Wavetel team.

If you need a demo Webphone then we have created a sample/demo application which can be found here:

https://webphone.wavetelbusiness.co.uk/webphone/webphone.html