Calculate the Centroid of a Set of Vectors
Configured with Respond To Webhook, Webhook. Review the connections and setup before adapting this template.
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.
| Node | Category | Type | Operation |
|---|---|---|---|
| Receive Vectors | Trigger | Webhook | See node parameters |
| Extract & Parse Vectors | Transform | Edit Fields | See node parameters |
| Validate & Compute Centroid | Code | Code | See node parameters |
| Return Centroid Response | Web / API | Respond To Webhook | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- 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
vectorsis 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:
vectorsparameter 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.