question

Mike Charles avatar image
Mike Charles asked Mike Charles answered

How to create WebPhone with javascript SDK

Hi Team, We are using Ringcentral javascript SDk to make and receive calls. We did the authorization with java SDK and saved required tokens and using the same tokens in javascript sdk using below code platform.auth().setData(tokens); But here I confused on how to get the WebPhone from the platform object. Could you please provide me the code to create a WebPhone after setting the tokens to platform.

sdk
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered Mike Charles commented

To implement a Web phone using Javascript, use the RingCentral Web phone SDK.

1 comment
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Hi Phong,

Thanks for your response. I am using the same SDK. But i got confused on how to create a Webphone without login function. I am using platform.auth().setData(tokens) to set the saved tokens instead of login. Then I am not getting how to create the Webphone from the platform

0 Likes 0 ·
Phong Vu avatar image
Phong Vu answered

This is the modified version of the example code on Github:

var appKey = '...';
var appSecret = '...';
var appName = '...';
var appVersion = '...';

var sdk = new RingCentral.SDK({
    appKey: appKey,
    appSecret: appSecret,
    appName: appName,
    appVersion: appVersion,
    server: RingCentral.SDK.server.production // or .sandbox
});

var remoteVideoElement =  document.getElementById('remoteVideo');
var localVideoElement  = document.getElementById('localVideo');

var platform = sdk.platform();
platform.auth().setData(tokens)
if (platform.loggedIn()){
    platform.post('/client-info/sip-provision', {
          sipInfo: [{transport: 'WSS'}]
    })
    .then(function(res) { // Doing nested then because we need loginResponse in a simple way
        return new RingCentral.WebPhone(res.json(), { // optional
              appKey: appKey,
              appName: appName,
              appVersion: appVersion,
              uuid: loginResponse.json().endpoint_id,
              logLevel: 1, // error 0, warn 1, log: 2, debug: 3
              audioHelper: {
                  enabled: true, // enables audio feedback when web phone is ringing or making a call
                  incoming: 'path-to-audio/incoming.ogg', // path to audio file for incoming call
                  outgoing: 'path-to-audio/outgoing.ogg' // path to aduotfile for outgoing call
              },
              media:{
                  remote: remoteVideoElement,
                  local: localVideoElement
              },
              //to enable QoS Analytics Feature
              enableQos:true
          });

    })
    .then(function(webPhone){

        // YOUR CODE HERE
        
    })
}


1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Mike Charles avatar image
Mike Charles answered

Thank you Phong Vu. your answer was very helpful for me. I had completed the integration and everything is working fine. But I didn't find any option to dismiss/reject the call in RingCentral Web phone SDK.

This is the way I am initiating the call.

var session = webphone.userAgent.invite(toNumber, {

fromNumber : fromNumber

});


And one more doubt is I am not able to record the calls. Do we need a paid account to enable Call Recondings or can we test with the sandbox account?


The last doubt is Do we need the RingCentral paid plan to apply for production? When I am trying to apply for production its showing the messege as below.
https://i.snipboard.io/TO3pqe.jpg

Please help me to solve these confusions.

Thanks,

Mike

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys