News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Get External phone number for active call in queue
Tags: call queues, call logs
Dec 5, 2022 at 10:17am   •   1 replies  •  0 likes
Ben Stich

I am trying to pull the phone number of an Inbound active phone number routed through a call Queue for an user. I am currently using Get User Active Call to try and pull that number. It seems to work for direct calls to and from User to Client and in call Queues if the inbound phone call is ignored by users. the issue is that if a user is busy and the systems moves to the next person or if a user declines a call, the User Active Call record changes to an outbound phone call and does not have the needed phone number anymore. How can I get the external phone number that I need when the record changed from Inbound to Outbound. The phone number I am trying to get is +12222222222
What I expect:

type: Voice
internalType: LocalNumber
direction: Inbound
action: Phone Call
result: In Progress
to: {
name: Test Queue
phoneNumber: +1111111111
location: Abbyville , KS},
from: {
name: Test Queue - Sam Smith
phoneNumber: +1222222222
location: Town, St},


What I am getting:

internalType: Sip
direction: Outbound
action: VoIP
Call result: In Progress
to: {
"phoneNumber" : "+19998887777",
"extensionNumber" : "1111",
"location" : ", KS" },
from: {
"name" : "Sam Smith",
"extensionNumber" : "1111",


1 Answer
answered on Dec 5, 2022 at 1:06pm  

The user active calls list also internal calls via a call queue and that is why you see the Outbound call also. I can't explain why and what those internal calls are for but as you can see, they all has different session id and telephony session id.

In this case, I recommend you to use the /presence?detailedTelephonyState=true to read active calls and detect the 'from' phone number. See sample code and result.

async function getUserTelephonyStatus(
  try {
    var endpoint = `/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true`
    var res = await platform.get(endpoint)
    var jsonObj = await res.json()
    if (jsonObj.hasOwnProperty('activeCalls')){
      for (var record of jsonObj.activeCalls){
        console.log(record)
      }
    }
  }catch(e) {
      console.log(e.message)
  }
}
// example result
{
  id: 's-a0d...',
  direction: 'Inbound',
  fromName: 'Demo queue - WIRELESS CALLER',
  from: '+1650224xxxx',
  toName: 'Demo queue',
  to: '+1209248xxxx',
  telephonyStatus: 'Ringing',
  sessionId: '961173946016',
  startTime: '2022-12-05T20:56:59.822Z',
  partyId: 'p-a0d...',
  telephonySessionId: 's-a0d...',
  callInfo: {
    primary: { type: 'QueueName', value: 'Demo queue' },
    additional: { type: 'CallerIdName', value: 'WIRELESS CALLER' }
  },
  queueCall: true
}

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us