Issue with JSON Parsing in OpenAI Response

Hi everyone,

I have created a scenario that triggers an Apify actor to crawl a webpage and provide the content as input to an OpenAI module. OpenAI needs to analyze the content and produce a JSON text that organizes the information into 4 different values.

PROBLEM 1:
The response from OpenAI contains characters before the JSON text, making the JSON invalid:

I have tried specifying in the prompt that nothing should be written outside the curly braces, but sometimes OpenAI still adds extra text, causing the scenario to break.

How can I prevent this issue? Are there any ways in Make.com to strip text outside of the curly braces?

PROBLEM 2:
Sometimes the crawling of the page takes longer than the Apify - Run Actor module waits, causing the scenario to proceed without having received the page content. I have tried setting a longer timeout, but it seems to have no effect.

How can I ensure that the scenario waits long enough for the Apify actor to complete the crawling? Are there any settings in Make.com to handle longer waits?

Has anyone faced similar issues or can suggest solutions? Any help would be greatly appreciated!

1 Like

Yes, you can use the built-in function replace in module [10]

e.g.:

{{ replace(11.json; "/(^```\w*\s*|\s*```$)/g"; emptystring) }}

For more information, see the function documentation in the Help Center.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

4 Likes

Thank you @samliew

What about the problem 2?

No problem, glad I could help!

Sorry, I am unfamiliar with question 2, hence I strongly suggest you open a separate thread for each question.

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Hope this helps! Let me know if there are any further questions or issues.

@samliew