Count the number of Idle agents by using a Data Action

Hello,

I would like to know if it is possible to count the number of IDLE agents based on a Data Action.

I use the /api/v2/routing/queues/{input.queue_id}/users?skills={input.skill}&routingStatus=${input.status} to retrieve the user information from the queue based on the Queue ID, the Skill and the status (Idle in this case).

The Data Action runs and I get a result in JSON, but I would like to count the status Idle so that when I have a value >0 then I can route that call via a pre-call rule to an Outbound Preview agent and if the value is =<0 I mark the contact in the list to not call.

Can I fetch or count the number of "status": Ïdle" from the data actions results?
I have been trying all day now and I can't get it to work like I want to.

JSON used:

{
"name": "test_GetAgentsIdleFromQueue - Exported 2020-08-20 @ 16:40",
"integrationType": "purecloud-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "/api/v2/routing/queues/{input.queue_id}/users?skills={input.skill}&routingStatus={input.status}", "requestType": "GET", "headers": { "Content-Type": "application/json" }, "requestTemplate": "{input.rawRequest}"
},
"response": {
"translationMap": {},
"translationMapDefaults": {},
"successTemplate": "${rawResult}"
}
},
"contract": {
"input": {
"inputSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Queue Request",
"description": "Requests Queue",
"type": "object",
"required": [
"queue_id"
],
"properties": {
"queue_id": {
"description": "The Queue ID",
"type": "string"
},
"skill": {
"type": "string"
},
"status": {
"type": "string"
}
},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Result",
"description": "Returns the number of idle agents.",
"type": "object",
"properties": {
"routingStatus": {}
},
"additionalProperties": true
}
}
},
"secure": false
}

Best regards,
Rob

Could you post the JSON you are getting back from your request with anything sensitive redacted?

There was a forum post about this a couple of years ago which seemed to indicate that the response would include a top level "total" key/value pair that would get you what you are looking for.

Hi Jason,

Below the JSON I get back (if one agent with is the requested skill is logged in and Idle in the queue).

The idea is not to use this in Architect but to trigger the Data Action when a Preview Outbound call has to be routed to an agent.
Before routing I would like to check (by using a pre-call rule) if there is an agent available in the queue if yes, route the call if not put the call to the side (update the record) and go to the next.

Therefore I would only need to know if the number of Idle agents in the queue is bigger than 0.

Best thing would be a outcome like count=1 or so, but I can't seem to find the way to to that.

{
"entities.user.skills.skillUri": [
[
"/api/v2/routing/skills/xxxxxxxx-6fe0-44d8-8f21-a66400fcf94d",
"/api/v2/routing/skills/xxxxxxxx-607e-4192-b22d-575cf8917b5f",
"/api/v2/routing/skills/xxxxxxxx-02e1-4e5b-83e1-731118e974de"
]
],
"entities.user.version": [
40
],
"entities.user.department": [
""
],
"entities.id": [
"xxxxxxxx-6224-4ff1-95f4-a08996572e97"
],
"entities.routingStatus.startTime": [
"2020-08-21T06:36:27.249Z"
],
"pageNumber": 1,
"entities.user.acdAutoAnswer": [
true
],
"entities.user.addresses.address": [
[
"+316xxxxxxx"
]
],
"entities.user.addresses.display": [
[
"+31 6 xxxxxxx"
]
],
"lastUri": "/api/v2/routing/queues/xxxxxxxx-0012-425d-8139-6dda3332e48e/users?pageSize=25&pageNumber=1&skills=SBR_0001&routingStatus=Idle",
"entities.user.primaryContactInfo.mediaType": [
[
"EMAIL",
"PHONE"
]
],
"entities.user.addresses.mediaType": [
[
"PHONE"
]
],
"entities.user.routingStatus.status": [
"IDLE"
],

"pageSize": 25,
"entities.user.addresses.countryCode": [
[
"NL"
]
],
"entities.user.primaryContactInfo.type": [
[
"PRIMARY",
"PRIMARY"
]
],
"entities.user.name": [
"RobTestxxxx"
],
"entities.user.chat.jabberId": [
"xxxxxxxx9@xxxxxxxx.com"
],
"entities.user.division.selfUri": [
"/api/v2/authorization/divisions/xxxxxxxx-25af-462d-aaff-01b5fbcdbdf6"
],
"total": 1,
"entities.user.routingStatus.startTime": [
"2020-08-21T06:36:27.249Z"
],
"entities.user.skills.proficiency": [
[
5,
5,
3
]
],
"entities.joined": [
true
],
"entities.routingStatus.status": [
"IDLE"
],
"entities.user.email": [
"robxxx@xxx.com"
],
"entities.user.selfUri": [
"/api/v2/users/xxxxxxxx-6224-4ff1-95f4-a08996572e97"
],
"entities.user.state": [
"active"
],
"entities.user.skills.state": [
[
"active",
"active",
"active"
]
],
"pageCount": 1,
"entities.user.primaryContactInfo.display": [
[
null,
"+31 6 xxxxxxx"
]
],
"firstUri": "/api/v2/routing/queues/xxxxxxxx-0012-425d-8139-6dda3332e48e/users?pageSize=25&pageNumber=1&skills=SBR_0001&routingStatus=Idle",
"selfUri": "/api/v2/routing/queues/xxxxxxxx-0012-425d-8139-6dda3332e48e/users?pageSize=25&pageNumber=1&skills=SBR_0001&routingStatus=Idle",
"entities.user.username": [
"robxxx@xxx.com"
],
"entities.name": [
"RobTestxxxx"
],
"entities.user.division.id": [
"xxxxxxxx-25af-462d-aaff-01b5fbcdbdf6"
],
"entities.user.primaryContactInfo.address": [
[
"robxxx@xxx.com",
"+316xxxxxxx"
]
],
"entities.user.title": [
""
],
"entities.ringNumber": [
1
],
"entities.user.id": [
"xxxxxxxx-6224-4ff1-95f4-a08996572e97"
],
"entities.user.skills.selfUri": [
[
"/api/v2/users/xxxxxxxx-6224-4ff1-95f4-a08996572e97/routingskills/79eb6231-6fe0-44d8-8f21-a66400fcf94d",
"/api/v2/users/xxxxxxxx-6224-4ff1-95f4-a08996572e97/routingskills/d5df9103-607e-4192-b22d-575cf8917b5f",
"/api/v2/users/xxxxxxxx-6224-4ff1-95f4-a08996572e97/routingskills/69d59527-02e1-4e5b-83e1-731118e974de"
]
],
"entities.user.division.name": [
"Home"
],
"entities.user.skills.name": [
[
"Skill_Test_1",
"SBR_0001",
"SBR_0002"
]
],
"entities.memberBy": [
"user"
],
"entities.user.skills.id": [
[
"xxxxxxxx-6fe0-44d8-8f21-a66400fcf94d",
"xxxxxxxx-4192-b22d-575cf8917b5f",
"xxxxxxxx-02e1-4e5b-83e1-731118e974de"
]
]
}

Best regards,
Rob

The
"total": 1
that is included in the response seems like it is exactly what you need.

--Jason

Hi Jason,

You are right, I took the value of total and it worked instantly :slight_smile:
I totaly overlooked that value, I thought I had to count myself.

Thanks!
Best regards,
Rob

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.