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:
-
Take all ImpactType records linked to a Project.
-
Process them in batches (e.g. batch size = 9).
-
Store each batch in an ExtractedBatch record with:
-
start_index
-
end_index
-
extracted_text
-
-
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
extract_batch
Parameters:
-
Project
-
Strategy
-
batch_number
-
start_index
-
end_index
Workflow does:
-
Create ExtractedBatch records
-
Build
extracted_textusing:
Search for ImpactTypes
→ sorted by Created Date
→ items from #start_index
→ items until #end_index
→ format as text
- Schedule next batch using:
batch_number + 1
start_index = end_index + 1
end_index = end_index + batch_size
- 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.
generate_strategy
This workflow:
-
Combines all ExtractedBatch texts
-
Sends them to OpenAI
-
Receives a structured JSON change strategy
-
Saves it into ChangeStrategy fields
-
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