Legacy Dev Forum Posts

 View Only

Sign Up

Extracting data in Architect from nested JSON arrays

  • 1.  Extracting data in Architect from nested JSON arrays

    Posted 06-05-2025 18:44

    Vikki_Papesh | 2023-08-01 15:03:44 UTC | #1

    I'm trying to build an Architect flow that allows a user to key in an external ID, retrieve user information via SCIM API, then compile a subset of the data for use in creating an email.

    So far, I built a GC data action that pulls all the required information and populates it in Test in the action editor, but once published, I am not sure how to retrieve the data. There are nested arrays as the response is an array, and I am pulling in ACD skills and proficiencies which are also an array.

    I was able to see the attribute names in the flow, but when I try to use them (for instance, play them as TTS), the variables can't be selected in the communication builder.

    The issue is likely with my response template, but I don't know where to start. Right now, I have the default response template in place for testing.

    The output template is:

    {
        "type": "object",
        "properties": {
          "Resources": {
            "type": "array",
            "additionalItems": true,
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "active": {
                  "type": "boolean"
                },
                "userName": {
                  "type": "string"
                },
                "displayName": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                  "type": "object",
                  "properties": {
                    "department": {
                      "type": "string"
                    },
                    "manager": {
                      "type": "object",
                      "properties": {
                        "value": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": true
                    }
                  },
                  "additionalProperties": true
                },
                "urn:ietf:params:scim:schemas:extension:genesys:purecloud:2.0:User": {
                  "type": "object",
                  "properties": {
                    "routingSkills": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": true
                      }
                    }
                  },
                  "additionalProperties": true
                }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      }

    And the response template is:

    {
      "translationMap": {},
      "translationMapDefaults": {},
      "successTemplate": "${rawResult}"
    }

    The flow variables are:

    How do I get from point A to point B?


    Jason_Mathison | 2023-08-01 15:11:40 UTC | #2

    Do you at most get one result back from your SCIM lookup? If so, firstFromArray can help you unwrap the outer array into a single object. That would simplify getting at the data.

    You should be able to look at the final, flattened output, in the data action test mode to see what is getting returned to architect. That should at least help you figure out how to process the results.

    For additional help you would be best off to post an example of the response you are getting, with anything sensitive redacted.

    --Jason


    Vikki_Papesh | 2023-08-01 15:31:51 UTC | #3

    The external ID returns only one result. All the returned data is a single entry with the exception of skills, which varies by the number of assigned skills. I don't need proficiencies, nor need to call skills, just need a text list of those assigned. I could even "assume" a maximum of 10 assigned skills and just provide a default or null value for less than 10.

    {
        "totalResults": 1,
        "startIndex": 1,
        "itemsPerPage": 1,
        "Resources": [
          {
            "id": "abcdefg-1234-5678-9012-hijklmnopqrs",
            "schemas": [
              "urn:ietf:params:scim:schemas:core:2.0:User",
              "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
              "urn:ietf:params:scim:schemas:extension:genesys:purecloud:2.0:User"
            ],
            "active": true,
            "userName": "user@email.com",
            "displayName": "Annie Agent",
            "title": "Specialist 1, Tech Support",
            "emails": [
              {
                "value": "user@email.com",
                "type": "other",
                "primary": true
              }
            ],
            "roles": [
              {
                "value": "WFM - Agent"
              },
              {
                "value": "Agent"
              },
              {
                "value": "User"
              },
              {
                "value": "InteractionSync"
              },
              {
                "value": "employee"
              },
              {
                "value": "Business User"
              }
            ],
            "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
              "division": "Home",
              "department": "Customer Tech Support",
              "manager": {
                "value": "xxxxxxx-xxxx-xxx-xxxx-xxxxxxxxxxxx",
                "$ref": "/api/v2/scim/v2/users/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
              },
              "employeeNumber": "011223"
            },
            "urn:ietf:params:scim:schemas:extension:genesys:purecloud:2.0:User": {
              "routingSkills": [
                {
                  "name": "Skill1",
                  "proficiency": 2
                },
                {
                  "name": "Skill2",
                  "proficiency": 3
                },
                {
                  "name": "Skill3",
                  "proficiency": 3
                },
                {
                  "name": "Skill4",
                  "proficiency": 2
                },
                {
                  "name": "Skill5",
                  "proficiency": 3
                },
                {
                  "name": "Skill6",
                  "proficiency": 3
                },
                {
                  "name": "Skill7",
                  "proficiency": 3
                }
              ]
            },
            "meta": {
              "resourceType": "User",
              "lastModified": "2023-07-31T19:01:45.000Z",
              "location": "/api/v2/scim/v2/users/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
              "version": "W/\"23\""
            }
          }
        ],
        "schemas": [
          "urn:ietf:params:scim:api:messages:2.0:ListResponse"
        ]
      }

    Vikki_Papesh | 2023-08-01 16:33:42 UTC | #4

    Jason_Mathison, post:2, topic:21265, full:true
    Do you at most get one result back from your SCIM lookup? If so, firstFromArray can help you unwrap the outer array into a single object. That would simplify getting at the data.

    You should be able to look at the final, flattened output, in the data action test mode to see what is getting returned to architect. That should at least help you figure out how to process the results.

    For additional help you would be best off to post an example of the response you are getting, with anything sensitive redacted.

    --Jason

    I forgot to mention that the nested skills array prevents me from viewing flattened data. So the output provided is the JSON response, unflattened.


    Jason_Mathison | 2023-08-01 16:55:48 UTC | #5

    A jsonpath expression along the lines of

    Resources[0].['urn:ietf:params:scim:schemas:extension:genesys:purecloud:2.0:User'].routingSkills[*].name

    Seems to get a list of skill names. I used https://www.javainuse.com/jsonpath to come up with that jsonpath expression.

    --Jason


    Vikki_Papesh | 2023-08-01 17:10:40 UTC | #6

    Jason_Mathison, post:5, topic:21265
    Resources[0].['urn:ietf:params:scim:schemas:extension:genesys:purecloud:2.0:User'].routingSkills[*].name

    Thank you, Jason. I'll give this a try!


    system | 2023-09-01 17:11:31 UTC | #7

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


    This post was migrated from the old Developer Forum.

    ref: 21265