{
  "id": "TDTskGWqylQauVHz",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Analyze WooCommerce product reviews sentiment",
  "tags": [],
  "nodes": [
    {
      "id": "9a61bab2-edb7-4916-b76e-0246b3b73159",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -656,
        -400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f8e43e1e-bdfe-4e70-a51f-2fce2cf6c81a",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        368,
        -640
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "65bc4038-be6e-4a66-8b7d-58d846e82748",
      "name": "Sentiment Analysis",
      "type": "@n8n/n8n-nodes-langchain.sentimentAnalysis",
      "position": [
        560,
        -64
      ],
      "parameters": {
        "options": {
          "enableAutoFixing": true,
          "includeDetailedResults": true
        },
        "inputText": "={{ $json.review }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "6620b077-504b-4b43-985e-55aca7578318",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        496,
        160
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "3ac738c0-da27-41ba-ad0b-804d36b99d61",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1568,
        -944
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "c6d6e6fd-23a7-41a6-a358-e4522465e63d",
      "name": "Get a product",
      "type": "n8n-nodes-base.wooCommerce",
      "position": [
        384,
        -1216
      ],
      "parameters": {
        "operation": "get",
        "productId": "={{ $json.product_id }}"
      },
      "credentials": {
        "wooCommerceApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e3041012-9673-4bc3-8c2e-94f6d22b0bda",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        960,
        -1200
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "973f7e5a-5237-4036-9e80-f2832154de10",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2176,
        -1200
      ],
      "parameters": {
        "sendTo": "YOUR_EMAIL",
        "message": "={{ $json.text }}",
        "options": {},
        "subject": "Product review"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8afd8dc3-ee24-4176-8b68-72e695ac5fd9",
      "name": "Product ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -368,
        -400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "649f6c6c-5aba-4cd6-ac29-58e85e5feb53",
              "name": "product_id",
              "type": "string",
              "value": "PRODUCT_ID"
            },
            {
              "id": "f0fef9f7-50d9-4fad-bb60-0302c78887ad",
              "name": "woocommerce_url",
              "type": "string",
              "value": "YOUR_WEBSITE"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9cd9bc15-5ee0-422a-a76e-079bd7c032cc",
      "name": "Set review",
      "type": "n8n-nodes-base.set",
      "position": [
        1120,
        -32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0a97a044-47e8-432e-a6ad-3f11ea10c218",
              "name": "sentiment",
              "type": "string",
              "value": "={{ $json.sentimentAnalysis.category }}"
            },
            {
              "id": "25426edf-cf8d-4266-b2ec-8fc7c74c2d2f",
              "name": "strenght",
              "type": "string",
              "value": "={{ $json.sentimentAnalysis.strength }}"
            },
            {
              "id": "2c963fa4-9d23-4d3e-a548-3dd44a9d6c0f",
              "name": "confidence",
              "type": "string",
              "value": "={{ $json.sentimentAnalysis.confidence }}"
            },
            {
              "id": "8053756f-17cb-4a44-bf79-f77b40c163d9",
              "name": "review",
              "type": "string",
              "value": "={{ $json.review }}"
            },
            {
              "id": "cb89435f-7a68-4284-b36c-00b69e37deca",
              "name": "reviewer",
              "type": "string",
              "value": "={{ $json.reviewer }}"
            },
            {
              "id": "fe884073-d85e-4a81-a2f4-3d3d46a96fec",
              "name": "reviewer_email",
              "type": "string",
              "value": "={{ $json.reviewer_email }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "49e5d138-54cd-476f-8913-116c2b2f43e6",
      "name": "Aggregate reviews",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        672,
        -1008
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "sentiment"
      },
      "typeVersion": 1
    },
    {
      "id": "fdbfc681-48cc-41ea-a358-d679f902bd01",
      "name": "Set vars for chart",
      "type": "n8n-nodes-base.code",
      "position": [
        864,
        -656
      ],
      "parameters": {
        "jsCode": "const labels = [];\nconst data = [];\nconst colors = [];\n\nitems.forEach((item, index) => {\n  labels.push(\n    `${item.json.sentiment} ${index + 1}`\n  );\n\n  data.push(1);\n\n  if (item.json.sentiment === 'Positive') {\n    colors.push('#4CAF50'); \n  } else if (item.json.sentiment === 'Negative') {\n    colors.push('#F44336'); \n  } else {\n    colors.push('#FFC107'); \n  }\n});\n\nreturn [{\n  json: {\n    labels,\n    data,\n    colors\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0e07c46d-ae3a-4fed-9e1f-ff95e293ac3b",
      "name": "Product Insights Analyst",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1280,
        -1200
      ],
      "parameters": {
        "text": "=Reviews: {{JSON.stringify($json.sentiment)}}\n\n\nProduct: {{ $json.name }} - {{ $json.description }}\nProduct Category: {{JSON.stringify($json.categories)}}",
        "options": {
          "systemMessage": "You are a Customer Voice and Product Insights analyst. Your task is to transform a JSON array of product reviews (with fields: sentiment, strength, confidence, review, reviewer, reviewer_email) into a clear, comprehensive, and actionable report for the product and customer care teams.\n\n**RULES AND CONSTRAINTS**\n\n* The input is always an array of JSON objects (reviews).\n* The fields \"strength\" and \"confidence\" may be strings: convert them into numbers.\n* The \"review\" field may contain HTML: extract and use only the text (remove tags such as `<p>`, `\\n`, etc.).\n* Do not invent data that is not present. If something is missing, explicitly state it.\n* Do not show full email addresses in the report: mask the email. Do not include unnecessary personal data.\n* Style: professional but readable; action-oriented; use headings and bullet points; avoid unnecessary jargon.\n\n**REPORT OBJECTIVE**\n\n1. Provide a concise overview of overall sentiment.\n2. Highlight the main themes emerging from the reviews (positive and negative).\n3. Identify critical issues and opportunities for product improvement.\n4. Propose concrete actions, priorities, and possible verification metrics.\n\n**MANDATORY OUTPUT STRUCTURE**\nGenerate the report following EXACTLY this structure (with sections in this order):\n\n**1. Executive Summary**\n\n* Total number of reviews\n* Sentiment distribution (counts and percentages)\n* Predominant sentiment\n* Average intensity (overall average strength + by sentiment)\n* Average reliability (overall average confidence + by sentiment)\n* 3 key insights (bulleted)\n\n**2. Quantitative Data (tables or structured lists)**\n\n* Table/List: for each review\n\n  * ID (1..N)\n  * Sentiment\n  * Strength\n  * Confidence\n  * Review excerpt (max 120 characters)\n* Statistics:\n\n  * average/min/max strength\n  * average/min/max confidence\n  * any outliers (e.g., strength \u2265 0.85 or confidence < 0.7) with explanation\n\n**3. Qualitative Review Analysis**\n\n* Recurring negative themes (list and explain with textual examples)\n* Recurring positive themes (list and explain with textual examples)\n* Ambiguities or information gaps (if reviews are too generic, point this out)\n\n**4. Product Diagnosis (what could be causing the feedback)**\n\n* Hypotheses on the causes of negative comments (based only on the text, without inventing)\n* What is working well (based on positive comments)\n* Risks if no action is taken (customer experience, reputation, conversions)\n\n**5. Operational Recommendations (concrete actions)**\nFor each recommendation include:\n\n* Proposed action\n* Rationale (linked to the emerging themes)\n* Expected impact (High/Medium/Low)\n* Estimated effort (High/Medium/Low)\n* Priority (P0/P1/P2)\n* How to measure it (suggested KPIs)\n\n**6. Inputs for the Product Department (backlog ideas)**\n\n* List of 8\u201315 possible interventions/ideas (even small ones), grouped by area (e.g., Quality, UX, Packaging, Performance, Communication, Support, Pricing)\n* Highlight \u201cQuick wins\u201d (low effort, medium/high impact)\n\n**7. Next Steps**\n\n* 3\u20135 recommended immediate steps (e.g., collect details, customer follow-ups, A/B tests, broader analysis)\n* What additional data would be needed for a better analysis (e.g., SKU, purchase date, category, star rating, channel, returns, etc.)\n\n**CALCULATION LOGIC (to be applied internally)**\n\n* Percentages = count / total * 100 (round to 1 decimal place)\n* Strength and Confidence: convert to float, use 2 decimals in the report\n* If a sentiment other than Positive/Negative/Neutral appears, treat it as \u201cOther\u201d and flag it.\n\n**INPUT**\nYou will receive a JSON array of reviews. Immediately after the input, generate the report respecting the structure and rules above.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "de1887e7-42d4-456b-b133-2da17232c674",
      "name": "HTML Converter",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1728,
        -1200
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=Translate into HTML by analyzing the content. I only need the HTML, not the opening tags \"html\\n and the closing \\n."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "29a53915-9929-4a0d-a0c2-4acc156b9986",
      "name": "GET Product Reviews",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -32,
        -160
      ],
      "parameters": {
        "url": "=https://{{$json.woocommerce_url}}/wp-json/wc/v3/products/reviews?product={{ $json.product_id }}\n",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "95eac7ef-7024-4793-8462-41710dcff50a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -1200
      ],
      "parameters": {
        "width": 816,
        "height": 608,
        "content": "## WooCommerce Product Review Sentiment Analysis and Detailed AI Report Generation for Improvement\n\nThis workflow automates the **end-to-end analysis of WooCommerce product reviews**, transforming raw customer feedback into **actionable product and customer-care insights**, and delivering them in a structured, visual, and shareable format.\n\n### **How it works:**\n\nThis workflow automates sentiment analysis of WooCommerce product reviews through a multi-step AI-driven process. It begins by retrieving all product reviews and details from the WooCommerce REST API, then processes them in batches for scalability. Each review is analyzed using an OpenAI-based sentiment model to classify tone, strength, and confidence. The data is cleaned, normalized, and aggregated to calculate sentiment metrics, which are visualized in a QuickChart pie chart. An AI agent then generates a comprehensive report including summaries, analytics, insights, and recommendations. Finally, the report is converted to HTML and emailed automatically to stakeholders for review and decision-making.\n\n### **Setup steps:**\n\nSet up WooCommerce API credentials in the HTTP Request node and connect OpenAI and Gmail (OAuth2) credentials for sentiment analysis, report generation, and email delivery. Update product-specific parameters (Product ID, store URL, and recipient email) in their respective nodes. Optionally, customize the chart design or AI report template. Once configured, manually trigger the workflow in n8n and monitor node execution. The workflow will then automatically collect reviews, perform analysis, and send the finished report via email.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "dab1e126-d223-40d0-ab2f-8611b4ec2c60",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -544
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 336,
        "content": "## STEP 1 - Set the target\n\nSets the target WooCommerce product ID and store URL."
      },
      "typeVersion": 1
    },
    {
      "id": "b98237b5-6c5f-4011-9fa1-0006263acbb0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -352
      ],
      "parameters": {
        "color": 7,
        "width": 1392,
        "height": 608,
        "content": "## STEP 2 - Data Retrieval from WooCommerce &  Set the target AI-Powered Sentiment Analysis\n\nFetches all reviews for the selected product via the WooCommerce REST API. \n\nAI-Powered Sentiment Analysis. Each review is analyzed using an OpenAI-based sentiment analysis model. For every review, the workflow extracts: Sentiment category (Positive / Negative / Neutral) Strength (intensity) Confidence (reliability of the classification)"
      },
      "typeVersion": 1
    },
    {
      "id": "3de43a09-5dd5-4f67-8f7e-8547824813ee",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        -784
      ],
      "parameters": {
        "color": 7,
        "width": 688,
        "height": 304,
        "content": "## STEP 3 - Visual Sentiment Distribution\n\nA pie chart is dynamically generated via QuickChart to visually represent sentiment distribution."
      },
      "typeVersion": 1
    },
    {
      "id": "8abdb511-b614-45a1-80f8-83d89a28b929",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        -1360
      ],
      "parameters": {
        "color": 7,
        "width": 1232,
        "height": 544,
        "content": "## STEP 4  Visual Sentiment Distribution\n\nA specialized AI agent (\u201cProduct Insights Analyst\u201d) transforms the raw and aggregated data into a professional, structured report. The final output is automatically sent via email to stakeholders (e.g. product or customer care teams)."
      },
      "typeVersion": 1
    },
    {
      "id": "8a8290da-09be-4b6c-bf03-e6dacf8ad7a5",
      "name": "QuickChart",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1232,
        -656
      ],
      "parameters": {
        "url": "https://quickchart.io/chart",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "c",
              "value": "={\n    \"type\":\"pie\",\n    \"data\":{\n      \"labels\":{{ JSON.stringify($json.labels) }},\n      \"datasets\":[\n        {\n          \"data\":[1,1,1],\n          \"backgroundColor\":{{ JSON.stringify($json.colors) }}\n        }\n      ]\n    },\n    \"options\":{\n      \"plugins\":{\n        \"title\":{\n          \"display\":true,\n          \"text\":\"Sentiment\"\n        },\n        \"legend\":{\n          \"position\":\"bottom\"\n        }\n      }\n    }\n  }"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "6271dc5f-1704-4c4b-b4af-ce6d5f9bdd40",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1696,
        -1328
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 736,
        "content": "## MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new **YouTube channel**](https://youtube.com/@n3witalia). Here I\u2019ll share videos and Shorts with practical tutorials and **FREE templates for n8n**.\n\n[![image](https://n3wstorage.b-cdn.net/n3witalia/youtube-n8n-cover.jpg)](https://youtube.com/@n3witalia)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "bbbd4909-a781-4c27-b112-3c0296e4a13c",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Product Insights Analyst",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Product ID": {
      "main": [
        [
          {
            "node": "GET Product Reviews",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get a product",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "QuickChart": {
      "main": [
        []
      ]
    },
    "Set review": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a product": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML Converter": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Set vars for chart",
            "type": "main",
            "index": 0
          },
          {
            "node": "Aggregate reviews",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sentiment Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate reviews": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Sentiment Analysis",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Product Insights Analyst",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "HTML Converter",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Sentiment Analysis": {
      "main": [
        [
          {
            "node": "Set review",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set review",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set vars for chart": {
      "main": [
        [
          {
            "node": "QuickChart",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET Product Reviews": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Product Insights Analyst": {
      "main": [
        [
          {
            "node": "HTML Converter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Product ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}