Find current queue thru API

Hi.
Is there a way to find the current queue thru API?

Hello,

Find the current queue of what? when (i.e. at what stage of the conversation)?

Regards,

Sorry... current queue of a live voice interaction

Assuming you know the conversationId of this interaction/conversation, you can invoke GET /api/v2/conversations/{conversationId}.
This will retrieve the conversation context.
In the response, you can find a participants array attribute which contains all participants - look for the last participant with purpose = acd in the array (it should be your queue if the call is currently in queue).

Regards,

Thanks Jerome. Any help on the jsonpath to find the last element.

$.participants[?(@.purpose=="acd")].queueName

[
"Queue1",
"Queue2",
"Queue3"
]

What are you invoking? A Genesys Cloud Data Action?

If yes, where are you invoking this Data Action from?
An Architect In-Queue flow? A Script (agent's script)?

Regards,

try to use it in agent script

Yes data action from script

Regarding the Data Action, you could use the following (lastQueue being defined as a string attribute in the Output Contract):

{
  "translationMap": {
    "queuesArrayAsStr": "$.participants[?(@.purpose==\"acd\")].queueName"
  },
  "translationMapDefaults": {
    "queuesArrayAsStr": "[\"None\"]"
  },
"successTemplate": "#set ($queuesArray = $queuesArrayAsStr.replace(\"[\", \"\").replace(\"]\", \"\").replace(\" \", \"\").split(\",\")) {\"lastQueue\": $queuesArray[-1] }"
}

The JSONPath Expression results in an array, represented as a string.
There is unfortunately no built-in method available to combine a search with a filter on purpose and get the last element of the array (there is one for the first element).
So the Velocity commands, in the above successTemplate, are used to convert the string back to an array.
Using -1 as index seems to be working for me when the array is not empty - to get the last element.

Regards,

Wow @Jerome.Saint-Marc . That's amazing. Thank you so much.

Couple of questions:

  1. Where can I learn syntax like you use in the successTemplate?

  2. When a conversation has no acd, I believe it should return None. However it threw an error. Any ideas?
    Response:
    {
    "translationMap": {
    "queuesArrayAsStr": "$.participants[?(@.purpose=="acd")].queueName"
    },
    "translationMapDefaults": {
    "queuesArrayAsStr": "["None"]"
    },
    "successTemplate": "#set ($queuesArray = $queuesArrayAsStr.replace("[", "").replace("]", "").replace(" ", "").split(",")) {"QueueName": $queuesArray[-1] }"
    }

Error:
{
"message": "Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('}' (code 125)): expected a value\n at [Source: (String)" {"QueueName": }"; line: 1, column: 18]'\n Template:'#set ($queuesArray = $queuesArrayAsStr.replace("[", "").replace("]", "").replace(" ", "").split(",")) {"QueueName": $queuesArray[-1] }'.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "12e36613-be71-4a80-a51f-f9979bbb2683",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": []
}

Hello,

"1. Where can I learn syntax like you use in the successTemplate?"

It is Velocity Template Language.
There's a link to its doc in the Response configuration for data actions.
Link to VTL Reference guide.

Note that some of the VTL statements are not supported - like foreach.
See this other post
But a statement if/elseif/else is working and can be leveraged in the success template.

"2. When a conversation has no acd, I believe it should return None. However it threw an error. Any ideas?"

The JSONPath expression is not returning None. It is returning an empty array in this case.
Because of this, the current velocity in success template raises an error when the array is empty (array of queues).
You can keep it like it is and manage the No ACD Queue as a Data Action error (failure output).
If you want to manage this in the Data Action itself, you could probably add some Velocity Template Language statements to test the queuesArrayAsStr or queuesArray variables (test if they are empty/null - using #if/#else).

Regards,

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