Agents "on queue" for architect routing

Hi All,

I am trying to use the number of "on queue" agents to make routing decisions in Architect. I have seen various posts regarding this and also can test the query in the developer tools which works using this query:

"
GET /api/v2/routing/queues/8e7d3e9f-8a8b-44e7-ae8c-84e9e4af3a23/users?presence=On%20Queue"

However when I try various code and in the data action I get various errors, for example if I use this previously posted code:

Input Contract:
{
"title": "Get Number of Agents Logged Into Queue Request",
"description": "A user ID-based request",
"type": "object",
"required": [
"QueueID"
],
"properties": {
"QueueID": {
"type": "string",
"description": "The Queue ID."
}
}
}

Output Contract:

{
"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",
"title": "Agents"
}
}
}

Request:

{
"requestUrlTemplate": "/api/v2/routing/queues/${input.QueueID}/users?presence=esc.url('On Queue')", "requestType": "GET", "headers": { "ContactID": "PureCloudIntegrations/1.0", "Content-Type": "application/x-www-form-urlencoded" }, "requestTemplate": "{input.rawRequest}"
}

Response:

{
"translationMap": {
"Agents_Logged_Into_Queue": ".total" }, "translationMapDefaults": {}, "successTemplate": "{ "Agents Logged Into Queue": {Agents_Logged_Into_Queue} }"
}"

I get this response:

{
"message": "The request could not be understood by the server due to malformed syntax.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "1d617fad-9b91-4582-b998-e640e39e29d2",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": [
{
"message": "Failed due to malformed requestUrlTemplate. Illegal character in query at index 112: https://api.mypurecloud.ie/api/v2/routing/queues/8e7d3e9f-8a8b-44e7-ae8c-84e9e4af3a23/users?presence=esc.url('On Queue')",
"code": "BAD_REQUEST",
"status": 400,
"messageParams": {},
"details": [],
"errors": []
}
]
}

If I change the request to match the previous test I was using in the developer tools, it returns this:

{
"message": "Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('A' (code 65)): was expecting double-quote to start field name\n at [Source: (String)"{ "Agents Logged Into Queue": {Agents_Logged_Into_Queue} }"; line: 1, column: 33]'\n Template:'{ "Agents Logged Into Queue": {Agents_Logged_Into_Queue} }'.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "50e2e081-b6d9-4fbe-995b-f0d1e05a4f48",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": []
}

I am very new to JSON, so any advise is greatly appreciated!

Thanks Luke

Hi Luke,

One of the steps in test mode will show you the resolved URL, can you post that?

--Jason

Hi Jason,

This is from the second attempt with the URL changed as per the developer tools:

"[GET] https://api.mypurecloud.ie/api/v2/routing/queues/8e7d3e9f-8a8b-44e7-ae8c-84e9e4af3a23/users?presence=On%20Queue"

Thanks LUke

That looks correct to me, but the forum can subtly change your post, making it hard to figure out formatting problems. Please export your Data Action and post it to this thread, you should now have the permission to do so.

--Jason

Ok thanks Jason, please find attachedAgents-On-Queue-20200519135448.custom.json (1.8 KB)

So you had made progress, the error was now resolving the success template.

The fix there is that you need a $ in front of {Agents_Logged_Into_Queue}, so ${Agents_Logged_Into_Queue}  Without that the template wasn't doing a variable substitution.

Finally, the translation map also needed a $ in front of the .total, so $.total otherwise it was setting the value to an array [ 0 ] instead of 0.

--Jason
1 Like

Hi Jason, ok thanks

I am not sure if this forum is deleting anything but I am not sure what is needed in front of these?

I just changed my previous reply to be "Preformatted text". I think that stopped the forum from removing all of the dollar signs :slight_smile:

That is great!

Thank you very much for your help Jason

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