SyntaxError: Unexpected token O in JSON at position 0
at JSON.parse ()
at Object.code (/root/codes/step_4/index.js:5:22)
at Object. (webpack://activepieces/engine/src/lib/executors/code-executer.ts:9:32)
at Generator.next ()
at fulfilled (webpack://activepieces/node_modules/tslib/tslib.es6.mjs:118:41)
Unfortunately, as a new user I cannot attach screenshots.
Make sure the âAsk ChatGPTâ step doesnât give invalid JSON format. If it does, fix the âquestion fieldâ by adding new prompts or editing existing ones to ensure the response is valid.
Sometimes OpenAI returns the data in JSON format, sometimes it returns the data in JSON but contains markdown code block iâŚe it starts with â```â (3 backticks)
Step #1: Make sure you include the text âReturn response in JSON formatâ in your prompt - This doesnât always return the data in JSON but it is required
Step #2: Make sure the variable name youâre using is chatgpt and it contains the entire response sent by OpenAI