question

Trent Grandey avatar image
Trent Grandey asked Phong Vu answered

Trying to test CallOut in the Sandbox

I am trying to test the CallOut API in a new app I'm developing. I've gotten pretty far. I have installed the RC Phone and can call into that phone with the sandbox account phone number.


So back to my app, I need to get the deviceId of that RC Phone. To get the deviceId, I need the extensionId. So I've called the GetExtensionList and I do get the info on my one sandbox extension. I don't see an extensionId. Given some of the other posts I've read and the urls that are shown on the api calls, I see them using the accountId as the extensionId.

So, I've called GetDevice with https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/device and I've also tried with accountId in both places instead of the tilde. No matter what I try, the records value in the response is empty.

What am I doing wrong it trying to get the device to target? Any help would be greatly appreciated!

rest api
1 |3000

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

Her is all what you need to implement in Node JS. Let me know if you have problem or you want in other programming language.

const RingCentral = require('@ringcentral/sdk').SDK

RINGCENTRAL_CLIENTID = 'your-app-client-id'
RINGCENTRAL_CLIENTSECRET = 'your-app-client-secret'
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'

RINGCENTRAL_USERNAME = 'username'
RINGCENTRAL_PASSWORD = 'password'
RINGCENTRAL_EXTENSION = 'ext-number'

const rcsdk = new RingCentral({
  server: RINGCENTRAL_SERVER,
  clientId: RINGCENTRAL_CLIENTID,
  clientSecret: RINGCENTRAL_CLIENTSECRET
})

var platform = rcsdk.platform();

rcsdk.login({
        username: RINGCENTRAL_USERNAME,
        extension: RINGCENTRAL_EXTENSION,
        password: RINGCENTRAL_PASSWORD
      })

platform.on(platform.events.loginSuccess, async function(e){
    console.log("Login success")
    get_extension_devices()
});

async function get_extension_devices() {
  console.log("get_extension_devices")
  try{
    var resp = await platform.get('/restapi/v1.0/account/~/extension/~/device')
    var jsonObj = await resp.json()
    for (var record of jsonObj.records){
      if (record.status == "Online"){
        console.log(record.status)
        console.log(record.id)
        call_out(record.id)
        break
      }
    }
  }catch(e){
    console.log(e.message)
  }
}

async function call_out(deviceId) {
  var params = {
    from: {
      deviceId: deviceId
    },
    to: {
      phoneNumber: "phone number to call"
    }
  }
  try{
    var resp = await platform.post('/restapi/v1.0/account/~/telephony/call-out', params)
    var jsonObj = await resp.json()
    console.log(JSON.stringify(jsonObj))
  }catch(e){
    console.log(e.message)
  }
}


1 |3000

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

Anirban avatar image
Anirban answered Anirban commented

@Phong Vu Just curious to know if RC phone support any device id? As per the question, it seems device response is empty because of using RC phone.

If I check following ref:

https://community.ringcentral.com/questions/10052/callout-using-mobiledesktop-app.html

you clearly mentioned:

"The RC mobile apps and the RC Desktop app do not register a device id so that you cannot find it from the extension device list. "

Correct me if I am missing anything

3 comments
1 |3000

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 ♦♦ commented ·

Well, he needs to clarify what is that RingCentral phone. When he said RingCentral phone and he could test call to that phone with the sandbox account phone number. I guessed that is the RingCentral softphone app. Because that is the only phone that supports sandbox mode (not the RC app, nor the RingCentral mobile phone app).

Also, when he called GetDevice with https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/device, it refers to the sandbox and it must be the RingCentral softphone app which does register its device Id to the extension devices list.


0 Likes 0 ·
Trent Grandey avatar image Trent Grandey Phong Vu ♦♦ commented ·

I am referring to this app: https://www.ringcentral.com/apps/rc-phone

I'll SWEAR I saw a post last night that said to use this app because the RC Desktop app did not have a device id. I'm looking for that post now, amongst the 1000 or so that I read last night. :)

Thank you for your help!

0 Likes 0 ·
Anirban avatar image Anirban Phong Vu ♦♦ commented ·

make sense.. thank you

0 Likes 0 ·
Trent Grandey avatar image
Trent Grandey answered Trent Grandey commented

If there is no way to get a deviceId for any device in the sandbox, is there ANY way to test a CallOut from the sandbox? I have a Ring Central Poly phone. Is there a way to log that into the sandbox?

Any other ideas???

8 comments
1 |3000

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 ♦♦ commented ·

Unfortunately, that RingCentral Phone app does not register its device Id to the system. I wonder how you could login that RC Phone app with your sandbox account user's credentials. Or did I misunderstand that you logged in with your production account and receive incoming call from your sandbox number? Please clarify.

This is the only phone app (scroll to the RC Phone Desktop) that can be used with the sandbox account, provided you switch the app to "sandbox" mode (e.g. fn-command-f2 on Mac).

We are working on the possibility to have other RC app to register its device Id but it is not possible right now.

0 Likes 0 ·
Trent Grandey avatar image Trent Grandey Phong Vu ♦♦ commented ·

This is the app I'm using. I switched it to Sandbox and logged in with my sandbox credentials. I can call from my mobile phone to this sandbox number and that works fine.

So if this doesn't give a deviceId, then there is nothing else that works in the Sandbox that does give a deviceId?

If I want to test, do I create an app with CallControl and then test some other call control enough to get it promoted to production and THEN I can test CallOut?
1606241277488.png

0 Likes 0 ·
1606241277488.png (20.3 KiB)
Phong Vu avatar image Phong Vu ♦♦ Trent Grandey commented ·

Yes, this is the RingCentral softphone app (RC Phone Desktop).

Yes, you need an app with the CallControl permission to call the call-out API. My code shared above should work. If you still don't see the device Id, let me know your app client id.

0 Likes 0 ·
Show more comments
Phong Vu avatar image
Phong Vu answered

Here is the problem. You don't have a phone for your 101 user extension. Login your sandbox account, select the user -> numbers & phones and add a phone (select the RingCentral softphone) for your extension.

screen-shot-2020-11-24-at-20624-pm.png


1 |3000

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