My API request to SNOW returns an array of size 19 to 25 depending on the unique ID that I send as the input. My question is , Is there a way to dynamically create variables for each element of the result array? I will be using these variables in a script which will list these array elements as a 'dropdown' from which the agent will choose one element.
I tried exploring velocity macros and other VTL features like #foreach (Which would be useful in my case, but found that Genesys doesnt support it from another article in the forum), $util.parse which is not supported as well (I believe so!). I tried using the response template like below, where I am first trying for one element from my result array,
It keeps failing with the error,
10. Apply output transformation: Transform failed to process result using 'successTemplate' template due to error:'Object 'java.lang.String' does not contain method get(java.lang.Integer) at successTemplate**
Is there any other way to do this? Please do correct my template if that will help.
The issue is that after processing the translationMap, categories is a string that happens to have a json array in it. It is not actually a list that you can reference individual items from.
This post gives an example of splitting a string back up into an array where you could can reference items from it
However, since the number of possible variables has a limit, this approach might actually be easier to deal with: