Loop block iteration over JSON array from Data Action

What is the standard approach to iterate over a JSON array returned from a Data Action using the Loop block in Architect?

My Data Action returns a payload like [{"id": 1}, {"id": 2}]. The Loop block expects a collection, but passing the raw response results in a single iteration over the object keys rather than the array items. I need to extract each object for subsequent processing.

Environment details:

  • CXone Architect
  • Data Action returning JSON array
  • Loop block configuration

I typically get around this by ensuring the Data Action returns a wrapper object with a specific array field, as Architect loops require a named collection path.

Error: Loop block expects a collection, but passing the raw response results in a single iteration over the object keys

{
 "items": [{"id": 1}, {"id": 2}]
}

Point the Loop block to response.items instead of response.

I typically get around this by wrapping the array in an object. architect loop blocks fail on raw arrays. return { "data": [...] } from the data action. then set loop collection to {{response.data}}. this prevents the key iteration bug. it is a known limitation with direct array returns in cxone architect flows.

Check your Data Action response schema because wrapping the array is necessary but insufficient if the downstream analytics pipeline expects flat interaction data. The suggestion above fixes the Loop block iteration, but it creates a nested object structure that often breaks the Set Participant Data action if you try to pass {{currentItem.id}} directly into a custom attribute for speech analytics. I’ve seen this cause silent failures where the transcript metadata gets corrupted, leading to inaccurate sentiment scores. Ensure your Data Action uses the application/json content-type explicitly and that the returned objects are strictly serializable. Also, verify that the Loop block’s currentItem variable is not being overwritten by parallel flows. If you are feeding this into a speech analytics API call later, remember that the view:analytics scope might be restrictive if the data hasn’t propagated yet, so add a retry mechanism with exponential backoff in the Architect flow to handle eventual consistency issues.

TL;DR: Wrapping helps, but verify your mock server’s JSON parsing.

Ah, this is a known issue in local integration tests. If your Docker Compose mock server doesn’t handle the wrapper correctly, the Loop block receives null. Ensure your mock-gc service returns valid JSON with the wrapper.

services:
 mock-gc:
 environment:
 - GC_RESPONSE_WRAPPER=true

This aligns the local schema with Architect’s expectations.