{
  "meta": {
    "instanceId": "73db18c27b0727eb1d6695ef46d95450042be277925d039ca7583d739b775d75"
  },
  "nodes": [
    {
      "id": "cd88d9b9-685f-4e1a-a94b-ce1c9230755f",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        800,
        368
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "51705ad0-36b1-4d9a-aa34-ab6a4cf8a10a",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        1040,
        368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-2",
              "name": "maxReviews",
              "type": "number",
              "value": 10
            },
            {
              "id": "id-3",
              "name": "apifyActorId",
              "type": "string",
              "value": "junglee/amazon-reviews-scraper"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "47fa2941-81c8-424a-991c-a1d6a221d7ed",
      "name": "Loop Over Reviews",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1616,
        368
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "f9ac105c-7d00-428a-b92e-7f03ea949882",
      "name": "Slack - Send Completion Notification",
      "type": "n8n-nodes-base.slack",
      "position": [
        3024,
        352
      ],
      "webhookId": "bfe91981-5c1b-4232-b6c2-304f0b495f92",
      "parameters": {
        "text": "=✅ Amazon レビュー分析が完了しました！\n\n処理したレビュー数: {{ $('Loop Over Reviews').item.json.batchSize }}\nNotionデータベースを確認してください。",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "<__PLACEHOLDER_VALUE__Slack Channel ID or Name__>"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "35f765fe-6164-440e-8ff1-2570dca6056d",
      "name": "Code (Parse JSON)1",
      "type": "n8n-nodes-base.code",
      "notes": "AIのテキスト回答をデータとして扱えるように変換します",
      "position": [
        2192,
        464
      ],
      "parameters": {
        "jsCode": "// 1. データを受け取る\nconst responseData = $input.first().json;\n\n// 2. AIの回答が入っている場所を探す (GeminiもOpenAIも対応)\nconst aiResponse = responseData.text || responseData.output || (responseData.message && responseData.message.content);\n\n// 3. 余計な文字（```json や ```）を掃除する\nconst cleanJson = aiResponse.replace(/```json|```/g, '').trim();\n\n// 4. JSONデータとして変換して、n8nに渡す（ここが重要！）\nreturn [ { json: JSON.parse(cleanJson) } ];"
      },
      "typeVersion": 2
    },
    {
      "id": "53bbef29-bf50-4fa0-acc4-ec691a57de0f",
      "name": "Create spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2608,
        464
      ],
      "parameters": {
        "options": {},
        "resource": "spreadsheet"
      },
      "typeVersion": 4.7
    },
    {
      "id": "2de87bfa-64dd-4313-bfbd-d2d1bab6746d",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1744,
        464
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.0-flash-lite",
          "cachedResultName": "models/gemini-2.0-flash-lite"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=あなたは熟練の商品開発マーケターです。\n以下のAmazonレビューを分析し、情報をJSON形式のみで出力してください。\n{\n  \"sentiment_score\": (1〜5の数値。1が最悪、5が最高),\n  \"category\": (\"Quality\", \"Price\", \"Function\", \"Design\", \"Shipping\", \"Other\" から最も当てはまるものを1つ選択),\n  \"summary\": (ユーザーの不満点を日本語で30文字以内に要約),\n  \"improvement\": (具体的な改善案を日本語で50文字以内で提案)\n}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e26f6997-97bb-4f6e-8eb6-d7019e998d9b",
      "name": "Run an Actor and get dataset",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        1296,
        368
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "list",
          "value": "R8WeJwLuzLZ6g4Bkk",
          "cachedResultUrl": "https://console.apify.com/actors/R8WeJwLuzLZ6g4Bkk/input",
          "cachedResultName": "Amazon Reviews Scraper (junglee/amazon-reviews-scraper)"
        },
        "operation": "Run actor and get dataset",
        "customBody": "{\n  \"startUrls\": [\n    {\n      \"url\": \"https://www.amazon.co.jp/dp/B09JDGYSQW\"\n    }\n  ],\n  \"maxReviews\": 10,\n  \"filterByRatings\": [\n    \"oneStar\",\n    \"twoStars\"\n  ],\n  \"proxyConfiguration\": {\n    \"useApifyProxy\": true\n  }\n}",
        "authentication": "apifyOAuth2Api"
      },
      "typeVersion": 1
    },
    {
      "id": "1052ec0a-4df5-4668-89d3-22d4afc1c902",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -240
      ],
      "parameters": {
        "width": 768,
        "height": 560,
        "content": "\n\n# Template Description \n## 📝 Template Title\n**Analyze Amazon product reviews with Gemini and save to Google Sheets**\n\n## 📄 Description\nThis workflow automates the process of analyzing customer feedback on Amazon products. Instead of manually reading through hundreds of reviews, this template scrapes reviews (specifically targeting negative feedback), uses Google Gemini (AI) to analyze the root causes of dissatisfaction, and generates specific improvement suggestions. The results are automatically logged into a Google Sheet for easy tracking, and a Slack notification is sent to keep your team updated.\n\nThis tool is essential for understanding \"Voice of Customer\" data efficiently without manual data entry.\n\n## 🧍 Who is this for\n- **Product Managers** looking for product improvement ideas.\n- **E-commerce Sellers (Amazon FBA, D2C)** monitoring brand reputation.\n- **Market Researchers** analyzing competitor weaknesses.\n- **Customer Support Teams** identifying recurring issues.\n\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b4fe470b-539c-405d-8cba-90da41c69924",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        208
      ],
      "parameters": {
        "color": 3,
        "width": 320,
        "height": 528,
        "content": "1. **Data Collection:** The workflow triggers the Apify actor (`junglee/amazon-reviews-scraper`) to fetch reviews from a specified Amazon product URL. It is currently configured to filter for 1 and 2-star reviews to focus on complaints."
      },
      "typeVersion": 1
    },
    {
      "id": "f2e6b53a-ff3c-4ac2-af2b-293413b7f80b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1552,
        208
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 528,
        "content": "2. **AI Analysis:** It loops through each review and sends the content to Google Gemini. The AI determines a sentiment score (1-5), categorizes the issue (Quality, Design, Shipping, etc.), summarizes the complaint, and proposes a concrete improvement plan."
      },
      "typeVersion": 1
    },
    {
      "id": "39f031dc-0d86-4acc-9d0a-5bf436fdefff",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2048,
        208
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 528,
        "content": "3. **Formatting:** A Code node parses the AI's response to ensure it is in a clean JSON format."
      },
      "typeVersion": 1
    },
    {
      "id": "de9ce0a4-9c17-4b09-8558-278177e1e1a5",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2480,
        208
      ],
      "parameters": {
        "color": 6,
        "width": 368,
        "height": 528,
        "content": "4. **Storage:** The structured data is appended as a new row in a Google Sheet.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "32b9be42-7635-4905-b4b7-87d8ca9a6347",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2896,
        208
      ],
      "parameters": {
        "color": 2,
        "width": 352,
        "height": 528,
        "content": "5. **Notification:** A Slack message is sent to your specified channel to confirm the batch analysis is complete."
      },
      "typeVersion": 1
    },
    {
      "id": "c0e79928-1d7f-4e39-b5e1-bc3be72dc7e5",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 816,
        "height": 352,
        "content": "## 🛠️ Requirements\n- **n8n** (Self-hosted or Cloud)\n- **Apify Account:** You need to rent the `junglee/amazon-reviews-scraper` actor.\n- **Google Cloud Account:** For accessing the Gemini (PaLM) API and Google Sheets API.\n- **Slack Account:** For receiving notifications.\n\n## 🚀 How to set up\n1. **Apify Config:** Enter your Apify API token in the credentials. In the \"Run an Actor\" node, update the `startUrls` to the Amazon product page you want to analyze.\n2. **Google Sheets:** Create a new Google Sheet with the following header columns: `sentiment_score`, `category`, `summary`, `improvement`. Copy the Spreadsheet ID into the Google Sheets node.\n3. **AI Prompt:** The \"Message a model\" node contains the prompt. It is currently set to output results in **Japanese**. If you need English output, simply translate the prompt text inside this node.\n4. **Slack:** Select the channel where you want to receive notifications in the Slack node."
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Code (Parse JSON)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Reviews": {
      "main": [
        [
          {
            "node": "Slack - Send Completion Notification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code (Parse JSON)1": {
      "main": [
        [
          {
            "node": "Create spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create spreadsheet": {
      "main": [
        [
          {
            "node": "Loop Over Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Run an Actor and get dataset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run an Actor and get dataset": {
      "main": [
        [
          {
            "node": "Loop Over Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}