Skip to main content

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?

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 .


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.


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"}}}

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?


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"
}
},
...

Thank you very much for your help with this.


Reply