Data & Analytics Workflows
Data processing and analytics
Calculate the Centroid of a Set of Vectors
# n8n Workflow: Calculate the Centroid of a Set of Vectors ## Overview This workflow receives an array of vectors in JSON format, validates that all vectors have the same dimensions, and computes the centroid. It is designed to be reusable across different projects. ## Workflow Structure ### Nodes and Their Functions: 1. **Receive Vectors (Webhook)**: Accepts a GET request containing an array of vectors in the `vectors` parameter. - **Expected Input:** `vectors` parameter in JSON format. - **Example Request:** `/webhook/centroid?vectors=[[2,3,4],[4,5,6],[6,7,8]]` - **Output:** Passes the received data to the next node. 2. **Extract & Parse Vectors (Set Node)**: Converts the input string into a proper JSON array for processing. - **Ensures `vectors` is a valid array.** - **If the parameter is missing, it may generate an error.** - **Expected Output Example:** ```json { "vectors": [[2,3,4],[4,5,6],[6,7,8]] } ``` 3. **Validate & Compute Centroid (Code Node)**: Validates vector dimensions and calculates the centroid. - **Validation:** Ensures all vectors have the same number of dimensions. - **Computation:** Averages each dimension to determine the centroid. - **If validation fails:** Returns an error message indicating inconsistent dimensions. - **Successful Output Example:** ```json { "centroid": [4,5,6] } ``` - **Error Output Example:** ```json { "error": "Vectors have inconsistent dimensions." } ``` 4. **Return Centroid Response (Respond to Webhook Node)**: Sends the final response back to the client. - **If the computation is successful**, it returns the centroid. - **If an error occurs**, it returns a descriptive error message. - **Example Response:** ```json { "centroid": [4, 5, 6] } ``` ## Inputs - JSON array of vectors, where each vector is an array of numerical values. ### Example Input ```json { "vectors": [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] } ``` ## Setup Guide 1. **Create a new workflow in n8n**. 2. **Add a Webhook node** (`Receive Vectors`) to receive JSON input. 3. **Add a Set node** (`Extract & Parse Vectors`) to extract and convert the data. 4. **Add a Code node** (`Validate & Compute Centroid`) to: - Validate dimensions. - Compute the centroid. 5. **Add a Respond to Webhook node** (`Return Centroid Response`) to return the result. ### Function Node Script Example ```javascript const input = items[0].json; const vectors = input.vectors; if (!Array.isArray(vectors) || vectors.length === 0) { return [{ json: { error: "Invalid input: Expected an array of vectors." } }]; } const dimension = vectors[0].length; if (!vectors.every(v => v.length === dimension)) { return [{ json: { error: "Vectors have inconsistent dimensions." } }]; } const centroid = new Array(dimension).fill(0); vectors.forEach(vector => { vector.forEach((val, index) => { centroid[index] += val; }); }); for (let i = 0; i < dimension; i++) { centroid[i] /= vectors.length; } return [{ json: { centroid } }]; ``` ## Testing - Use a tool like Postman or the n8n UI to send sample inputs and verify the responses. - Modify the input vectors to test different scenarios. This workflow provides a simple yet flexible solution for vector centroid computation, ensuring validation and reliability.
n8n$4.99Automate Airtable Record Updates on New Trigger Events
Seamlessly update Airtable records in response to new trigger events, ensuring your database remains up-to-date and organized with minimal manual intervention.
Make$2.99Automate Daily Currency Exchange Rate Updates in Google Sheets
Automatically fetch daily currency exchange rates using Mallabe Currencies and update them in a Google Sheets document. This workflow ensures you have the latest exchange rates for specified currencies at your fingertips.
Make$2.99Add new rows to Google BigQuery from a custom webhook
Streamline your data management process by automatically adding new entries to Google BigQuery whenever a custom webhook is triggered. This template allows you to efficiently capture and store data from various sources, ensuring that your analytics and reporting are always up-to-date. Perfect for developers and data analysts looking to enhance their data workflows without manual intervention.
Make$2.99Automate HubSpot API Pagination for Contact Retrieval
Efficiently handle pagination in HubSpot API requests to retrieve all contacts by leveraging n8n's automation capabilities.
n8n$4.99Distribute Data Across Multiple HTTP Endpoints
Efficiently send data to multiple HTTP endpoints using this automated workflow. Streamline your data distribution process with reliable HTTP requests.
Make$3.99Filtering and Branching Data
**Ask:** Conditional filtering and branching items **Why:** Filtering and branching data based on conditions allows you to build complex workflows that work with more than one data flow scenario. **Main use cases:** - Filter out data that is not relevant for the rest of the workflow. - Split data into several branches of the workflow, where we want the data to be treated differently in the rest of the workflow.
n8n$9.99Automate News Scraping with ScrapeGraphAI to Google Sheets
AI-powered workflow that scrapes news articles from websites using ScrapeGraphAI and stores structured data in Google Sheets for easy monitoring and analysis.
n8n$14.99**Visualize Your n8n Workflows with Mermaid.js!**
## Are you a visual thinker working with n8n? View and understand workflow structures at a glance with this template! Built with mermaid.js, Bootstrap 5, and AJAX to create an interactive web page displaying n8n workflows as flowcharts. Perfect for documentation, presentations, or just getting a clearer picture of your automation processes. Need customization help? Reach out to [Eduard](https://www.linkedin.com/in/parsadanyan/)! ### Benefits * Instant workflow visualization * Responsive design * Direct links to n8n workflows * Special shapes for different node types * Disabled node indication * No external dependencies - just paste the workflow and call the webhook * Easily customizable - enhance the JS script or add custom styling ### Important note for cloud users Since the cloud version doesn't support environmental variables, please make the following changes in the CONFIG node: * Update the `instance_url` variable: Enter your n8n URL instead of `{{$env[N8N_PROTOCOL]}}://{{$env[N8N_HOST]}}` * Change the `webhook_path` to simply "webhook" instead of `{{$env[N8N_ENDPOINT_WEBHOOK] || webhook}}` ### Examples 1. Multiple flowcharts on a single page:  2. Several shapes for different nodes:  3. Langchain nodes with special connections styling: 
n8n$9.99Automatically Add New QuickCapture Events to Airtable Records
Seamlessly create a new Airtable record whenever a new project event is detected in QuickCapture, ensuring your data is always up-to-date.
MakeFreeAutomate Email Validation in Airtable with Loqate
Automatically validate emails in Airtable using Loqate and remove invalid entries to maintain data integrity.
Make$3.99AI Bulk Optimizer for Rank Math SEO Titles & Descriptions
Automates bulk generation and update of SEO-optimized titles and meta descriptions for WordPress posts using AI and Rank Math plugin.
n8n$22.99Automatically Add New Mailparser.io Emails to Google Sheets
Automatically transfer parsed email data from Mailparser.io to Google Sheets, creating a new row for each email.
MakeFreeAutomatically Export SQL Data to Excel Spreadsheet
Effortlessly convert SQL query results into Excel spreadsheets for easy data management and sharing.
n8n$4.99Automatically Log Shopify Customer Emails to Google Sheets
Capture emails from your Shopify customers and automatically log them into a Google Sheet for easy tracking and management.
Make$3.99Retrieve and Verify DNS Records for Any Domain Using uProc
Effortlessly obtain and verify DNS records for any domain using the uProc tool in n8n. Ensure domain setups are correct by checking DNS records in real-time.
n8n$3.99Automate Email Validation and Status Update in Google Sheets with TrueMail
Automatically validate emails from a Google Sheet using TrueMail and update the sheet with the validation status. This workflow ensures your email list is accurate and up-to-date.
Make$3.99CyberPulse AI RedOps: Generate Daily RedOps Security Simulation Reports
## Description Automatically compiles a daily HTML report of all RedOps simulations (Modules 1-5), summarizing offensive activity, response logs, and module effectiveness. Designed for GRC teams, Red/Purple teams, and internal auditors - no manual formatting required. ## Who's It For: - Red teams running daily simulations - Purple teams reviewing impact and response - CISOs, SOCs, or compliance teams requiring summaries ## How It Works: - Trigger manually or on schedule (e.g., daily cron) - Reads simulation logs from a shared Google Sheet - Filters data by time or module - Formats data into an HTML summary table - Sends email with report or uploads to Drive/S3 ## Requirements: - Gmail or SMTP node for email - Google Sheets connected (OAuth) ### Google Sheet Requirements: - Columns: `Date`, `Module`, `Action`, `Result`, `Status` - One row per offensive simulation log - Make sure headers are in the first row - Unified log format for RedOps Modules 1-5 ## File Templates: - RedOps_AutoReport_Log_Template.xlsx ## Customization Tips: - Set filtering timeframe (24h, 7d) in JavaScript node - Modify the table style in the HTML generator - Connect to PDF node or S3 for exporting to other tools ## Ethics & Compliance: This workflow is designed for internal reporting only. It does not simulate attacks or initiate actions. Use for audit logs, red team reviews, and awareness tracking only. ## Setup Instructions 1. Copy the provided Google Sheet template (linked in File Templates). 2. Fill in your RedOps logs (columns: date, module, action, result, status). 3. Connect Google Sheets node using OAuth credentials. 4. In the Gmail node: - Set recipient email (use `your_email@example.com` as a placeholder). - Choose HTML output from the summary table. 5. Trigger via Cron node (daily) or manually. 6. Optional: Connect Drive or S3 node to store a backup. Supports: - NIST 800-53 AU-6, AU-12 - ISO 27001 A.16.1.6 - ACSC Essential Eight reporting practices **Part of the CYBERPULSE RedOps Suite** š https://cyberpulsesolutions.com ā info@cyberpulsesolutions.com
n8n$4.99Automate Airtable Record Updates with Phantombuster CSV Data
Effortlessly update Airtable records using output data from Phantombuster, including CSV file uploads. This workflow streamlines data integration between Phantombuster and Airtable.
Make$4.99Synchronize Google Sheets Metrics with Orbit Members and Activities
Effortlessly sync member and activity data from Google Sheets to Orbit, ensuring your community metrics are always up-to-date.
n8n$4.99Sync Monday.com Item Updates to an HTTP Endpoint
Automatically synchronize updates from Monday.com items to a specified HTTP endpoint, ensuring real-time data consistency across platforms.
Make$3.99Bluesky New Follower Auto DM
Automatically sends welcome DMs to new Bluesky followers every 4 hours. Lightweight, stateless automation with no storage or dependencies needed.
n8n$9.99Automate JSON Data Transfer from Facebook Lead Ads
Seamlessly transfer new leads from Facebook Lead Ads to any destination in JSON format using Make's integration capabilities.
Make$3.99Automate Data Insertion into PostgreSQL via Custom Webhook
Effortlessly automate your data entry process by using a custom webhook to insert data into your PostgreSQL database. This workflow ensures your database remains current without manual updates, enhancing data management efficiency for developers and businesses.
Make$2.99
Related categories
Custom AI Systems & Services
Our team of experienced AI builders will help build custom AI systems, workflows, and solutions.
Request Custom Work