← All N8N workflows
Automation & utilitiesCodeRespond To WebhookEdit FieldsWebhook

Calculate the Centroid of a Set of Vectors

Configured with Respond To Webhook, Webhook. Review the connections and setup before adapting this template.

Workflow preview
TriggerReceive VectorsWebhookTransformExtract & Parse VectorsEdit FieldsCodeValidate & ComputeCentroidCodeWeb / APIReturn CentroidResponseRespond To Webhook

Node categories in this workflow

  • Trigger
  • Transform
  • Code
  • Web / API

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Receive VectorsTriggerWebhookSee node parameters
Extract & Parse VectorsTransformEdit FieldsSee node parameters
Validate & Compute CentroidCodeCodeSee node parameters
Return Centroid ResponseWeb / APIRespond To WebhookSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

None declared. HTTP requests and Code nodes may still need configuration.

Workflow notes

Sticky Note

📌 Description:
This node extracts the vectors array from the GET request and converts it into a properly formatted array for processing.

  • Ensures vectors is a valid array.
  • If the parameter is missing, it may generate an error.

🔹 Expected Output Example:

{
  "vectors": [[2,3,4],[4,5,6],[6,7,8]]
}
Sticky Note1

📌 Description:
This node performs vector validation and centroid computation.

  • 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:

{
  "centroid": [4,5,6]
}

🔹 Error Output Example:

{
  "error": "Vectors have inconsistent dimensions."
}
Sticky Note2

📌 Description:
This node sends the final response back to the client that made the request.

  • If the computation is successful, it returns the centroid.
  • If an error occurs, it returns a descriptive error message.

🔹 Example Response:

{
  "centroid": [4, 5, 6]
}
Sticky Note4

📌 Description:
This node acts as the entry point for the workflow, receiving a GET request containing an array of vectors in the vectors parameter.

  • Expected Input: vectors parameter in JSON format.
  • Example Request:
    https://actions.singular-innovation.com/webhook-test/centroid?vectors=[[2,3,4],[4,5,6],[6,7,8]]
    
  • Output: Passes the received data to the next node for processing.
Calculate the Centroid of a Set of Vectors

Calculate the Centroid of a Set of Vectors

Purpose and structure

This folder contains the Calculate the Centroid of a Set of Vectors workflow. Its executable nodes use code, respondToWebhook, set, webhook. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Receive Vectors

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/1862_Code_Respondtowebhook_Automation_Webhook.json MIT; preserve source notices.

More in Automation & utilities