api subscription to department extension not forwarding the call to agents automatically on call arrival

  • 1
  • Question
  • Updated 1 day ago
steps
1. I am subscribed to all the following extensions : departments, individual extension ids
2. whenever we recieve a call and the caller types the extension id for individual agent , we recieve the agents presence in subscription properly..
3. when I select on department 's extension on call, the call is not forwarded to agent directly, and I am not receiving that notification in callback for that agent. Instead I receive notification object for department extension as :
{
  "uuid": "*",
  "event": "/restapi/v1.0/account/*/extension/*/presence?detailedTelephonyState=true",
  "timestamp": "*",
  "subscriptionId": "*",
  "ownerId": "*",
  "body": {
    "extensionId": *,
    "sequence": *,
    "presenceStatus": "Offline"
  }

4. even when the presence of agent extension is already enabled

So I am not able to figure out if this is right way to do things.
My aim is to recieve department call and get the presence of agent using subscription api to whom the call is forwarded to.
Photo of Bruno Dmello

Bruno Dmello

  • 140 Points 100 badge 2x thumb

Posted 3 weeks ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,416 Points 5k badge 2x thumb
How do you implement the call forwarding? Via Active Call Control API or using preconfigured forwarding rules?

Can you explain more on this? 

3. when I select on department 's extension on call, the call is not forwarded to agent directly, and I am not receiving that notification in callback for that agent.

How do you select and how do you forward the call. Would be helpful if you provide some codes
Photo of Bruno Dmello

Bruno Dmello

  • 140 Points 100 badge 2x thumb
I didn't configured anything or any api to control thing, I only made sure that under group section-> the list of users are active as well as call handling is set to simultaneous type.  

the overall procedure coded is a follows: 
1. get the list of extensions by department :
/account/~/extension?type=Department
2. then I loop over its data to get members of all department
getCallMembersExtensions = (allExtensions) => {
return (extensionResults)=>{
let extensionDetails = extensionResults.json();
let memberList = extensionDetails.records.map(({id}) => {
allExtensions.push(this.getPresenceLink(id))
return platform.get(`/account/~/department/${id}/members`)
})
return Promise.all(memberList)
}
}
4. prepare the presence links  
getMemberPresence = (allExtensions) => {
return (memberDetails) => {
console.log("memberDetails", memberDetails);
memberDetails.map((memberDatum) => {
let memberJson = memberDatum.json();
return memberJson.records.map((r) => {
allExtensions.push(this.getPresenceLink(r.id))
})
})
5. set the presence

subscription
.setEventFilters([...allExtensions, '/account/~/presence'])
.register().then(function (response) {
console.log('Success: Subscription is listening');
}).catch(function(e) {
console.log('Subscription Error: ', e);
});
5. listen to the events,
const subscription = getRcsdk().createSubscription();
subscription.on(subscription.events.notification, function(accountPresence) {
  console.log("accountPresence", accountPresence)
});
here I receive notifications for both direct agent extension on call or call queue extensions. but in case of call queue extension  , I receive this data
{
  "uuid": "*",
  "event": "/restapi/v1.0/account/*/extension/*/presence?detailedTelephonyState=true",
  "timestamp": "*",
  "subscriptionId": "*",
  "ownerId": "*",
  "body": {
    "extensionId": *,
    "sequence": *,
    "presenceStatus": "Offline"
  }
no caller info, nothing else.. moreover I was expecting that it forwards the call to particular agent(as the agent's ext id is also being listened, I may recieve a notification in callback for same, but this is not happening).
please let me know if I am missing something



Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
There are a few strange things here:

You set the presence filter at the account level 
subscription.setEventFilters([...allExtensions, '/account/~/presence']) 
This means that you will get presence status notification of all the extensions under the same account and provided that you login the app with the admin user.

However, the notification data you received came with the telephony status:
"event": "/restapi/v1.0/account/*/extension/*/presence?detailedTelephonyState=true",
I guess that you replace the tilde, the subscriptionId with the * symbol. Can you double check the subscriptionId returned after you subscribe for the event and the one in the notification payload to see if they match.

Can you try to subscribe for the presence with telephony status event at the extension level for each of the extension you want to monitor. Iterate thru the list of extensions, get the extension id then add to the filter array as shown below
'/restapi/v1.0/account/~/extension/[EXTENSION_ID]/presence?detailedTelephonyState=true'

You wrote ".. moreover I was expecting that it forwards the call to particular agent(as the agent's ext id is also being listened". I think your code has nothing to do with forwarding the call to an agent. So if you defined the forwarding with the forwarding rule, just check that part to see if it was preconfigured properly.

I will try to double check if the notification data for a call in the call queue would contain call information and let you know later. This could take some time for me to test so please be patience.
Photo of Bruno Dmello

Bruno Dmello

  • 140 Points 100 badge 2x thumb
In above code I have collection all the extensions links to be subscribed in an array. the name of array is  
allExtensions
you can check in part 2, 4.
yes I have replace tilde and data with '*', just to hide the data.. if required I can definitely share it..


"Can you try to subscribe for the presence with telephony status event at the extension level for each of the extension you want to monitor. Iterate thru the list of extensions, get the extension id then add to the filter array as shown below"
 ->so in 2,4 step I have collection the extension with method

getPresenceLink(id) {
return `/restapi/v1.0/account/~/extension/${id}/presence?detailedTelephonyState=true`
}

that creates the subscription links, and then on step 5 registered all the links in array, so that I may listen to all the extensions, as well as any notification that I may miss on account level.

 hope this is all a expected.

I do get notification for all the extensions subscribed

So I guess, the only issue is the response event structure I received when called a call queue extension. let me know once you verify about this.

Forwarding    
I don't want to actually forward the call to agent number explicitly using any rule. but by default when we call the call queue extension and we get notification about it on api, in background I am sure we handle the call to particular agent, that 's what we configure in call handling and member section under group tab(which I had configured as 'simultaneous'). 


Thanks for help please let me know if anything else is required from my side 

Photo of Bruno Dmello

Bruno Dmello

  • 140 Points 100 badge 2x thumb
Hello Phong Vu, 
please let me know once you receive any updates on this.
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
Hi Bruno,

I just got some time to test the queue and presence notification and here is the outcomes:

If I have no "Agent" available (meaning that none of the users added to the queue extension is logged in) then the notification body will be just as what you got. i.e. 

{"extensionId":xxxxxxxx,"sequence":22,"presenceStatus":"Offline"}
...

But if I login with one of the user (in my test, the extension 101) using the soft phone (so at least one is available/online) then I get a detailed call info from the notification body:

{"extensionId":xxxxxxxxx,"telephonyStatus":"NoCall","activeCalls":[{"id":"Y3MxNjk2MTIzOTczNTE2MjAzNjE5QDEwLjI4LjIwLjEwOQ","direction":"Inbound","from":"+1650224XXXX","toName":"Sales team","to":"+1438800XXXX","telephonyStatus":"NoCall","sessionId":"20915514004","terminationType":"final","startTime":"2019-05-07T18:23:29.883Z","partyId":"cs1696123973516203619-3","telephonySessionId":"Y3MxNjk2MTIzOTczNTE2MjAzNjE5QDEwLjI4LjIwLjEwOQ"}],"sequence":373,"presenceStatus":"Available","userStatus":"Available","dndStatus":"TakeAllCalls","message":"I am free","allowSeeMyPresence":true,"ringOnMonitoredCall":false,"pickUpCallsOnHold":false,"totalActiveCalls":1}

I am sure that if I also login with other users on added to the queue extension, then I would receive more notification for that user.

Is this what you are looking for? Please try as I did and let me know.
Photo of Bruno Dmello

Bruno Dmello

  • 140 Points 100 badge 2x thumb
Thanks for your feedback. so this are the steps implemented : 
1. performed login in ringcentral integrated app with admin account.
2. logged in with call queue member account in different browser
3. made a call to company number and typed the extension for call queue in which the member is present.
4. in the integrated app, receiving the presence notification that still shows the same offline response and not the active call with callers info response

please let me know if I am missing something or what can be done about it
(Edited)
Photo of Bruno Dmello

Bruno Dmello

  • 140 Points 100 badge 2x thumb
Hi I got some changes now :
1. login with any credentials admin/callqueue member in ringcentral integrated app
2.make a call on the app number, selected the callqueue extension in which the member is present.
3. Observed that when I cut the call, I receive data in my listener callback. I received all the data desired on call stop.

One thing is that at-least I receive data now which is a new step.. but now sure why we receive after call is cut.
please let me know what you think about it 
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,406 Points 5k badge 2x thumb
Hi Bruno,

I guessed that all of the steps you did before was correct. The only different thing between your test and mine was a testing scenario, where one of the extensions (added to the queue extension) is online to receive the notification. When saying "online" I mean that user must login to receive a call (e.g. logged in the RingCentral soft-phone).

Not sure, why you just got the notification when the call is terminated. Do you still use the `/restapi/v1.0/account/~/extension/${id}/presence?detailedTelephonyState=true` filter?

If the problem persists, join our support channel so we can help you faster.
Photo of Bruno Dmello

Bruno Dmello

  • 140 Points 100 badge 2x thumb
After some test and re login , I got it working now. We receive the data for callqueue member when logged in with member credential in app. However the next thing is if the admin is member of the group we are not receiving the data when only admin is logged in and not other member.
 Thanks a lot for your support, we reached to a new step. I will connect on support channel for more info.