question

Alex Rogers avatar image
Alex Rogers asked Phong Vu commented

Can I get DeviceId in Telephony subscription events?

I'm using the RingCentral.net SDK. I use basically this code to monitor for my extension's calls:
=================
string s1 = "/restapi/v1.0/account/{0}/extension/~/presence?detailedTelephonyState=true&sipData=true";

string s2 = "/restapi/v1.0/account/{0}/telephony/sessions";

// replace the IDs in the above strings (not shown)

await r.PubNubExtension.Subscribe(new[] {s1, s2}, Device.ParseSubscription);

=================
When I receive the events for the calls, I would like to know which actual device (handset) the call is happening on. I've seen in the traces for outbound calls that "DeviceId" appears in the "body.parties[0].from" field but this value doesn't come through the SDK. Also the value doesn't appear to be present (ie in ".to") for inbound calls.

Also, when making a call, then the deviceid is required to make the call (using CallOut)

So my question is:
Is it possible to get the actual device id for the handset involved in calls?

sdkdeveloper sandboxpubnub
1 |3000

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

vyshakhbabji avatar image
vyshakhbabji Deactivated answered Alex Rogers commented

What type of device are you using? Today you can only get device IDs for Softphone , Hard Phone devices via Device endpoint https://developers.ringcentral.com/api-reference/Devices/listExtensionDevices


Unfortunately , you will not be able to get deviceIDs for RC App or Web-phone apps .

1 comment
1 |3000

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

Alex Rogers avatar image Alex Rogers commented ·

Thanks, vyshakhbabji. For this scenario, I am using a variety of devices, hence why I'd like to identify which one is used in the call. I'm using RC Phone, WebPhone, HardPhone and Softphone. However, for me, I don't see any deviceIds in the events, except for Outbound calls as indicated and even then it doesn't come through the .Net SDK.

0 Likes 0 ·
Phong Vu avatar image
Phong Vu answered Alex Rogers commented

The device id is reported in the telephony session event payload only for outbound calls. It is included in the event through the .NET SDK. Here is what I got in my test using the .NET SDK

// code snippet
...
var eventFilters = new[]
   {
       "/restapi/v1.0/account/~/extension/~/telephony/sessions"
   };
var subscription = await pubNubExtension.Subscribe(eventFilters, message =>
   {
      Console.WriteLine(message);
      ...
   }

// console 

{....,"parties":[{"accountId":"xxxxx","extensionId":"yyyyy","id":"p-a0d7bfa00bcb8z17efe18a620zabb6420000-1","direction":"Outbound","to":{"phoneNumber":"+1650224xxxx"},"from":{"phoneNumber":"+1720386xxxx","extensionId":"yyyy","deviceId":"802404926016"},"status":{"code":"Setup","rcc":false},"park":{},"missedCall":false,"standAlone":false,"muted":false}],"origin":{"type":"Call"}}}
----
{....,"parties":[{"accountId":"xxxx","extensionId":"yyyy","id":"p-a0d7bfa00bcb8z17efe18a620zabb6420000-1","direction":"Outbound","to":{"phoneNumber":"+1650224xxxx"},"from":{"phoneNumber":"+172038xxxx","extensionId":"yyyy","deviceId":"802404926016"},"status":{"code":"Proceeding","rcc":false},"park":{},"missedCall":false,"standAlone":false,"muted":false}],"origin":{"type":"Call"}}}
----
{...,"parties":[{"accountId":"xxxx","extensionId":"yyyy","id":"p-a0d7bfa00bcb8z17efe18a620zabb6420000-1","direction":"Outbound","to":{"phoneNumber":"+1650224xxxx"},"from":{"phoneNumber":"+1720386xxxx","extensionId":"yyyy","deviceId":"802404926016"},"status":{"code":"Answered","rcc":false},"park":{},"missedCall":false,"standAlone":false,"muted":false}],"origin":{"type":"Call"}}}
----
{....,"parties":[{"accountId":"xxxx","extensionId":"yyyy","id":"p-a0d7bfa00bcb8z17efe18a620zabb6420000-1","direction":"Outbound","to":{"phoneNumber":"+1650224xxxx"},"from":{"phoneNumber":"+1720386xxxx","extensionId":"yyyy","deviceId":"802404926016"},"status":{"code":"Disconnected","rcc":false},"park":{},"missedCall":false,"standAlone":false,"muted":false}],"origin":{"type":"Call"}}}
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.

Alex Rogers avatar image Alex Rogers commented ·

Thank you, Phong Vu, for your answer.

So, the deviceId is only present for outbound calls.

Will it ever likely be presented for inbound calls too?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Alex Rogers commented ·

For inbound calls, I am not sure if it would be included for a call to a digital line (e.g. a desk phone). If you have one, please try to call that number and see if the device id is included. However, I doubt that it would be there because an incoming call will ring all the devices that a user is currently login.

0 Likes 0 ·
Alex Rogers avatar image Alex Rogers Phong Vu ♦♦ commented ·

Thank you, Phong Vu.

I have a variety of devices and none of them receive the deviceId on incoming calls.

However, I should point out that I don't need the deviceId on "Ringing". As you say several devices are ringing. I want to know the deviceId on "Connected". That is, I want to know which of the devices actually answered the call. But still I don't get the deviceId at this point either.

0 Likes 0 ·
Phong Vu avatar image
Phong Vu answered Phong Vu commented

Unfortunately, there is no device id in any call stage for inbound call. However, I found a workaround solution below for you.

As soon as you get the "Answered" event of an inbound call, call the endpoint to read active calls for that extension. Set the "view" = Detailed to get the call detailed info. The device id is inside the call legs array at the leg with the direction = "Outbound". Some code snippet in Node JS here

...
subscription.on(subscription.events.notification, function(msg) {
    console.log(JSON.stringify(msg));
    console.log("======");
    if (msg.body.parties[0].status.code == "Answered"){
      readActiveCall(msg.body.telephonySessionId)
    }
});

async function readActiveCall(telSessionId){
  console.log("readActiveCall")
  try {
    var endpoint = `/restapi/v1.0/account/~/extension/~/active-calls`
    console.log(endpoint)
    var resp = await platform.get(endpoint, { view: "Detailed" })
    var jsonObj = await resp.json()
    for (var record of jsonObj.records){
      if (telSessionId == record.telephonySessionId){
        console.log(JSON.stringify(record))
        console.log("=====")
      }
    }
    console.log("+++++++++");
  }catch(e){
    console.log(e.message)
  }
}
// sample response
{
  "uri": "https://platform.ringcentral.com/restapi/v1.0/account/80964xxx/extension/6228832xxx/call-log/QE3d-cD9VKkHzUA?view=Detailed",
  "id": "QE3d-cD9VKkHzUA",
  "sessionId": "777389694016",
  "startTime": "2022-02-17T23:16:51.000Z",
  "duration": 86,
  "type": "Voice",
  "internalType": "LocalNumber",
  "direction": "Inbound",
  "action": "Phone Call",
  "result": "Accepted",
  "to": {
    ...
  },
  "from": {
    ...
  },
  "reason": "Accepted",
  "telephonySessionId": "s-a0d17932e8d6bz17f09f959f4z73533f0000",
  "legs": [
    {
      "startTime": "2022-02-17T23:16:51.000Z",
      "duration": 86,
      "type": "Voice",
      "internalType": "LocalNumber",
      "direction": "Inbound",
      "action": "Phone Call",
      "result": "Accepted",
      "to": {
        ...
      },
      "from": {
        ...
      },
      ...
    },
    {
      "startTime": "2022-02-17T23:16:51.000Z",
      "duration": 86,
      "type": "Voice",
      "internalType": "Sip",
      "direction": "Outbound",
      "action": "VoIP Call",
      "result": "Accepted",
      "to": {
        ...
      },
      "from": {
        "name": "Paco Vu",
        "extensionNumber": "11119",
        "device": {
          "uri": "...",
          "id": "802636634016"
        }
      },
      ...
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.

Alex Rogers avatar image Alex Rogers commented ·

This is working for us now. For convenience, we're also going to use it for outbound calls too.

1 Like 1 ·
Phong Vu avatar image Phong Vu ♦♦ Alex Rogers commented ·

Do you mind to accept the answer. Thanks

0 Likes 0 ·
Alex Rogers avatar image Alex Rogers commented ·

Thank you very much for your help with this.

0 Likes 0 ·

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