Workflow: Manualtrigger Workflow
Integrations: code, executeWorkflow, executeWorkflowTrigger, filter, googleSheets, html, httpRequest, manualTrigger, noOp, set, splitOut, stickyNote

{"meta": {"instanceId": "workflow-b9857866", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:53.914162", "updatedAt": "2025-09-29T07:07:53.914245", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production"}, "nodes": [{"id": "63501cc8-77c9-4037-9f70-da23b6d20b03", "name": "When clicking \u2018Test workflow\u2019", "type": "n8n-nodes-base.manualTrigger", "position": [280, 440], "parameters": {}, "typeVersion": 1, "notes": "This manualTrigger node performs automated tasks as part of the workflow."}, {"id": "00de989c-d9e9-4b42-b5db-7097800a6017", "name": "Zip Entries", "type": "n8n-nodes-base.set", "position": [1380, 360], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "833a554d-2b39-4160-9348-18b17b28ce30", "name": "data", "type": "array", "value": "={{ \n $json.review_author.map((review_author, idx) => ({\n review_author,\n review_author_reviews_count: $json.review_author_reviews_count[idx].replace(' reviews', '').toInt(),\n review_country: $json.review_country[idx],\n review_date: $json.review_date[idx].toDate(),\n review_date_of_experience: $json.review_date_of_experience[idx].replace('Date of experience: ', '').toDate(),\n review_rating: $json.review_rating[idx].toInt(),\n review_text: $json.review_text[idx],\n review_title: $json.review_title[idx],\n review_url: $('Get TrustPilot Page').params.url.match(/https:\\/\\/[^/]+/) + $json.review_url[idx],\n }))\n}}"}]}}, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "9290e116-c001-49d5-ae4c-d91cd246f2c2", "name": "Extract Reviews", "type": "n8n-nodes-base.html", "position": [1140, 520], "parameters": {"options": {"trimValues": true}, "operation": "extractHtmlContent", "extractionValues": {"values": [{"key": "YOUR_CREDENTIAL_HERE", "cssSelector": "[data-service-review-card-paper] [data-consumer-name-typography]", "returnArray": true}, {"key": "YOUR_CREDENTIAL_HERE", "attribute": "data-service-review-rating", "cssSelector": "[data-service-review-rating]", "returnArray": true, "returnValue": "attribute"}, {"key": "YOUR_CREDENTIAL_HERE", "cssSelector": "[data-service-review-title-typography]", "returnArray": true}, {"key": "YOUR_CREDENTIAL_HERE", "cssSelector": "[data-service-review-text-typography]", "returnArray": true}, {"key": "YOUR_CREDENTIAL_HERE", "cssSelector": "[data-service-review-date-of-experience-typography]", "returnArray": true}, {"key": "YOUR_CREDENTIAL_HERE", "attribute": "datetime", "cssSelector": "[data-service-review-date-time-ago]", "returnArray": true, "returnValue": "attribute"}, {"key": "YOUR_CREDENTIAL_HERE", "cssSelector": "[data-consumer-country-typography]", "returnArray": true}, {"key": "YOUR_CREDENTIAL_HERE", "cssSelector": "[data-consumer-reviews-count-typography]", "returnArray": true}, {"key": "YOUR_CREDENTIAL_HERE", "attribute": "href", "cssSelector": "a[data-review-title-typography]", "returnArray": true, "returnValue": "attribute"}]}}, "typeVersion": 1.2, "notes": "This html node performs automated tasks as part of the workflow."}, {"id": "4aa3e50d-fcce-48a7-8237-c12f8592f69e", "name": "Reviews to List", "type": "n8n-nodes-base.splitOut", "position": [1380, 520], "parameters": {"options": {}, "fieldToSplitOut": "data"}, "typeVersion": 1, "notes": "This splitOut node performs automated tasks as part of the workflow."}, {"id": "a6b9abf9-a17a-4f30-9f90-6183770c4933", "name": "Default Data Loader", "type": "n8n-nodes-base.noOp", "position": [1980, 520], "parameters": {"options": {"metadata": {"metadataValues": [{"name": "review_author", "value": "={{ $json.review_author }}"}, {"name": "review_author_reviews_count", "value": "={{ $json.review_author_reviews_count }}"}, {"name": "review_country", "value": "={{ $json.review_country }}"}, {"name": "review_date", "value": "={{ $json.review_date }}"}, {"name": "review_date_of_experience", "value": "={{ $json.review_date_of_experience }}"}, {"name": "review_rating", "value": "={{ $json.review_rating }}"}, {"name": "review_date_month", "value": "={{ $json.review_date.toDateTime().format('M') }}"}, {"name": "review_date_year", "value": "={{ $json.review_date.toDateTime().format('yyyy') }}"}, {"name": "review_date_of_experience_month", "value": "={{ $json.review_date_of_experience.toDateTime().format('M') }}"}, {"name": "review_date_of_experience_year", "value": "={{ $json.review_date_of_experience.toDateTime().format('yyyy') }}"}, {"name": "company_id", "value": "={{ $('Set Variables').item.json.companyId }}"}, {"name": "review_url", "value": "={{ $json.review_url }}"}]}}, "jsonData": "={{ $json.review_title }}\n{{ $json.review_text }}", "jsonMode": "expressionData"}, "typeVersion": 1, "notes": "This documentDefaultDataLoader node performs automated tasks as part of the workflow."}, {"id": "afd8907c-9a59-4dcc-94c5-2114fb2a7d5d", "name": "Recursive Character Text Splitter", "type": "n8n-nodes-base.noOp", "position": [1980, 660], "parameters": {"options": {}, "chunkSize": 4000}, "typeVersion": 1, "notes": "This textSplitterRecursiveCharacterTextSplitter node performs automated tasks as part of the workflow."}, {"id": "e22d92b8-e8e9-42aa-9d02-2e70234f11ed", "name": "Embeddings OpenAI", "type": "n8n-nodes-base.noOp", "position": [1860, 520], "parameters": {"model": "text-embedding-3-small", "options": {}}, "credentials": {"openAiApi": {"id": "8gccIjcuf3gvaoEr", "name": "OpenAi account"}}, "typeVersion": 1, "notes": "This embeddingsOpenAi node performs automated tasks as part of the workflow."}, {"id": "f0ea6b63-c96d-4b3f-8a21-d0f2dbb4efc3", "name": "Set Variables", "type": "n8n-nodes-base.set", "position": [520, 440], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "2e58a9fa-a14d-4a6c-8cc8-8ec947c791fb", "name": "companyId", "type": "string", "value": "www.freddiesflowers.com"}]}}, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "0188986f-fbe9-4c06-892a-3cb71b52a309", "name": "Get Payload of Points", "type": "n8n-nodes-base.httpRequest", "position": [1740, 1120], "parameters": {"url": "{{ $env.BASE_URL }}", "method": "POST", "options": {}, "jsonBody": "={{\n {\n \"ids\": $json.points,\n \"with_payload\": true\n }\n}}", "sendBody": true, "specifyBody": "json", "authentication": "{{ $credentials.predefinedCredentialType }}", "nodeCredentialType": "YOUR_CREDENTIAL_HERE"}, "credentials": {"qdrantApi": {"id": "NyinAS3Pgfik66w5", "name": "QdrantApi account"}}, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow."}, {"id": "5fc6e0b6-507f-4cfd-951b-be3709b86ac2", "name": "Clusters To List", "type": "n8n-nodes-base.splitOut", "position": [1480, 1120], "parameters": {"options": {}, "fieldToSplitOut": "output"}, "typeVersion": 1, "notes": "This splitOut node performs automated tasks as part of the workflow."}, {"id": "f21369b9-1dd5-4b35-a1f3-00fd67794051", "name": "OpenAI Chat Model", "type": "n8n-nodes-base.noOp", "position": [2140, 1340], "parameters": {"model": "gpt-4o-mini", "options": {}}, "credentials": {"openAiApi": {"id": "8gccIjcuf3gvaoEr", "name": "OpenAi account"}}, "typeVersion": 1, "notes": "This lmChatOpenAi node performs automated tasks as part of the workflow."}, {"id": "b0075699-6513-4781-b5de-81d1ab81dfe1", "name": "Only Clusters With 3+ points", "type": "n8n-nodes-base.filter", "position": [1480, 1300], "parameters": {"options": {}, "conditions": {"options": {"leftValue": "", "caseSensitive": true, "typeValidation": "strict"}, "combinator": "and", "conditions": [{"id": "328f806c-0792-4d90-9bee-a1e10049e78f", "operator": {"type": "array", "operation": "lengthGt", "rightType": "number"}, "leftValue": "={{ $json.points }}", "rightValue": 2}]}}, "typeVersion": 2, "notes": "This filter node performs automated tasks as part of the workflow."}, {"id": "f6a6209c-d269-4238-8e92-230df7b41df9", "name": "Set Variables1", "type": "n8n-nodes-base.set", "position": [519, 1220], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "2e58a9fa-a14d-4a6c-8cc8-8ec947c791fb", "name": "companyId", "type": "string", "value": "={{ $json.companyId }}"}, {"id": "37cf8af2-6f0f-40b1-b822-c9bd6a620a3c", "name": "review_date_from", "type": "string", "value": "={{ $today.startOf('month').toISO() }}"}, {"id": "8d72f739-f832-4c25-b62a-2ae70ad2b1e7", "name": "review_date_to", "type": "string", "value": "={{ $today.endOf('month').toISO() }}"}]}}, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "85cb48b1-0ab9-4f88-88f3-82fcfb041ebe", "name": "Find Reviews", "type": "n8n-nodes-base.httpRequest", "position": [896, 1160], "parameters": {"url": "{{ $env.BASE_URL }}", "method": "POST", "options": {}, "jsonBody": "={\n \"limit\": 500,\n \"filter\":{\n \"must\": [\n {\n \"key\": \"metadata.company_id\",\n \"match\": { \"value\": \"{{ $('Set Variables1').item.json.companyId }}\" }\n },\n {\n \"key\": \"metadata.review_date\",\n \"range\": {\n \"gte\": \"{{ $('Set Variables1').item.json.review_date_from }}\",\n \"gt\": null,\n \"lt\": null,\n \"lte\": \"{{ $('Set Variables1').item.json.review_date_to }}\"\n }\n }\n ]\n },\n \"with_vector\":true\n}", "sendBody": true, "specifyBody": "json", "authentication": "{{ $credentials.predefinedCredentialType }}", "nodeCredentialType": "YOUR_CREDENTIAL_HERE"}, "credentials": {"qdrantApi": {"id": "NyinAS3Pgfik66w5", "name": "QdrantApi account"}}, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow."}, {"id": "69bbd197-c78f-4dae-9300-fe23d4d49855", "name": "Prep Output For Export", "type": "n8n-nodes-base.set", "position": [2720, 1203], "parameters": {"mode": "raw", "options": {}, "jsonOutput": "={{ {\n ...$json.output,\n \"CompanyID\": $('Set Variables1').item.json.companyId,\n \"From\": $('Set Variables1').item.json.review_date_from,\n \"To\": $('Set Variables1').item.json.review_date_to,\n \"Number of Responses\": $('Get Payload of Points').item.json.result.length,\n \"Raw Responses\": $('Get Payload of Points').item.json.result.map(item =>\n [\n item.payload.metadata.review_date,\n item.payload.metadata.review_author,\n item.payload.metadata.review_rating,\n item.payload.content.replaceAll('\"', '\\\"').replaceAll('\\n', ' '),\n item.payload.metadata.review_url,\n ]\n ).join('\\n')\n} }}\n"}, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "d77daa23-6acf-4daa-bf4c-33da4d05a54c", "name": "Export To Sheets", "type": "n8n-nodes-base.googleSheets", "position": [2940, 1203], "parameters": {"columns": {"value": {}, "schema": [{"id": "CompanyID", "type": "string", "display": true, "removed": false, "required": false, "displayName": "CompanyID", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "From", "type": "string", "display": true, "removed": false, "required": false, "displayName": "From", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "To", "type": "string", "display": true, "removed": false, "required": false, "displayName": "To", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Insight", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Insight", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Sentiment", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Sentiment", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Suggested Improvements", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Suggested Improvements", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Number of Responses", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Number of Responses", "defaultMatch": false, "canBeUsedToMatch": true}, {"id": "Raw Responses", "type": "string", "display": true, "removed": false, "required": false, "displayName": "Raw Responses", "defaultMatch": false, "canBeUsedToMatch": true}], "mappingMode": "autoMapInputData", "matchingColumns": []}, "options": {}, "operation": "append", "sheetName": {"__rl": true, "mode": "name", "value": "=Sheet1"}, "documentId": {"__rl": true, "mode": "id", "value": "=1wAwWCcIZod00IGtxwTbTgjIRbKHu3Yl9wYWJ8GeT2Os"}}, "credentials": {"googleSheetsOAuth2Api": {"id": "XHvC7jIRR8A2TlUl", "name": "Google Sheets account"}}, "typeVersion": 4.4, "notes": "This googleSheets node performs automated tasks as part of the workflow."}, {"id": "1f60c3a5-a47a-4313-9b29-8ea652d573f7", "name": "Clear Existing Reviews", "type": "n8n-nodes-base.httpRequest", "position": [760, 440], "parameters": {"url": "{{ $env.WEBHOOK_URL }}", "method": "POST", "options": {}, "jsonBody": "={\n \"filter\": {\n \"must\": [\n {\n \"key\": \"metadata.company_id\",\n \"match\": {\n \"value\": \"{{ $('Set Variables').item.json.companyId }}\"\n }\n }\n ]\n }\n}", "sendBody": true, "specifyBody": "json", "authentication": "{{ $credentials.predefinedCredentialType }}", "nodeCredentialType": "YOUR_CREDENTIAL_HERE"}, "credentials": {"qdrantApi": {"id": "NyinAS3Pgfik66w5", "name": "QdrantApi account"}}, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow."}, {"id": "61c3117c-757c-45dd-b9d5-1122b793be30", "name": "Trigger Insights", "type": "n8n-nodes-base.executeWorkflow", "position": [2660, 440], "parameters": {"options": {}, "workflowId": "={{ $workflow.id }}"}, "typeVersion": 1, "notes": "This executeWorkflow node performs automated tasks as part of the workflow."}, {"id": "d3c6e81f-34bb-4be9-b869-2c219b87c4fb", "name": "Prep Values For Trigger", "type": "n8n-nodes-base.set", "position": [2460, 440], "parameters": {"options": {}, "assignments": {"assignments": [{"id": "24dd90ad-390f-444e-ba6c-8c06a41e836e", "name": "companyId", "type": "string", "value": "={{ $('Set Variables').item.json.companyId }}"}]}}, "executeOnce": true, "typeVersion": 3.4, "notes": "This set node performs automated tasks as part of the workflow."}, {"id": "64af9cc7-a194-4427-ba78-d9a1136b962f", "name": "Execute Workflow Trigger", "type": "n8n-nodes-base.executeWorkflowTrigger", "position": [316, 1220], "parameters": {}, "typeVersion": 1, "notes": "This executeWorkflowTrigger node performs automated tasks as part of the workflow."}, {"id": "7b6ba502-36c2-41e6-9d67-781d0d40a569", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [186.9455564469605, 263.2301011325764], "parameters": {"color": 7, "width": 787.3314861380661, "height": 465.52420584035275, "content": "## Step 1. Starting Fresh\nFor this demo, we'll clear any existing records in our Qdrant vector store for the selected company. We do this using the Qdrant's delete points API."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "a99389d4-8ea6-4379-b725-f30e92b0d29e", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [1006.3778510483207, 148.50042906971555], "parameters": {"color": 7, "width": 638.5221986278162, "height": 580.2538779032135, "content": "## Step 2. Scraping TrustPilot For Company Reviews\n[Read more about HTTP Request Node]({{ $env.WEBHOOK_URL }}\n\nWe'll scrape at the most recent 3 pages of reviews for illustrative purposes but we could easily scrape them all if required. The HTML node offers a convenient way to extract data from the returned html pages and using it, we'll retrieve all the reviews data."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "139ccadd-9135-4681-b2eb-403b8d8bd710", "name": "Get TrustPilot Page", "type": "n8n-nodes-base.httpRequest", "position": [1140, 360], "parameters": {"url": "{{ $env.BASE_URL }}", "options": {"pagination": {"pagination": {"parameters": {"parameters": [{"name": "page", "value": "={{ $pageCount + 1 }}"}]}, "maxRequests": 3, "limitPagesFetched": true}}}}, "executeOnce": false, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow."}, {"id": "1c71db65-713b-4c31-9c11-5ff678fb327a", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [1680, 140], "parameters": {"color": 7, "width": 638.5221986278162, "height": 689.8000993522735, "content": "## Step 3. Store Reviews in Qdrant\n[Learn more about the Qdrant Vector Store]({{ $env.WEBHOOK_URL }}\n\nVector databases are a great way to store data if you're interested in perform similiarity searches which applies here as we want to group similar reviews to find patterns. Qdrant is a powerful vector database and tool of choice because of its robust API implementation and advanced filtering capabilities."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "a4f82a1b-5a76-46b6-a7a3-84ab09b46699", "name": "Qdrant Vector Store", "type": "n8n-nodes-base.noOp", "position": [1860, 360], "parameters": {"mode": "insert", "options": {}, "qdrantCollection": {"__rl": true, "mode": "id", "value": "=trustpilot_reviews"}}, "credentials": {"qdrantApi": {"id": "NyinAS3Pgfik66w5", "name": "QdrantApi account"}}, "typeVersion": 1, "notes": "This vectorStoreQdrant node performs automated tasks as part of the workflow."}, {"id": "cbad9e73-c5b3-474c-95ef-7269addc4e62", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "position": [216, 1000], "parameters": {"color": 7, "width": 543.4265511994403, "height": 453.31956386852846, "content": "## Step 5. The Insight Subworkflow\n[Learn more about Workflow Triggers]({{ $env.WEBHOOK_URL }}\n\nThis subworkflow takes the companyId to find the relevant records in our Qdrant vector store. It also takes a \"from\" and \"to\" date to scope the insights to a particular range - doing this we can say something like \"we only want insights for the past month of reviews\". "}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "9c530716-63f4-4368-8d0e-0cdbe8f5b08e", "name": "Sticky Note4", "type": "n8n-nodes-base.stickyNote", "position": [780, 920], "parameters": {"color": 7, "width": 557.7420442679241, "height": 526.2781960611934, "content": "## Step 6. Apply Clustering Algorithm to Reviews\n[Read more about using Python in n8n]({{ $env.WEBHOOK_URL }}\n\nWe'll retrieve our vectors embeddings for the desired company reviews and perform an advanced clustering algorithm on them. This powerful echnique allows us to quickly group similar embeddings into clusters which we can then use to discover popular feedback, opinions and pain-points!"}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "9790b3a5-cc7c-4e12-8038-fc661c8226f8", "name": "Sticky Note5", "type": "n8n-nodes-base.stickyNote", "position": [1360, 920], "parameters": {"color": 7, "width": 598.5585287222906, "height": 605.9905193915599, "content": "## Step 7. Fetch Reviews By Cluster\n[Learn more about using the Code Node]({{ $env.WEBHOOK_URL }}\n\nWith the Qdrant point IDs grouped and returned by our code node, all that's left is to fetch the payload of each. Note that the clustering algorithm isn't perfect and may require some tweaking depending on your data."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "267057b6-9727-4a45-9d87-5429da42f48e", "name": "Sticky Note7", "type": "n8n-nodes-base.stickyNote", "position": [1980, 969], "parameters": {"color": 7, "width": 587.6069484146701, "height": 552.9535170892194, "content": "## Step 8. Getting Insights from Grouped Reviews\n[Read more about using Information Extractor Node]({{ $env.WEBHOOK_URL }}\n\nNext, we'll use our state-of-the-art LLM to generate insights on our reviews. Doing it this way, we'll able to pull more granular results addressing many key topics within the reviews."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "b8cc07d0-ffa3-425f-ae74-76dcb68fa88f", "name": "Sticky Note8", "type": "n8n-nodes-base.stickyNote", "position": [2600, 980], "parameters": {"color": 7, "width": 572.5638733479158, "height": 464.4019616956416, "content": "## Step 9. Write To Insights Sheet\nFinally, our completed insights to appended to the Insights Sheet we created earlier in the workflow.\n\nYou can find a sample sheet here: {{ $env.WEBHOOK_URL }}"}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "0dac0854-7106-44e3-bd68-fad7b201a6bc", "name": "Sticky Note6", "type": "n8n-nodes-base.stickyNote", "position": [2340, 240], "parameters": {"color": 7, "width": 519.6419932444072, "height": 429.11782776909047, "content": "## Step 4. Trigger Insights SubWorkflow\n[Learn more about Workflow Triggers]({{ $env.WEBHOOK_URL }}\n\nA subworkflow is used to trigger the analysis for the survey. This separation is optional but used here to better demonstrate the two part process."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "4aa7e73e-c29d-41df-b2f8-a62109285ccb", "name": "Sticky Note9", "type": "n8n-nodes-base.stickyNote", "position": [460, 380], "parameters": {"width": 226.36363118160727, "height": 327.0249036433755, "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### \ud83d\udea8 Set company here!\nTrustpilot must recognise it as part of the url."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "4d895cf9-452c-401e-a6f3-b9d3a359a96d", "name": "Apply K-means Clustering Algorithm", "type": "n8n-nodes-base.code", "position": [1116, 1160], "parameters": {"language": "python", "pythonCode": "import numpy as np\nfrom sklearn.cluster import KMeans\n\n# get vectors for all answers\npoint_ids = [item.id for item in _input.first().json.result.points]\nvectors = [item.vector.to_py() for item in _input.first().json.result.points]\nvectors_array = np.array(vectors)\n\n# apply k-means clustering where n_clusters = 5\n# this is a max and we'll discard some of these clusters later\nkmeans = KMeans(n_clusters=min(len(vectors), 5), random_state=42).fit(vectors_array)\nlabels = kmeans.labels_\nunique_labels = set(labels)\n\n# Extract and print points in each cluster\nclusters = {}\nfor label in set(labels):\n clusters[label] = vectors_array[labels == label]\n\n# return Qdrant point ids for each cluster\n# we'll use these ids to fetch the payloads from the vector store.\noutput = []\nfor cluster_id, cluster_points in clusters.items():\n points = [point_ids[i] for i in range(len(labels)) if labels[i] == cluster_id]\n output.append({\n \"id\": f\"Cluster {cluster_id}\",\n \"total\": len(cluster_points),\n \"points\": points\n })\n\nreturn {\"json\": {\"output\": output } }"}, "typeVersion": 2, "notes": "This code node performs automated tasks as part of the workflow."}, {"id": "95c57019-d9d7-4d9f-93dd-21d3d9708861", "name": "Sticky Note10", "type": "n8n-nodes-base.stickyNote", "position": [-260, 40], "parameters": {"width": 400.381109509268, "height": 612.855812336249, "content": "## Try It Out!\n\n### This workflow generates highly-detailed customer insights from Trustpilot reviews. Works best when dealing with a large number of reviews.\n\n* Import Trustpilot reviews and vectorise in Qdrant vectorstore.\n* Identify clusters of popular topics in reviews using K-means clustering algorithm. \n* Each valid cluster is analysed and summarised by LLM.\n* Export LLM response and cluster results back into sheet.\n\nCheck out the reference google sheet here: {{ $env.WEBHOOK_URL }}\n\n### Need Help?\nJoin the [Discord]({{ $env.WEBHOOK_URL }} or ask in the [Forum]({{ $env.WEBHOOK_URL }}\n\nHappy Hacking!"}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "9bba9480-792e-48e3-ad9f-8809ce3aba09", "name": "Customer Insights Agent", "type": "n8n-nodes-base.noOp", "position": [2140, 1180], "parameters": {"text": "=The {{ $json.result.length }} reviews were:\n{{\n$json.result.map(item =>\n`* ${item.payload.metadata.review_author} gave ${item.payload.metadata.review_rating} stars: \"${item.payload.content.replaceAll('\"', '\\\"').replaceAll('\\n', ' ')}\"`\n).join('\\n')\n}}", "options": {"systemPromptTemplate": "=You help summarise a selection of trustpilot reviews for a company called \"{{ $json.result[0].payload.metadata.company_id }}\".\nThe {{ $json.result.length }} reviews were selected because their contents were similar in context.\n\nYour task is to: \n* summarise the given reviews into a short paragraph. Provide an insight from this summary and what we could learn from the reviews.\n* determine if the overall sentiment of all the listed responses to be either strongly negative, negative, neutral, positive or strongly positive."}, "schemaType": "fromJson", "jsonSchemaExample": "{\n\t\"Insight\": \"\",\n \"Sentiment\": \"\",\n \"Suggested Improvements\": \"\"\n}"}, "typeVersion": 1, "notes": "This informationExtractor node performs automated tasks as part of the workflow."}, {"id": "4488deb9-27f6-4f9d-b17e-9b5e7a1bba33", "name": "Sticky Note12", "type": "n8n-nodes-base.stickyNote", "position": [180, 760], "parameters": {"color": 5, "width": 323.2987132716669, "height": 80, "content": "### Run this once! \nIf for any reason you need to run more than once, be sure to clear the existing data first."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}, {"id": "5cb3bd73-1e77-4eba-9d2e-634fdc374330", "name": "Sticky Note11", "type": "n8n-nodes-base.stickyNote", "position": [780, 1480], "parameters": {"color": 5, "width": 323.2987132716669, "height": 110.05160146874424, "content": "### First Time Running?\nThere is a slight delay on first run because the code node has to download the required packages."}, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow."}], "pinData": {}, "connections": {"0188986f-fbe9-4c06-892a-3cb71b52a309": {"main": [[{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-93c1e616", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-0d084f39", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-24f9d459", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-b4ae5bff", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-23fe66e8", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-d5686037", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-de77c8f4", "type": "main", "index": 0}], [{"node": "error-handler-0188986f-fbe9-4c06-892a-3cb71b52a309-7bfc4398", "type": "main", "index": 0}]]}, "85cb48b1-0ab9-4f88-88f3-82fcfb041ebe": {"main": [[{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-a21a758d", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-86a70ff7", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-2e961df5", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-63a70c3c", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-10b6603a", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-cb1be15e", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-a4710aac", "type": "main", "index": 0}], [{"node": "error-handler-85cb48b1-0ab9-4f88-88f3-82fcfb041ebe-33130d71", "type": "main", "index": 0}]]}, "1f60c3a5-a47a-4313-9b29-8ea652d573f7": {"main": [[{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-6c73d0c1", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-5091003b", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-3bba6942", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-d5b7fd97", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-4a6e550c", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-3cf429a3", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-6bb71d2a", "type": "main", "index": 0}], [{"node": "error-handler-1f60c3a5-a47a-4313-9b29-8ea652d573f7-fb0b3042", "type": "main", "index": 0}]]}, "139ccadd-9135-4681-b2eb-403b8d8bd710": {"main": [[{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-b58ad64d", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-c19cdd70", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-44159589", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-c7322e32", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-669cca0d", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-2ffacf84", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-c20735e6", "type": "main", "index": 0}], [{"node": "error-handler-139ccadd-9135-4681-b2eb-403b8d8bd710-5c901e69", "type": "main", "index": 0}]]}, "e22d92b8-e8e9-42aa-9d02-2e70234f11ed": {"main": [[{"node": "error-handler-e22d92b8-e8e9-42aa-9d02-2e70234f11ed-1aac10da", "type": "main", "index": 0}]]}, "f21369b9-1dd5-4b35-a1f3-00fd67794051": {"main": [[{"node": "error-handler-f21369b9-1dd5-4b35-a1f3-00fd67794051-73d8f791", "type": "main", "index": 0}]]}, "d77daa23-6acf-4daa-bf4c-33da4d05a54c": {"main": [[{"node": "error-handler-d77daa23-6acf-4daa-bf4c-33da4d05a54c-a5602475", "type": "main", "index": 0}]]}}, "name": "Manualtrigger Workflow", "settings": {"executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": null, "timezone": "UTC", "executionTimeout": 3600, "maxExecutions": 1000, "retryOnFail": true, "retryCount": 3, "retryDelay": 1000}, "description": "Automated workflow: Manualtrigger Workflow. This workflow integrates 18 different services: filter, httpRequest, stickyNote, textSplitterRecursiveCharacterTextSplitter, vectorStoreQdrant. It contains 48 nodes and follows best practices for error handling and security.", "tags": ["automation", "n8n", "production-ready", "excellent", "optimized"], "notes": "Excellent quality workflow: Manualtrigger Workflow. This workflow has been optimized for production use with comprehensive error handling, security, and documentation."}