Create new database object per new line in API response

Maybe this have been answered before but I couldn’t find something that helped me with my question.

The OpenAI API gives me a response that’s separated by new lines that looks like this:
"1. Some text\n2. More text\n3. More text.\n4. Something else"

I want to create a new database object for each one of this lines. Using my example, I would create 4 new objects. What would I need to do after this step in my workflow?

Screenshot 2023-04-30 at 17.19.44

I really appreciate it if you can point me in the right direction

1 Like

I’m going to answer myself in case someone else runs into a similar problem. First of all, you need to have the paid Bubble version in order to run “Backend workflows”.

  1. Split the OpenAI / ChatGPT response into new lines (\n). I used a plugin called “Split text by \n returns list” but there are probably cleaner ways to do this
  2. Use recursiveness to loop though the list, converting each line into the object you need. I used this tutorial: Recursive workflows in Bubble (OR, HOW TO LOOP THROUGH A LIST) - YouTube

Hope it helps someone.