Skip to main content
All CollectionsBuild AutomationsOperators
Torq's Collect Operator: Streamline Loop Results Aggregation
Torq's Collect Operator: Streamline Loop Results Aggregation

Learn how to use the Collect operator to collect the results of a loop in an easily readable array.

Updated over a week ago

The Collect operator in Torq is a vital tool for efficiently gathering data from loop iterations into a cohesive array. This functionality simplifies data handling in complex workflows, allowing you to reference results in subsequent steps with ease.

Key Considerations for Using the Collect Operator

  • Placement: The Collect operator must be used within a loop.

  • Data Limit: The operator shouldn't be used to collect more than 1MB of data.

  • Iteration Handling: Each iteration clears the previous results in the array. To maintain all results in a single array, utilize additional Collect operators in the parent loop.

Flatten Results Option

The Flatten Results setting combines all iteration inputs into a single array, simplifying data management for scenarios like paginated results. By default, each iteration's results are stored as separate array items.

Step-by-Step Guide to Using the Collect Operator

  1. Initiate a Loop: Start by adding a Loop operator from the bottom of the Steps Library.

  2. Add the Collect Operator: Hover over the Loop operator to reveal and select the Collect operator. Place it inside the loop.

  3. Configure Collection: In the Collect operator's settings, specify the path to the data you want to gather from each loop iteration, such as $.ask_a_question.slack_response for collecting user responses.

  4. (Optional) Multiple Collections: To segment the collected data, you can add more Collect operators within the same loop. For instance, to capture only the email addresses of users who declined a request set the path to $.loop_value.

Did this answer your question?