parse data
Hi, might be a silly question but how do I parse certain response data and then pass it onto the next request. For example; i'm creating a workflow where a supabase DB query gets client information - certain aspects of the data is then parsed to be sent to openai's api -> then i'd like to store the response into a supabase create row node.
Solution:Jump to solution
Hey @wino, after looking at your workflow I think it's possible to get it working with only one loop node. You can move the Create Row node inside of the first loop node - after the Text Generator node. From there you can reference the output of the Text Generator node to save the program data.
10 Replies
AI Support Bot Information
<@795796877949272116> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human!
Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers.
Please note: Team members will review and answer the questions on best efforts basis.
AI Response
To create a workflow where you query client information from a Supabase database, parse the response data to send to OpenAI's API, and finally store the OpenAI API response back into the Supabase database, follow these general steps:
1. Query Client Information from Supabase DB
- Node: Supabase Query
- Action: Fetch the client data from Supabase.
2. Parse the Response Data
- Node: Use a Utility Node like an Empty Script or a custom utility to parse the JSON response from the Supabase Query node.
- Action: Extract the specific fields you need from the client data.
3. Send Data to OpenAI API
- Node: OpenAI Assistant
- Action: Use the extracted data from the previous step in the prompt or parameters to send a request to OpenAI's API.
4. Store the Response in Supabase
- Node: Supabase Create Row
- Action: Pass the OpenAI API response data to this node to store it back into the Supabase database.
Practical Example from BuildShip:
You can check out the supabase CRUD tutorial for detailed steps on CRUD (Create, Read, Update, Delete) operations with Supabase. For parsing and handling JSON fields, dot notation in the expression editor can be utilized【4:0†source】.
Example Node Configuration
1. Supabase Query Node Configuration:
- Endpoint: Your Supabase URL
- Method: POST (or appropriate method)
- SQL Query:
4. Supabase Create Row Node Configuration: - Endpoint: Your Supabase URL - Method: POST - Body: Pass the OpenAI response to this node to store it in the Supabase table. - Example Body: Additional Resources: - Node Output Configuration guide for managing responses and passing data between nodes .
For further details, you can explore more templates and resources directly on BuildShip to find pre-built solutions that might fit your use case . If these steps don’t fully address your use case, consider reaching out via BuildShip's in-app support for more personalized assistance.
SELECT * FROM clients WHERE client_id = '123'
2. Utility Node to Parse Data:
- Node Script Example:
3. OpenAI Assistant Node Configuration:
- Input Parameters: Pass the parsed data relevantDataForOpenAI
to the API request.
4. Supabase Create Row Node Configuration: - Endpoint: Your Supabase URL - Method: POST - Body: Pass the OpenAI response to this node to store it in the Supabase table. - Example Body: Additional Resources: - Node Output Configuration guide for managing responses and passing data between nodes .
For further details, you can explore more templates and resources directly on BuildShip to find pre-built solutions that might fit your use case . If these steps don’t fully address your use case, consider reaching out via BuildShip's in-app support for more personalized assistance.
BuildShip AI Support
Hi @wino, nodes can access the outputs of other nodes so it's just a matter of accessing the exact fields from your data that you want to parse. Here's a slightly different workflow that might give you some idea how to do this - load data from an API call and insert into supabase: https://buildship.app/remix/6582d840-ddac-479e-a646-45111f1d96d7
BuildShip - Visual backend workflow builder
Visually build workflows and powerful backend logic for your apps. Powered by AI, connect to anything with or without code.
Hey Luis - this is a massive help and was exactly what I was after. Am i still able to reference things in a previous loop? I.e. i've successfully referenced client data and sent it to chat gpt's api for context, then looped and sent that data to supabase. With the chat gpt's data i'd also like to reference the client_id that was only referenced in the first loop (not in the data sent to chat gpt).
if that made sense
If I don't reference the client_id, it works fine and create a row with the correct data in the correct column but as soon as I try and reference the client_id it gives me a syntax error
"invalid input syntax for type uuid: "undefined""
Hey @wino, I’m not sure I follow. If you can submit your workflow via in app support then I may be able to further assist you.
@Luis I just submitted the workflow in the support popup
Solution
Hey @wino, after looking at your workflow I think it's possible to get it working with only one loop node. You can move the Create Row node inside of the first loop node - after the Text Generator node. From there you can reference the output of the Text Generator node to save the program data.
Here's a workflow that does this. You'll just need to add back your API keys. https://buildship.app/remix/cb4d40eb-ba99-4263-a9b8-3153d86261da
BuildShip - Visual backend workflow builder
Visually build workflows and powerful backend logic for your apps. Powered by AI, connect to anything with or without code.
@Luis thanks heaps that worked perfectly.
Also i noticed with your workflows you add a status 200 ok - can i ask why?
It’s just to indicate a successful execution of the workflow, but useful to also return any data you want back to the client.