{
  "name": "App Store Agent",
  "nodes": [
    {
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n\"query\": \n\"https://apps.apple.com/pl/app/worms/id321369231?l=pl\"\n}"
      },
      "id": "39379256-2e35-45be-9127-d75ac53aacdf",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "name": "Start",
      "position": [
        -2256,
        336
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "49682872-684e-44f3-91f1-740e7b4df362",
              "name": "app_id",
              "value": "={{ $json.app_id }}",
              "type": "string"
            },
            {
              "id": "6dc462d1-1e4d-46c6-838f-9eb77e933a7c",
              "name": "review",
              "value": "={{ $json.review }}",
              "type": "string"
            },
            {
              "id": "d9da0afd-65a8-4820-a674-de264d2947ad",
              "name": "review_id",
              "value": "={{ $json.review_id }}",
              "type": "string"
            },
            {
              "id": "f75d6fca-db2d-4b8d-91cf-75fa58dbc83e",
              "name": "timestamp",
              "value": "={{ $json.timestamp }}",
              "type": "string"
            },
            {
              "id": "9bf893ea-2ce1-474d-a12d-b32b3f51423a",
              "name": "timestamp",
              "value": "={{ $json.timestamp }}",
              "type": "string"
            },
            {
              "id": "f24c96ee-518e-46fb-92d7-2d8fac1598be",
              "name": "rating",
              "value": "={{ $json.review_rating }}",
              "type": "string"
            },
            {
              "id": "02f0cde4-b375-4f1c-96be-f5655447fa69",
              "name": "id",
              "value": "={{ $json.app_id }}:{{ $json.review_id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1360,
        224
      ],
      "id": "f761f960-ab19-4f83-a94e-6fc22c13395e",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -1136,
        224
      ],
      "id": "1c7bc462-2085-4660-88f5-8e3bb57550a2",
      "name": "Loop Over Items",
      "executeOnce": false
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "app_reviews",
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $json.id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -912,
        192
      ],
      "id": "5d3f5dde-9398-498f-8bc5-b17a82953023",
      "name": "Get a row",
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "72afdbab-3124-4b04-94e2-ecce3f6aa0ce",
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -624,
        192
      ],
      "id": "c22e0a7c-3020-4229-9cbf-60e6b9940db9",
      "name": "If"
    },
    {
      "parameters": {
        "tableId": "app_reviews",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "id",
              "fieldValue": "={{ $('Loop Over Items').item.json.id }}"
            },
            {
              "fieldId": "app_id",
              "fieldValue": "={{ $('Loop Over Items').item.json.app_id }}"
            },
            {
              "fieldId": "review_id",
              "fieldValue": "={{ $('Loop Over Items').item.json.review_id }}"
            },
            {
              "fieldId": "review",
              "fieldValue": "={{ $('Loop Over Items').item.json.review }}"
            },
            {
              "fieldId": "timestamp",
              "fieldValue": "={{ $('Loop Over Items').item.json.timestamp }}"
            },
            {
              "fieldId": "sentiment",
              "fieldValue": "={{ $json.output.sentiment }}"
            },
            {
              "fieldId": "rating",
              "fieldValue": "={{ $('Loop Over Items').item.json.rating }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        160,
        272
      ],
      "id": "3932281e-20a1-4132-8c6b-cc1d3e8e6756",
      "name": "Create a row",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "maxItems": 10,
        "keep": "lastItems"
      },
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -1584,
        224
      ],
      "id": "20d3b57b-a98a-4908-8db7-df4beb00c40e",
      "name": "Limit"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\"sentiment\":\"positive\"}",
        "autoFix": true
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -208,
        32
      ],
      "id": "f41f3bdc-4b6e-4367-8d91-46af39933d53",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "reviews",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        -912,
        -384
      ],
      "id": "68a03a3c-5a66-407c-8ab9-2fe53e408fc8",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5",
          "mode": "list",
          "cachedResultName": "gpt-5"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -624,
        -160
      ],
      "id": "a6b4b5d5-2637-43fb-b8d9-1ee50ae9d0d5",
      "name": "GPT-5",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are an assistant that summarizes app store reviews.\n\nInput: {{ JSON.stringify($json.reviews) }}\n\nTasks:\n1) Use `sentiment` field\n2) Count positive, neutral, negative.\n3) Create 3\u20136 concise, actionable insights (\u2264100 chars each), each of the form:\n   <Title> \u2014 <Why it matters> (<Short evidence>)\n   - Prefer themes: Bugs/Crashes, Performance, Usability, Pricing, Feature Request, Onboarding, Content, Localization.\n   - Focus on novelty, severity, or frequency; avoid duplicates; include at least one \u201cwhat to do\u201d hint.\n   - Use short quotes only if essential; otherwise use a stat (e.g., \u201c22% mention battery drain\u201d).\n\nOutput EXACTLY this format:\n<X> new positive reviews\n<Y> new neutral reviews\n<Z> new negative reviews\n\nInsights:\n\u2022 <bullet>\n\u2022 <bullet>\n\u2022 <bullet>\n(3\u20136 bullets total)\n\nDo not output anything else.",
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -688,
        -384
      ],
      "id": "bdd33556-5ab0-46fe-a52f-2bf9adcc5b89",
      "name": "Summary"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Classify the sentiment of the review as \"positive\", \"neutral\", or \"negative\".\nReview: {{ $('Loop Over Items').item.json.review }}\nRating: {{ $('Loop Over Items').item.json.rating }}\nOutput strictly JSON: {\"sentiment\":\"positive\"}",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -304,
        -192
      ],
      "id": "a6b24acf-134f-4a1d-adde-f8bbeafc52a9",
      "name": "Sentiment"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5-nano",
          "mode": "list",
          "cachedResultName": "gpt-5-nano"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -336,
        32
      ],
      "id": "e351e5a3-39be-4b84-85fc-8cdaf9749b0b",
      "name": "GPT-5-nano",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5-nano",
          "mode": "list",
          "cachedResultName": "gpt-5-nano"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -128,
        240
      ],
      "id": "b64a0ff6-3b29-4669-bb9d-6f70ced37fe1",
      "name": "GPT-5-nano-2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fd50400f-58fd-45a5-8ed0-25139a83b7f9",
              "name": "reviews",
              "value": "={{ $('Aggregate').item.json.reviews }}",
              "type": "array"
            },
            {
              "id": "835c61e3-b284-464d-b784-6d8c4eef27eb",
              "name": "summary",
              "value": "={{ $json.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -208,
        -384
      ],
      "id": "76a81fc4-b268-4f3a-84d4-dc261a66df0c",
      "name": "Output"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "b6c4474d-db5a-42ec-afba-6793caf52efd",
              "leftValue": "={{ Array.isArray($json) }}",
              "rightValue": "={{true}}",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1808,
        336
      ],
      "id": "b4681163-6841-4b78-9299-eaf6cd5ddc71",
      "name": "Available reviews"
    },
    {
      "parameters": {
        "jsCode": "return {\n  reviews: [],\n  summary: \"No new reviews available\"\n}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -944,
        496
      ],
      "id": "d090d739-6cf0-40dd-ab6f-450278c3bc23",
      "name": "Code"
    },
    {
      "parameters": {
        "resource": "webScrapper",
        "dataset_id": {
          "__rl": true,
          "value": "gd_m734msue16e0adkbit",
          "mode": "list",
          "cachedResultName": "Apple App Store reviews "
        },
        "urls": "=[{\"url\":\"{{ $json.query }}\"}] ",
        "requestOptions": {}
      },
      "type": "@brightdata/n8n-nodes-brightdata.brightData",
      "typeVersion": 1,
      "position": [
        -2032,
        336
      ],
      "id": "cb315664-fa3f-4af7-b414-6a58d5306e4a",
      "name": "Scrape App Store Reviews",
      "credentials": {
        "brightdataApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Scrape App Store Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a row": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sentiment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a row": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Sentiment",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-5": {
      "ai_languageModel": [
        [
          {
            "node": "Summary",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Sentiment": {
      "main": [
        [
          {
            "node": "Create a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-5-nano": {
      "ai_languageModel": [
        [
          {
            "node": "Sentiment",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "GPT-5-nano-2": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Summary": {
      "main": [
        [
          {
            "node": "Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Available reviews": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape App Store Reviews": {
      "main": [
        [
          {
            "node": "Available reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0aec51ad-1f5b-40bd-8326-5fd254c1cbc3",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "uV2sfimMGxMmLZmR",
  "tags": []
}