Save only certain lines from GPT 3.5 API Response


I am receiving a block of data from my API call but want to save only certain lines of this response to the Bubble Database. Current method I’m using is extremely inefficient and would appreciate any guidance.

For example, the API call returns the below raw output:

"Concept 1

ITEM1: After a mother’s eggs hatch, one of the ducklings is perceived as ugly

ITEM2: He wanders away

ITEM3: He finds a home with an old woman"

I’d like to automatically save the words after ITEM1 (After a mother’s eggs hatch, one of the ducklings is perceived as ugly) into a new database field ('Concept 1 Item 1). Want to do the same for the words after ITEM2 (He wanders away) and ITEM 3.

Is there a way for Bubble to automatically identify only the words desired for each field and save them?

The API sometimes includes line spaces between the different items (HEADLINE, PIC1 and PIC2) and sometimes does not so do not want to use split by: item number.

My current solution is really clunky.

  • I have a multiline input capturing the Raw API response.
  • Then, I have multiple multiline inputs that try and pick out individual lines of text using value: split by item number:2 → This often breaks because sometimes the different items have an empty line between them and sometimes not.

You may check the API documentation to see if you can request for the response to come as a JSON object instead of a String. That way you could just reference “Response’s Item 1”.