Json translation map error

Hello,

can anyone point me what is the error in the following translation map?
Here is the JSON (output from Get a conversation by id API):

{
  "conversationEnd": "2024-03-27T16:12:23.831Z",
  "conversationId": "e63bed99-10b2-4db3-b714-3337a6084cff",
  "conversationStart": "2024-03-27T16:11:55.544Z",
  "divisionIds": [
    "8d34b842-9dd9-4823-a573-18b9cc7d6334"
  ],
  "mediaStatsMinConversationMos": 4.382980503298057,
  "mediaStatsMinConversationRFactor": 91.91201782226562,
  "originatingDirection": "inbound",
  "participants": [
    {
      "externalContactId": "0f638bdc-4d5d-436b-a819-e2e6b9267a29",
      "participantId": "2527ef74-0359-4aea-895e-de89f692077b",
      "participantName": "Mobile Number, Switzerland",
      "purpose": "external",
      "sessions": [
        {
          "ani": "tel:+4179135xxx",
          "direction": "inbound",
          "dnis": "tel:+4131528xxx",
          "edgeId": "b9606412-3538-4f7e-aea2-540f0efe9225",
          "mediaType": "voice",
          "protocolCallId": "J7C5N9V9PH5K55O0O1M13JVQD8@81.201.83.43",
          "provider": "Edge",
          "remoteNameDisplayable": "Mobile Number, Switzerland",
          "sessionDnis": "tel:+4131528xxx",
          "sessionId": "775ee5d7-3d08-4d3a-ad45-913baf735661",
          "mediaEndpointStats": [
            {
              "codecs": [
                "audio/opus"
              ],
              "eventTime": "2024-03-27T16:12:08.906Z",
              "maxLatencyMs": 30,
              "minMos": 4.882479204219975,
              "minRFactor": 92.4466552734375,
              "receivedPackets": 659
            },
            {
              "codecs": [
                "audio/PCMU"
              ],
              "discardedPackets": 3,
              "eventTime": "2024-03-27T16:12:23.890Z",
              "maxLatencyMs": 30,
              "minMos": 4.382980503298057,
              "minRFactor": 91.91201782226562,
              "receivedPackets": 1402
            }
          ],
          "metrics": [
            {
              "emitDate": "2024-03-27T16:11:55.598Z",
              "name": "nConnected",
              "value": 1
            },
            {
              "emitDate": "2024-03-27T16:12:23.830Z",
              "name": "tConnected",
              "value": 28232
            }
          ],
          "segments": [
            {
              "conference": false,
              "segmentEnd": "2024-03-27T16:11:55.598Z",
              "segmentStart": "2024-03-27T16:11:55.544Z",
              "segmentType": "system"
            },
            {
              "conference": false,
              "disconnectType": "endpoint",
              "segmentEnd": "2024-03-27T16:12:23.830Z",
              "segmentStart": "2024-03-27T16:11:55.598Z",
              "segmentType": "interact"
            }
          ]
        }
      ]
    },
    {
      "participantId": "59f548cb-fae1-451c-a2ee-79313b7c3fce",
      "participantName": "SC_GC_Voice_InboundFlow_OpenHours",
      "purpose": "ivr",
      "sessions": [
        {
          "ani": "tel:+417913xxx",
          "direction": "inbound",
          "dnis": "tel:+413152xxx",
          "edgeId": "b9606412-3538-4f7e-aea2-540f0efe9225",
          "mediaType": "voice",
          "peerId": "775ee5d7-3d08-4d3a-ad45-913baf735661",
          "protocolCallId": "84d13727-a16a-47bc-9ded-406f30775dda",
          "provider": "Edge",
          "remote": "Mobile Number, Switzerland",
          "remoteNameDisplayable": "Berne, Switzerland",
          "sessionDnis": "tel:+413152xxxx",
          "sessionId": "8969cf44-4ccc-4a09-94d1-547ac77563e8",
          "mediaEndpointStats": [
            {
              "codecs": [
                "audio/opus"
              ],
              "eventTime": "2024-03-27T16:12:08.906Z",
              "maxLatencyMs": 30,
              "minMos": 4.888272741811877,
              "minRFactor": 92.70230865478516,
              "receivedPackets": 660
            }
          ],
          "flow": {
            "endingLanguage": "de-de",
            "entryReason": "tel:+4131528xxxx",
            "entryType": "dnis",
            "exitReason": "TRANSFER",
            "flowId": "e66d95fd-fc9a-480f-9917-d43e7c874d5e",
            "flowName": "SC_GC_Voice_InboundFlow_OpenHours",
            "flowType": "INBOUNDCALL",
            "flowVersion": "52.0",
            "startingLanguage": "en-us",
            "transferTargetAddress": "8a323401-9acd-46c2-be08-5e68d4ecd5f2",
            "transferTargetName": "DCO_Pikett_DE",
            "transferType": "GROUP_VOICEMAIL"
          },
          "metrics": [
            {
              "emitDate": "2024-03-27T16:11:55.789Z",
              "name": "nFlow",
              "value": 1
            },
            {
              "emitDate": "2024-03-27T16:12:08.761Z",
              "name": "tIvr",
              "value": 13202
            },
            {
              "emitDate": "2024-03-27T16:12:08.769Z",
              "name": "tFlow",
              "value": 12980
            },
            {
              "emitDate": "2024-03-27T16:12:08.769Z",
              "name": "tFlowExit",
              "value": 12980
            }
          ],
          "segments": [
            {
              "conference": false,
              "segmentEnd": "2024-03-27T16:11:55.559Z",
              "segmentStart": "2024-03-27T16:11:55.551Z",
              "segmentType": "system"
            },
            {
              "conference": false,
              "disconnectType": "transfer",
              "segmentEnd": "2024-03-27T16:12:08.761Z",
              "segmentStart": "2024-03-27T16:11:55.559Z",
              "segmentType": "ivr",
              "sipResponseCodes": [
                410
              ]
            }
          ]
        }
      ]
    },
    {
      "participantId": "5db250ac-3747-407b-83f1-35b0d23a0d2f",
      "participantName": "8a323401-9acd-46c2-be08-5e68d4ecd5f2",
      "purpose": "voicemail",
      "sessions": [
        {
          "ani": "tel:+417913xxxx",
          "direction": "inbound",
          "dnis": "tel:+413152xxxx",
          "edgeId": "b9606412-3538-4f7e-aea2-540f0efe9225",
          "mediaType": "voice",
          "peerId": "775ee5d7-3d08-4d3a-ad45-913baf735661",
          "protocolCallId": "b9459e01-9ee6-4f99-9f1b-24dae1a0a1f3",
          "provider": "Edge",
          "remote": "Mobile Number, Switzerland",
          "remoteNameDisplayable": "8a323401-9acd-46c2-be08-5e68d4ecd5f2",
          "sessionDnis": "sip:8a323401-9acd-46c2-be08-5e68d4ecd5f2@127.0.0.1;language=de-DE;src=https://edge-proxy.euc2.pure.cloud/connector/v1/organizations/2f823112-47de-41d2-a18e-7cc28542eefa/defaults/ivr/0c8d5bb4-aedb-483d-86d3-006761e926c7/defaultentrypoint.vxml;user=voicemail",
          "sessionId": "9f9fe92f-8d8d-437d-b22e-e28e44970d85",
          "mediaEndpointStats": [
            {
              "codecs": [
                "audio/opus"
              ],
              "eventTime": "2024-03-27T16:12:23.890Z",
              "maxLatencyMs": 31,
              "minMos": 4.882177251729915,
              "minRFactor": 92.43347930908203,
              "receivedPackets": 752
            }
          ],
          "metrics": [
            {
              "emitDate": "2024-03-27T16:12:23.831Z",
              "name": "tVoicemail",
              "value": 15078
            }
          ],
          "segments": [
            {
              "conference": false,
              "segmentEnd": "2024-03-27T16:12:08.753Z",
              "segmentStart": "2024-03-27T16:12:08.742Z",
              "segmentType": "system"
            },
            {
              "conference": false,
              "disconnectType": "peer",
              "segmentEnd": "2024-03-27T16:12:23.831Z",
              "segmentStart": "2024-03-27T16:12:08.753Z",
              "segmentType": "interact"
            }
          ]
        }
      ]
    }
  ]
}

and this is my translation map:

{
  "translationMap": {
    "targetName": "$.participants[?(@.purpose =='ivr')].sessions[0].flow.transferTargetName"
  },
  "translationMapDefaults": {
    "targetName": "false"
  },
  "successTemplate": "{\"targetName\":${targetName}}"
}

I've tested this map on https://jsonpath.com/ and is OK but on Genesys is not. Anyone knows why?

Regards,
Mihai

Hello,

This is because your JSONPath expression returns an array of strings.
When you use a filter like the one you have for participants (participants[?(@.purpose =='ivr')]), JSONPath will return an array of values.
As your output (targetName) is likely a string, you have to extract a value from that array (e.g. the first one). There is a macro for this, which also allows defining a default value (if array is empty).

Something like the following should work I think:

{
  "translationMap": {
    "targetNameArray": "$.participants[?(@.purpose =='ivr')].sessions[0].flow.transferTargetName"
  },
  "translationMapDefaults": {
    "targetNameArray": "[]"
  },
  "successTemplate": "{\"targetName\": ${successTemplateUtils.firstFromArray(\"${targetNameArray}\", \"false\")} }"
}

Regards,

Hi,

OK now I understand.. so if there were more sections with porpose==ivr it would have returned all of them... so actually my response was an array with 1 element instead of a string..

Thank you very much for the explanation.

Regards,
Mihai

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