# Batching keeps looping with larger data inputs

**URL:** <https://forum.bubble.io/t/batching-keeps-looping-with-larger-data-inputs/392801>\
**Category:** APIs\
**Created:** [March 7, 2026, 6:59pm UTC](https://forum.bubble.io/t/batching-keeps-looping-with-larger-data-inputs/392801 "2026-03-07T18:59:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonolsen89](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@simonolsen89](https://forum.bubble.io/u/simonolsen89)\
**Post date:** [March 7, 2026, 6:59pm UTC](https://forum.bubble.io/t/batching-keeps-looping-with-larger-data-inputs/392801/1 "2026-03-07T18:59:34Z")

</div>

Hi,

I have a Bubble app that generates **AI-powered Change Strategies** from a list of **Change Impact records**. The OpenAI integration works and the JSON parsing works, but I’m having trouble with the **batching workflow used to process large numbers of impacts safely**.

I need someone experienced with **Bubble backend workflows and recursive batching**

**Goal**

The system should:

1. Take all **ImpactType records** linked to a Project.

2. Process them in **batches** (e.g. batch size = 9).

3. Store each batch in an **ExtractedBatch** record with:

4. When all batches are complete, run B.E. WF **generate\_strategy** , which sends the combined impacts to **OpenAI** to produce a Change Strategy.

This previously worked but after adding batching safeguards it now **loops or produces incorrect batch ranges**.

* * *

# Current Data Structure

### ImpactType

Fields include:

- Project

- As Is

- To Be

- culture\_level

- customer\_level

- data\_level

- organisation\_level

- people\_level

- policies\_level

- process\_level

- systems\_level

- created date

### ChangeStrategy

Fields include:

- Project

- batch\_size

- batches\_done

- Impact\_Count\_ForProject

- overview\_text

- objectives\_text

- timeline\_text

- stakeholder\_text

- training\_text

- comms\_text

- hypercare\_text

- strategyJSON

- strategyJSON\_raw

- status

### ExtractedBatch

Fields include:

- strategy

- project

- batch\_number

- start\_index

- end\_index

- extracted\_text

- status

* * *

# Backend Workflows

## 1️⃣ extract\_batch

Parameters:

- Project

- Strategy

- batch\_number

- start\_index

- end\_index

Workflow does:

1. Create ExtractedBatch records

2. Build `extracted_text` using:

Search for ImpactTypes  
→ sorted by Created Date  
→ items from #start\_index  
→ items until #end\_index  
→ format as text

1. Schedule next batch using:

batch\_number + 1  
start\_index = end\_index + 1  
end\_index = end\_index + batch\_size

1. When all impacts processed → schedule `generate_strategy`.

Problem:  
The batching logic sometimes produces invalid ranges like:

start\_index = 10  
end\_index = 9

or loops continuously.

* * *

## 2️⃣ generate\_strategy

This workflow:

1. Combines all ExtractedBatch texts

2. Sends them to **OpenAI**

3. Receives a structured JSON change strategy

4. Saves it into ChangeStrategy fields

5. Runs `parse_strategy_json`

This part works correctly.

What screenshots would be helpful to share?

I’m not very techsavvy and as you can might read have gotten chatgpt to help me with most of it.

Thank you for taking the time to read all this.  
Simon

---

<div class="post-metadata">

**Author:** ![code-escapee](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/code-escapee/32/195485_2.png) [@code-escapee](https://forum.bubble.io/u/code-escapee)\
**Post date:** [March 9, 2026, 2:28am UTC](https://forum.bubble.io/t/batching-keeps-looping-with-larger-data-inputs/392801/2 "2026-03-09T02:28:48Z")

</div>

Kudos on trying but id caution this isnt the kind of workflow you can build, let alone maintain, without understanding what’s going on, especially considering the ramifications of such a WF going off the rails.

---

<div class="post-metadata">

**Author:** ![ferhatgulbahar](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ferhatgulbahar/32/123920_2.png) [@ferhatgulbahar](https://forum.bubble.io/u/ferhatgulbahar)\
**Post date:** [March 12, 2026, 5:19am UTC](https://forum.bubble.io/t/batching-keeps-looping-with-larger-data-inputs/392801/3 "2026-03-12T05:19:32Z")

</div>

Simon, can you share your app, or a copy of it with simplified version? Or maybe even video showing what you are trying to do.

It s hard for us to understand what you need to accomplish from your message
