Data action - On Queue users

Hi,

i'm trying to create a data action that will return the number of 'on queue' users in a queue i have the below (unfortunately new users can't upload files so putting the code here) but it always sends back 0 as people in queue even when i'm set to that status

{
"name": "Get_Users_in_queue_Ver 3 - Exported 2018-07-25 @ 8:31 - Exported 2018-07-25 @ 8:05",
"integrationType": "purecloud-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "/api/v2/analytics/queues/observations/query",
"requestType": "POST",
"headers": {},
"requestTemplate": "{"filter": {"type":"or","predicates": [{"dimension": "queueId","value": "${input.QUEUE_ID}"}]}}"
},
"response": {
"translationMap": {
"metrics": "$.results[0].data[?(@.metric=="oOnQueueUsers")].stats.count"
},
"successTemplate": "{"metrics": ${successTemplateUtils.firstFromArray("${metrics}", "0")}}"
}
},
"contract": {
"input": {
"inputSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Active agents in Queue",
"description": "The number of agents in a queue.",
"type": "object",
"required": [
"QUEUE_ID"
],
"properties": {
"QUEUE_ID": {
"description": "The queue ID.",
"type": "string"
}
}
}
},
"output": {
"successSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"metrics": {
"type": "integer"
}
}
}
}
},
"secure": false
}

any help appreciated :slight_smile:

Kind Regards,

Ian

Hello,

As it is right now, there are errors in your Data Action contract and configuration.
I mean that it fails if you test it (and doesn't return 0).

The Request configuration is missing metrics attribute in your query.
It should be like this I guess (requesting oOnQueueUsers metrics):

{
  "requestUrlTemplate": "/api/v2/analytics/queues/observations/query",
  "requestType": "POST",
  "headers": {},
  "requestTemplate": "{\"filter\": {\"type\":\"or\",\"predicates\": [{\"dimension\": \"queueId\",\"value\": \"${input.QUEUE_ID}\"}]},\"metrics\": [ \"oOnQueueUsers\" ]}"
}

The response configuration also had an issue when no agent is in queue.
It should be like this:

{
  "translationMap": {
    "metrics": "$.results[0].data[?(@.metric==\"oOnQueueUsers\")].stats.count"
  },
  "translationMapDefaults": {
    "metrics": "[]"
  },
  "successTemplate": "{\"metrics\": ${successTemplateUtils.firstFromArray(\"${metrics}\", \"0\")}}"
}

If you are still getting 0 after updating your Data Action, it may be that the OAuth Client (Client Credentials) that you are using for your Genesys Cloud Data Actions does not have visibility on the division that your queue belongs to. In this case, you would need to make sure that the roles assigned to your OAuth Client are enabled on the necessary divisions.

Regards,

Thanks very much for the quick response :), just made these changes but seem to be getting the following error now:

7. Resolve request body template: Substitution values invalid in action config. Reference ${input.QUEUE_ID} evaluated to null when attempting to render at BodyTemplate[line 1, column 74] A common reason for this error is needing to prepend the variable with 'input.' or 'credentials.'

the code i have is as follows:

input contract:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Get Number of Agents Logged Into Queue Request",
"description": "A user ID-based request",
"type": "object",
"required": [
"QueueID"
],
"properties": {
"QueueID": {
"description": "The Queue ID.",
"type": "string"
}
},
"additionalProperties": true
}

output contract:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Get User Routing Status Response",
"description": "Agents logged into queue.",
"type": "object",
"required": [
"Agents Logged Into Queue"
],
"properties": {
"Agents Logged Into Queue": {
"description": "Agents logged into queue. A value > 0 does not guarantee that an interaction sent to this queue will be answered.",
"type": "number"
}
},
"additionalProperties": true
}

configuration request:

{
"requestUrlTemplate": "/api/v2/analytics/queues/observations/query",
"requestType": "POST",
"headers": {},
"requestTemplate": "{"filter": {"type":"or","predicates": [{"dimension": "queueId","value": "${input.QUEUE_ID}"}]},"metrics": [ "oOnQueueUsers" ]}"
}

configuration response:

{
"translationMap": {
"metrics": "$.results[0].data[?(@.metric=="oOnQueueUsers")].stats.count"
},
"translationMapDefaults": {
"metrics": "[]"
},
"successTemplate": "{"metrics": ${successTemplateUtils.firstFromArray("${metrics}", "0")}}"
}

Thanks in advance!

Hello,

In your first post, you had named the variable that holds the id of the queue: QUEUE_ID (in your input contract).
${input.QUEUE_ID} is meant to reference the variable you define in this input contract (in the request configuration).

In your second post, you have apparently changed the variable name from QUEUE_ID to QueueID. You are totally allowed to do this.
But in this case, to reference the value of that variable you need to use: ${input.QueueID} in your request configuration.

Regards,

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