Response Template not displaying SegmentEnd data in Data action

I am trying to pull QueueID and SegmentEnd (or ConverstationEnd) data/time data from a known conversationID using the /api/v2/conversations/${input.ConversationID} and use architect to search for the index of the most recent time, then use the most recent Queue ID to write to a custom attribute.
Both QueueID and segmentEnd are in the PURPOSE="ACD" section of the output.

My contracts setup is as follows.

My Response Template is as follows:

{
"translationMap": {
"queueId": "$.participants[?(@.purpose == 'acd')].queueId",
"segmentEnd": "$.segmentEnd[?('acd' in @.participants[*].purpose)].segmentEnd"
},
"translationMapDefaults": {
"queueId": "[]",
"segmentEnd" : "[]"
},
"successTemplate": "{\n"queueId": ${queueId},\n"segmentEnd": ${segmentEnd}\n}"
}

Other variations tried to no avail

	"segmentEnd": "$.segmentEnd[*].participants[?(@.purpose=="acd")].sessions[*].segments[*].segmentEnd"

"successTemplate": "{\n"queueId": ${queueId},\n"segmentEnd": ${successTemplateUtils.firstFromArray(${segmentEnd}\n}"

Queue IDs are displaying fine, but not the SegmentEnd data.
Is my response template incorrect? or setup of output contract given its a Data/Time field (i have it listed as a String at present). I could also use ConversationEnd instead of SegmentEnd.

Thanks for any tips. I am struggling to use the new API Explorer

First place I would start is by putting in an example response (the results of the execute step in test mode) into a JSONpath testing web site. For example, I tend to use https://www.javainuse.com/jsonpath
Be sure to redact anything sensitive before using a third party site like that.

Then see if you segmentEnd json path does what you expect and try working out any issues.

If you are not able to sort it out with that tool, feel free to post the redacted object here for us to help out with. Make sure that the redactions do not change the shape of the object.

--Jason

Thanks Jason, i will try out that website link. :slight_smile:

Hi @Simon_McKenzie ,

If you are interested in getting conversationEnd, you can use the following API endpoint:

GET /api/v2/analytics/conversations/{conversationId}/details

You can use the response template provided below to get what you need:

{
  "translationMap": {
    "queueIds": "$.participants[?(@.purpose == 'acd')].sessions[*].segments[*].queueId",
    "conversationEnd": "$.conversationEnd"
  },
  "translationMapDefaults": {
    "queueIds": "[]",
    "conversationEnd": ""
  },
  "successTemplate": "{\"queueIds\": ${queueIds},\"conversationEnd\":${conversationEnd}}"
}

Ensure queueIds is declared as an array of strings and conversationEnd as a string.

Let me know what if that helps :slight_smile:

Kind Regards,

Charaf

Thanks for the Charaf. I tried your response template and it partially works.
Assuming i have contracts setup correctly....

I was not getting any Queue Ids outputted so experimented with the response template and changed it to this....
now i am getting all the Queue Ids outputted although duplicates are coming out. Its basically finding any QueueID under the ACD section and writing it to the array. I was after just one of each. .

{
"translationMap": {
"queueId": "$.participants[?(@.purpose == 'acd')].sessions[].segments[].queueId",
"conversationEnd": "$.conversationEnd"
},
"translationMapDefaults": {
"queueId": "[]",
"conversationEnd": ""
},
"successTemplate": "{"queueId": ${queueId},"conversationEnd":${conversationEnd}}"
}

I suspect i will have to use the POST /api/v2/analytics/conversations/details/query as it allows me to SORT ASC/DESC.

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