Hi,
I'm building an integration to external system over Genesys Cloud API as a Data Action. The problem I'm facing is that the JSON response coming back from the client's system has about 200 individual values that I need to write into Architect call flow and route the call based on the received data.
The JSON response has multiple arrays and sub arrays that's making the Data Action configuration a major pain with about 1500 lines of code if I use translation maps, defaults etc. The two approaches to get the Data Action configured and working I found so far are:
Option 1)
-
Configure Input Contract Schema with all necessary variables
-
Configure Output Contract Schema with all necessary variables using structure that reflects the arrays and sub arrays inside the JSON response
-
Configure the Request Body Template with
${input.rawRequest} -
Configure the Response with
{
"translationMap": {},
"translationMapDefaults": {},
"successTemplate": "${rawResult}"
}
This simplifies the whole Data action setup, because the Response doesn't need to have every value described inside the:
- translationMap
- translationMapDefaults
- successTemplate
We let Genesys Data Action to parse the raw result and match it against the Output Contract Schema
Problem here is that Genesys parses all the array variables into Collection Variables inside Genesys Cloud Architect flow. What I can't work out is how to automatically assign values from string collection into individual string variables.
E.g.
Flow.StringCollection[0] == Flow.String0
Flow.StringCollection[1] == Flow.String1
I have about 1500 individual string collection values to use inside the architect flow and I want to store each into an individual string variable, rather than reference the collection position every time.
I was thinking to count the values inside the string collection and then loop the Update Data action to store each of the String collection values into individual String variables.
This is where I hit an issue, Flow.variableNames cannot be created using Expressions. They only support Literal mode for name of the variable in Architect.
Is there a way to get around this limitation of variable names not supporting Expression mode? Can we somehow dynamically generate variable name incremented by 1 for example inside a loop? Or is there an improvement coming in the future?
I know that I can use Set Participant Data that supports name creation using Expression mode, but that defeats the purpose of saving time in creating complex and long Data action maps.
You can see that Set Participant Data name can eb set using Expression mode. For some reason Flow.variable names don't have this option.
Option 2)
The second option, and the one I decided to use at the end, is to use Data Action Translation Maps and translate each array value into a direct value before it get's passed to Architect. This way, architect will get the JSON response values as individual Flow.variables and not collections.
The drawback of this approach is that it requires me to write 600 lines of code for:
- translationMap
- translationMapDefaults
- successTemplate
I was hoping there is a simpler way to do it.
Thanks for any advice on how to approach this and save time with building more complex data actions with arrays in future.