Parsing JSON Response from API Call and Using as Action in Workflow

I’m currently working on an application where I’m using an external API (OpenAI’s API) that returns data as a JSON string. The API is properly set up and functioning as expected, returning responses in the following format:

{
“id”: “chatcmpl-7EvxH6PxT3Cr3mHhiqJx4Qz35O5tV”,
“object”: “chat.completion”,
“created”: 1683793727,
“model”: “gpt-4-0314”,
“usage”: {
“prompt_tokens”: 1387,
“completion_tokens”: 296,
“total_tokens”: 1683
},
“choices”: [
{
“message”: {
“role”: “assistant”,
“content”: "
{
“Problem1”: “Difficult navigation and customization of settings”,\n “Quote1”: “Well, to be honest, it wasn’t very user-friendly. I found it hard to navigate and customize the settings to my preferences.”,\n “Problem2”: “Overwhelmed by the number of options and cluttered interface”,\n “Quote2”: “When I first signed up for Loom, I was overwhelmed by the number of options available. The interface also felt cluttered, and it was hard to find the specific settings I needed.”,\n “Problem3”: “Issues with video quality and limited optimization options”,\n “Quote3”: “One thing I noticed was that the video quality wasn’t as good as I expected. It would be great if there were more options for optimizing the video quality.”,\n “Problem4”: “Technical difficulties during recording process, like audio issues and video quality drops”,\n “Quote4”: “Yes, there were a few issues. At one point, the audio cut out and I had to stop and start over again. And there were a few times where the video quality dropped unexpectedly.”,\n “Problem5”: “Lack of video editing options, such as annotations or captions”,\n “Quote5”: “I think it would be helpful if there were more options for editing the videos after they’ve been recorded. It would be great if I could add annotations or captions to the videos to make them more informative.”\n}"
},
“finish_reason”: “stop”,
“index”: 0
}
]
}

The ‘content’ field in the response contains a JSON-formatted string that I want to parse and use to update fields in a data type within my application. The data type has fields corresponding to the keys in the JSON string (Problem1, Quote1, Problem2, Quote2, etc.).

I am currently struggling to find an efficient way to parse this JSON string and use the values within a workflow without resorting to regex or similar methods. I tried creating a plugin that would take the JSON string and return an action that could be used in the workflow, but I encountered issues with undefined or empty input.

I would appreciate any advice or guidance on how to best approach this problem. How can I efficiently parse the JSON string and use the values in a workflow to update fields in a data type?

Thank you in advance for your help!

2 Likes

Hello,

Have you found any solution? I am also struggling with this.

Yup, I’ve built a custom plugin using GPT4

Ask it to act as a bubble.io developer and help you build this plugin with instructions

For those of us who don’t know how to build custom plugins, is there a way to do this by just using Bubble functionality? I also tried Regex and it didn’t work.

I just asked ChatGPT to explain to me how to build it

Have you figured it out? @nithinsudheer7 @mkapadia13

Check this youtube video - https://youtu.be/KrFsERqxy1Y?si=5yhHysRus3bdYBfZ