Normalizing Product Data for AI
When working with AI Agents, raw JSON responses from APIs often need cleaning and restructuring before they can be used effectively. The goal of this step is to take the unprocessed data from the Rainforest HTTP node, simplify it into a single, LLM-friendly data packet, and feed it into the AI Agent without running into the dreaded "[object Object]" issue.
Check what the HTTP node actually returned
The Rainforest HTTP Request already provides everything you need to build a meaningful product summary:
- asin;
- title;
- brand;
- categories;
- rating and total_reviews;
- images;
- bullet points;
- rank / BSR;
- offers and buy box;
- keyword list.
That's more than enough data for AI analysis, so there's no need to make another request. Instead, you'll work with what's already available.
If you drag the product object into the AI Agent’s context field, you'll notice that n8n shows [object Object]. This happens because the context field expects plain text, not a nested object. Even though LLMs can read JSON, the field itself only accepts a string, so you need to flatten and stringify the data first.
Normalising the Data with a Code Node
Right after the HTTP Request, add a Code node. You can use ChatGPT to generate the transformation logic for you, simply share the Rainforest output and ask:
Paste that code into the node, set it to run once for all items, and execute. You should now see one clean object with all product data grouped and ready.
If the AI Agent still shows [object Object], it means the structure is correct but still not stringified. In that case, update your Code node to output:
return [{ json: { data: JSON.stringify(items[0].json) } }];
or use an Aggregate node to merge everything into one list before stringifying.
You're not actually coding here, just testing code generated by an LLM. If something fails, copy the exact error message back into ChatGPT and let it fix it for you.
Connecting to the AI Agent
Once the output looks right, add your AI Agent node (Gemini, OpenAI, etc.) and paste your system prompt in the Instruction field. For example:
Execute the workflow. The model should now generate a clean, structured summary including:
- A short product snapshot;
- What's working (ratings, A+ content, badges);
- What's hurting (few images, missing keywords);
- Fixes and keyword ideas.
If you want the model to ask clarifying questions before responding, just add this line to your prompt:
Tack för dina kommentarer!
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 4.17
Normalizing Product Data for AI
Svep för att visa menyn
When working with AI Agents, raw JSON responses from APIs often need cleaning and restructuring before they can be used effectively. The goal of this step is to take the unprocessed data from the Rainforest HTTP node, simplify it into a single, LLM-friendly data packet, and feed it into the AI Agent without running into the dreaded "[object Object]" issue.
Check what the HTTP node actually returned
The Rainforest HTTP Request already provides everything you need to build a meaningful product summary:
- asin;
- title;
- brand;
- categories;
- rating and total_reviews;
- images;
- bullet points;
- rank / BSR;
- offers and buy box;
- keyword list.
That's more than enough data for AI analysis, so there's no need to make another request. Instead, you'll work with what's already available.
If you drag the product object into the AI Agent’s context field, you'll notice that n8n shows [object Object]. This happens because the context field expects plain text, not a nested object. Even though LLMs can read JSON, the field itself only accepts a string, so you need to flatten and stringify the data first.
Normalising the Data with a Code Node
Right after the HTTP Request, add a Code node. You can use ChatGPT to generate the transformation logic for you, simply share the Rainforest output and ask:
Paste that code into the node, set it to run once for all items, and execute. You should now see one clean object with all product data grouped and ready.
If the AI Agent still shows [object Object], it means the structure is correct but still not stringified. In that case, update your Code node to output:
return [{ json: { data: JSON.stringify(items[0].json) } }];
or use an Aggregate node to merge everything into one list before stringifying.
You're not actually coding here, just testing code generated by an LLM. If something fails, copy the exact error message back into ChatGPT and let it fix it for you.
Connecting to the AI Agent
Once the output looks right, add your AI Agent node (Gemini, OpenAI, etc.) and paste your system prompt in the Instruction field. For example:
Execute the workflow. The model should now generate a clean, structured summary including:
- A short product snapshot;
- What's working (ratings, A+ content, badges);
- What's hurting (few images, missing keywords);
- Fixes and keyword ideas.
If you want the model to ask clarifying questions before responding, just add this line to your prompt:
Tack för dina kommentarer!