That is a very large resource page. Even so, really would like a video or webinar or a blog or something that breaks it down and explains it step by step with some real examples with Genesys APIs that an admin can replicate.
Original Message:
Sent: 06-18-2024 16:28
From: Paul Simpson
Subject: Nested Array Translation Map Issue - Conversation Details
Of course, as soon as I hit "Post", I tried Googling the function name, successTemplateUtils.firstFromArray, and found this.
HTH
------------------------------
Paul Simpson
Views expressed are my own and do not necessarily reflect those of my employer.
Original Message:
Sent: 06-18-2024 16:25
From: Paul Simpson
Subject: Nested Array Translation Map Issue - Conversation Details
Anton,
You won't get any argument from me there! I often see it heavily implied, if not outright stated, that it is following some well-known standard library, I believe for JavaScript. If that is true, then if anyone knows the name of that library, we could perhaps find external documentation! 😁
------------------------------
Paul Simpson
Views expressed are my own and do not necessarily reflect those of my employer.
Original Message:
Sent: 06-18-2024 16:14
From: Anton Vroon
Subject: Nested Array Translation Map Issue - Conversation Details
If there is one thing I found really lacking as far as training material, it is the DataAction outputs, translation mappings, and velocity macros like that.
All the material out there are usually basic outputs and just uses raw results.
A lot of time spent on the developer forum figuring out things like that from past threads.
I would love to see a Q&A or a DevBlog/DevCast or anything really going over how to write the mapping and some common velocity macros and how to use them.
------------------------------
Anton Vroon
Original Message:
Sent: 06-18-2024 13:35
From: Paul Simpson
Subject: Nested Array Translation Map Issue - Conversation Details
Hey Anton!
I didn't know about the successTemplateUtils.firstFromArray thing. I have a similar requirement and have been returning an array and processing it in Architect! This will streamline things tremendously.
Thanks!
------------------------------
Paul Simpson
Views expressed are my own and do not necessarily reflect those of my employer.
Original Message:
Sent: 06-16-2024 19:36
From: Anton Vroon
Subject: Nested Array Translation Map Issue - Conversation Details
Update your output contract to just be:
{ "type": "object", "properties": { "participantId": { "type": "string" }, "sessionId": { "type": "string" } }, "additionalProperties": true}
with the translationmap as:
{ "translationMap": { "participantId": "$.participants[*].participantId", "sessionId": "$.participants[*].sessions[*].sessionId" }, "translationMapDefaults": {}, "successTemplate": "{\"participantId\": ${successTemplateUtils.firstFromArray(\"${participantId}\",\"0\")},\"sessionId\": ${successTemplateUtils.firstFromArray(\"${sessionId}\",\"0\")} }"}
And it should work.
The next issue you will face however is that the result is not the agent participant id, but just the very first one, which for inbound is likely to be the customer.
So you are going to want to apply a filter eg
$.participants[?(@.purpose == 'agent')].participantId or customer or acd or whatever participant you are looking for. And then you might need to further differentiate if you might have multiple agents on the call.
And for session, similar $.participants[?(@.purpose == 'agent')].sessions[0].sessionId I just added 0 to get the first session, but again you could do a filter or do -1 for the last item in the array etc.
I believe you can also use
PATCH /api/v2/conversations/{conversationId}/participants/{participantId} to apply a wrap up to the participant without worrying about the session.
- Though not 100% on this approach.
------------------------------
Anton Vroon
Original Message:
Sent: 06-14-2024 16:03
From: Matt Riedl
Subject: Nested Array Translation Map Issue - Conversation Details
Hello,
I am currently trying to extract a couple elements from the conversation details API:
/api/v2/analytics/conversations/${input.conversationId}/details
One of the elements I need is within a nested array, and I've been trying to use a translation map to extract the relevant elements:
Output Contract:
{
"type": "object",
"properties": {
"participants": {
"type": "array",
"items": {
"title": "agentParticipantObject",
"type": "object",
"properties": {
"participantId": {
"type": "string"
},
"sessions": {
"type": "array",
"items": {
"title": "agentSessionObject",
"type": "object",
"properties": {
"sessionId": {
"type": "string"
}
},
"additionalProperties": true
}
}
},
"additionalProperties": true
}
}
},
"additionalProperties": true
}
Translation map:
{
"translationMap": {
"agentParticipantId": "$.participants[*].participantId",
"agentSessionId": "$.participants[*].sessions[*].sessionId"
},
"translationMapDefaults": {},
"successTemplate": "{\"agentParticipantId\": ${successTemplateUtils.firstFromArray(\"${agentParticipantId}\",\"0\")},\"agentSessionId\": ${successTemplateUtils.firstFromArray(\"${agentSessionId}\",\"0\")} }"
}
Result:
It seems like I am most of the way there, but I am having a difficult time removing the participants and sessions arrays from the output. I was hoping someone could point me in the right direction.
In the end my goal is to use this API to extract the elements I need to execute this API in order to set a wrap-up code in a trigger/workflow configuration:
/api/v2/conversations/messages/{conversationId}/participants/{participantId}/communications/{communicationId}/wrapup
Thanks,
Matt
#ArchitectureandDesign
#Integrations
------------------------------
Matt Riedl
Acliviti, LLC
------------------------------