Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  WFM APIs and Null values in the return array. (intraday schedules)

    Posted 07-08-2025 18:48
    Hello,
    I need some help fine-tuning the translation map for an output array.
    I am trying to use the WFM APIs to retrieve schedule data at an intraday level so I can make routing decisions based on expected future staffing levels in a planning group. (rather than current logged in levels).
    /api/v2/workforcemanagement/businessunits/{businessUnitId}/intraday
    The raw JSON results show items in the array for each interval, with non-staffed intervals showing as Null (48 items in the array).
    When trying to apply a Translation Map, the Null items disappear, and I receive an array of only 28 items.
    The API returns no identifying information about the interval.  I can manually look at the results and see that my first interval with data starts at 7 AM in my sample, but we do not have consistent start times across all of our planning groups and have different hours on weekend days/holidays, so I cannot simply assume that they all always start at 7 AM.
    I am looking for a solution to this puzzle where the array stays intact with 48 items, the non-scheduled intervals showing as 0 staff, rather than Null.
    Translation Map
    {
      "translationMap": {
        "onQueueTimeSeconds": "$.result.intradayDataGroupings[0].scheduleDataPerInterval[*].onQueueTimeSeconds"
      },
      "translationMapDefaults": {
        "onQueueTimeSeconds": "0"
      },
      "successTemplate": "{\"Array1.onQueueTimeSeconds\":${onQueueTimeSeconds}}"
    }
    Resolve Translation Map
    {
      "rawResult": "{\n  \"status\" : \"Complete\",\n  \"operationId\" : \"d5f8d93a-9b0d-4dc2-b631-319d7e47c3ab\",\n  \"result\" : {\n    \"startDate\" : \"2025-07-08T04:00:00Z\",\n    \"endDate\" : \"2025-07-09T04:00:00Z\",\n    \"intervalLengthMinutes\" : 30,\n    \"categories\" : [ \"ScheduleData\" ],\n    \"shortTermForecast\" : {\n      \"id\" : \"143b6e86-3d4f-4e4a-b91c-49ce14687b9a\",\n      \"weekDate\" : \"2025-07-07\"\n    },\n    \"schedule\" : {\n      \"id\" : \"377927d1-c8de-403a-a975-1d81ee9f7dd0\",\n      \"weekDate\" : \"2025-07-07\"\n    },\n    \"intradayDataGroupings\" : [ {\n      \"mediaType\" : \"Voice\",\n      \"forecastDataPerInterval\" : [ ],\n      \"scheduleDataSummary\" : {\n        \"onQueueTimeSeconds\" : 3031080\n      },\n      \"scheduleDataPerInterval\" : [ null, null, null, null, null, null, null, null, null, null, null, null, null, null, {\n        \"onQueueTimeSeconds\" : 14400\n      }, {\n        \"onQueueTimeSeconds\" : 14400\n      }, {\n        \"onQueueTimeSeconds\" : 43200\n      }, {\n        \"onQueueTimeSeconds\" : 52500\n      }, {\n        \"onQueueTimeSeconds\" : 69300\n      }, {\n        \"onQueueTimeSeconds\" : 74700\n      }, {\n        \"onQueueTimeSeconds\" : 102300\n      }, {\n        \"onQueueTimeSeconds\" : 105900\n      }, {\n        \"onQueueTimeSeconds\" : 117000\n      }, {\n        \"onQueueTimeSeconds\" : 106800\n      }, {\n        \"onQueueTimeSeconds\" : 125100\n      }, {\n        \"onQueueTimeSeconds\" : 135300\n      }, {\n        \"onQueueTimeSeconds\" : 181920\n      }, {\n        \"onQueueTimeSeconds\" : 180060\n      }, {\n        \"onQueueTimeSeconds\" : 175200\n      }, {\n        \"onQueueTimeSeconds\" : 164700\n      }, {\n        \"onQueueTimeSeconds\" : 162600\n      }, {\n        \"onQueueTimeSeconds\" : 183780\n      }, {\n        \"onQueueTimeSeconds\" : 150600\n      }, {\n        \"onQueueTimeSeconds\" : 127320\n      }, {\n        \"onQueueTimeSeconds\" : 114300\n      }, {\n        \"onQueueTimeSeconds\" : 120600\n      }, {\n        \"onQueueTimeSeconds\" : 109500\n      }, {\n        \"onQueueTimeSeconds\" : 100500\n      }, {\n        \"onQueueTimeSeconds\" : 74100\n      }, {\n        \"onQueueTimeSeconds\" : 77100\n      }, {\n        \"onQueueTimeSeconds\" : 77700\n      }, {\n        \"onQueueTimeSeconds\" : 63000\n      }, {\n        \"onQueueTimeSeconds\" : 7200\n      }, null, null, null, null, null ],\n      \"performancePredictionDataPerInterval\" : [ ]\n    } ]\n  }\n}",
      "onQueueTimeSeconds": "[ 14400, 14400, 43200, 52500, 69300, 74700, 102300, 105900, 117000, 106800, 125100, 135300, 181920, 180060, 175200, 164700, 162600, 183780, 150600, 127320, 114300, 120600, 109500, 100500, 74100, 77100, 77700, 63000, 7200 ]"
    }

    Data returned in the Delevoper Center

    {
      "status": "Complete",
      "operationId": "6c2d09e6-a7ab-4130-bc8f-f963cec62113",
      "result": {
        "startDate": "2025-07-08T04:00:00Z",
        "endDate": "2025-07-09T04:00:00Z",
        "intervalLengthMinutes": 30,
        "categories": [
          "ScheduleData"
        ],
        "shortTermForecast": {
          "id": "143b6e86-3d4f-4e4a-b91c-49ce14687b9a",
          "weekDate": "2025-07-07"
        },
        "schedule": {
          "id": "377927d1-c8de-403a-a975-1d81ee9f7dd0",
          "weekDate": "2025-07-07"
        },
        "intradayDataGroupings": [
          {
            "mediaType": "Voice",
            "forecastDataPerInterval": [],
            "scheduleDataSummary": { "onQueueTimeSeconds": 3031080 },
            "scheduleDataPerInterval": [
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              { "onQueueTimeSeconds": 14400 },
              { "onQueueTimeSeconds": 14400 },
              { "onQueueTimeSeconds": 43200 },
              { "onQueueTimeSeconds": 52500 },
              { "onQueueTimeSeconds": 69300 },
              { "onQueueTimeSeconds": 74700 },
              { "onQueueTimeSeconds": 102300 },
              { "onQueueTimeSeconds": 105900 },
              { "onQueueTimeSeconds": 117000 },
              { "onQueueTimeSeconds": 106800 },
              { "onQueueTimeSeconds": 125100 },
              { "onQueueTimeSeconds": 135300 },
              { "onQueueTimeSeconds": 181920 },
              { "onQueueTimeSeconds": 180060 },
              { "onQueueTimeSeconds": 175200 },
              { "onQueueTimeSeconds": 164700 },
              { "onQueueTimeSeconds": 162600 },
              { "onQueueTimeSeconds": 183780 },
              { "onQueueTimeSeconds": 150600 },
              { "onQueueTimeSeconds": 127320 },
              { "onQueueTimeSeconds": 114300 },
              { "onQueueTimeSeconds": 120600 },
              { "onQueueTimeSeconds": 109500 },
              { "onQueueTimeSeconds": 100500 },
              { "onQueueTimeSeconds": 74100 },
              { "onQueueTimeSeconds": 77100 },
              { "onQueueTimeSeconds": 77700 },
              { "onQueueTimeSeconds": 63000 },
              { "onQueueTimeSeconds": 7200 },
              null,
              null,
              null,
              null,
              null
            ],
    	"performancePredictionDataPerInterval": []
          }
        ]
      }
    }

    #Architect
    #DataActions
    #PlatformAPI

    ------------------------------
    Peter DeMarco
    na
    ------------------------------


  • 2.  RE: WFM APIs and Null values in the return array. (intraday schedules)

    Posted 07-09-2025 10:05

    Here is one approach to replacing the nulls with a 0 value.

    {
      "translationMap": {},
      "translationMapDefaults": {},
      "successTemplate": "${rawResult.replace(\"null\", \"{${esc.quote}onQueueTimeSeconds${esc.quote}: 0 }\")}"
    }

    Because this string replacement happens after the translation map has been processed, you would need to setup the output contract to mirror the response you are getting back from the endpoint, and then use the result.intradayDataGroupings.scheduleDataPerInterval.onQueueTimeSeconds output (assuming you are using flattening)



    ------------------------------
    --Jason
    ------------------------------



  • 3.  RE: WFM APIs and Null values in the return array. (intraday schedules)

    Posted 07-09-2025 11:54

    Jason,

    Thank you for the suggestion, it's making progress in that the nulls are 0 and all entries are accounted for.  However, without the translation map, I'm running into difficulty setting up the output contact to actually output the data. I don't get errors, the contracts are just blank.

    I have tried variations on object/array/object/integer or following the structure I see object/array/object/array/object/integer - but can't flatten nested arrays, and it wasn't mapping the data anyway.

      "status": "Complete",
      "operationId": "a702f67c-892f-4c2f-932e-385750a67a4a",
      "result": {
        "startDate": "2025-07-09T04:00:00Z",
        "endDate": "2025-07-10T04:00:00Z",
        "intervalLengthMinutes": 30,
        "categories": [
          "ScheduleData"
        ],
        "shortTermForecast": {
          "id": "143b6e86-3d4f-4e4a-b91c-49ce14687b9a",
          "weekDate": "2025-07-07"
        },
        "schedule": {
          "id": "377927d1-c8de-403a-a975-1d81ee9f7dd0",
          "weekDate": "2025-07-07"
        },
        "intradayDataGroupings": [
          {
            "mediaType": "Voice",
            "forecastDataPerInterval": [],
            "scheduleDataSummary": {
              "onQueueTimeSeconds": 3152100
            },
            "scheduleDataPerInterval": [
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 12600  },
              { "onQueueTimeSeconds": 12600  },
              { "onQueueTimeSeconds": 45000  },
              { "onQueueTimeSeconds": 51600  },
              { "onQueueTimeSeconds": 70500  },
              { "onQueueTimeSeconds": 74700  },
              { "onQueueTimeSeconds": 101700  },
              { "onQueueTimeSeconds": 108000  },
              { "onQueueTimeSeconds": 122100  },
              { "onQueueTimeSeconds": 113100  },
              { "onQueueTimeSeconds": 119400  },
              { "onQueueTimeSeconds": 151800  },
              { "onQueueTimeSeconds": 190500  },
              { "onQueueTimeSeconds": 194100  },
              { "onQueueTimeSeconds": 177000  },
              { "onQueueTimeSeconds": 170400  },
              { "onQueueTimeSeconds": 176400  },
              { "onQueueTimeSeconds": 192000  },
              { "onQueueTimeSeconds": 157800  },
              { "onQueueTimeSeconds": 138900  },
              { "onQueueTimeSeconds": 122100  },
              { "onQueueTimeSeconds": 129300  },
              { "onQueueTimeSeconds": 116700  },
              { "onQueueTimeSeconds": 100200  },
              { "onQueueTimeSeconds": 77100  },
              { "onQueueTimeSeconds": 81300  },
              { "onQueueTimeSeconds": 77700  },
              { "onQueueTimeSeconds": 61200  },
              { "onQueueTimeSeconds": 6300  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0  },
              { "onQueueTimeSeconds": 0          }
            ],
            "performancePredictionDataPerInterval": []
          }
        ]
      }
    }


    ------------------------------
    Peter DeMarco
    na
    ------------------------------



  • 4.  RE: WFM APIs and Null values in the return array. (intraday schedules)

    Posted 07-09-2025 14:17

    Sorry, I completely missed how complex that response was, it would not be possible to get that through the flattener.

    {
      "translationMap": {
        "onQueueTimeSeconds": "$.result.intradayDataGroupings[0].scheduleDataPerInterval[*]"
      },
      "translationMapDefaults": {},
      "successTemplate": "{ \"onQueueTimeSeconds\" : ${onQueueTimeSeconds.replace(\"null\", \"0\").replace(\"{\n  ${esc.quote}onQueueTimeSeconds${esc.quote} : \", \"\").replace(\"\n}\", \"\")} }"
    }

    My new approach is to get the entire scheduleDataPerInterval and convert the nulls and objects into integers. Hopefully that gets you in a better place.



    ------------------------------
    --Jason
    ------------------------------



  • 5.  RE: WFM APIs and Null values in the return array. (intraday schedules)

    Posted 07-09-2025 16:24

    Thank you again. That was able to get me the return results that I need for the Data Action.



    ------------------------------
    Peter DeMarco
    na
    ------------------------------