Get Wrap Up Codes of all Agents via Data Action

Hi,

We are trying to construct a Data Action that retrieves the Wrap Up Code for the last agent who handled a call from a call. We are using the GET /api/v2/conversations/calls/{conversationId} endpoint, however, we are performing a data manipulation for the output as below.

{
"translationMap": {
"wrapUpCodes": "$.participants[?(@.purpose=="agent")].wrapup.code"
},
"translationMapDefaults": {
"wrapUpCodes": "["0"]}"
},
"successTemplate": "{"WRAPUPCODES":"${wrapUpCodes}"}"
}

The Translation Map has been developed using the JSONPath evaluator, and we can see that it is retrieving an array of Wrap-Up Code ID's. In the Success Template, our first approach is to get the Wrap Up Code as an array. However, when we test this Data Action, the response we are getting is

"message": "Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('2' (code 50)): was expecting comma to separate Object entries\n at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 21]'\n Template:'{"WRAPUPCODES":"${wrapUpCodes}"}'.",
"code": "bad.request",
"status": 400,
"messageParams": {},

If we open the "9. Resolve Translation Map" section, we can see below

"wrapUpCodes": "[ "2aa01ee8-8c43-47c5-ad71-6f92ad8c15c1", "ININ-WRAP-UP-TIMEOUT" ]"

Can't understand why the Output Transformation is failing? What are we doing wrong?

Next question is, is there a way in the Success Template to choose the last element of the array instead of the first? Or do I have to handle this in Architect flow?

Soumik

The issue with the success template is probably that you are putting quotes around the array:

"successTemplate": "{"WRAPUPCODES" : ${wrapUpCodes}}"

Here is an example of some velocity code for getting the last entry of an array:

--Jason

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