Neo4j icon

Neo4j

Interact with a Neo4j graph database

Overview

This n8n node allows you to create a relationship between two nodes in a Neo4j graph database. It is useful for automating the process of linking entities (such as people, companies, or other objects) with specific relationships (like WORKS_AT, KNOWS, etc.). Common scenarios include building knowledge graphs, managing organizational structures, or tracking connections between various data points.

Example use cases:

  • Connecting a "Person" node to a "Company" node with a "WORKS_AT" relationship.
  • Linking two users with a "KNOWS" relationship in a social network graph.

Properties

Below are the input properties relevant to the Create Relationship operation:

Display Name Type Description
Start Node Match Labels String Labels of the starting node for the relationship (optional). Example: Person.
Start Node Match Properties JSON Properties to uniquely identify the starting node (required). Example:
{"ID": "{{ $json.startNodeID }}"}
End Node Match Labels String Labels of the ending node for the relationship (optional). Example: Company.
End Node Match Properties JSON Properties to uniquely identify the ending node (required). Example:
{"ID": "{{ $json.endNodeID }}"}
Relationship Type String The type of the relationship (required). Must be a valid Neo4j type name (letters, numbers, underscores).
Relationship Properties JSON Properties for the relationship (optional). Example:
{"since": "{{ $now.year }}", "role": "Developer"}
Options > Return Data Boolean Whether to return the created relationship's element ID, type, and properties. Default: true.

Output

The output will contain information about the created relationship if Return Data is enabled. The structure typically includes:

{
  "elementId": "string",         // Unique identifier of the created relationship
  "type": "string",              // Relationship type (e.g., WORKS_AT)
  "properties": {                // Key-value pairs of relationship properties
    "since": "2024",
    "role": "Developer"
  }
}

If binary data is returned (not typical for this operation), it would represent exported or serialized relationship data.

Dependencies

  • Neo4j Database: You must have access to a running Neo4j instance.
  • Credentials: Requires n8n credentials of type neo4jApi (typically includes connection URL, username, and password).

Troubleshooting

Common issues:

  • Authentication errors: Ensure your Neo4j credentials are correct and that the database is accessible from n8n.
  • Node not found: If the start or end node cannot be uniquely identified by the provided properties, the relationship will not be created. Double-check your match properties.
  • Invalid relationship type: The relationship type must only contain letters, numbers, or underscores.
  • Malformed JSON: Ensure all JSON fields (match properties, relationship properties) are valid JSON objects.

Error messages you might encounter:

  • "Could not authenticate to Neo4j": Check your credentials and network connectivity.
  • "No matching node found for given properties": Verify the node properties and labels.
  • "Invalid relationship type": Use only allowed characters in the relationship type.

Links and References

Discussion