I was wondering how can n8n can select and connect nodes does the system prompt plays main role or the llm model if system prompt does then how the system prompt is written what is the flow

I am Ai devloper and was researching on the automation i wonder how the n8n make possible to select and connect the acurate nodes

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Good question. It’s actually a combination of both but the LLM does the heavy lifting.

When n8n’s AI builds or suggests workflows, it works like this:

The system prompt gives the LLM context about what n8n is, what nodes exist, what they do, and how they connect. Think of it as the instruction manual the LLM reads before doing anything. It tells the model the rules, which nodes are available, what inputs and outputs they accept, and how the connection logic works.

The LLM then uses that context combined with your natural language request to figure out which nodes to select and how to wire them together. The model isn’t hardcoded to pick specific nodes, it reasons about your goal and maps it to the right tools based on what the system prompt told it was available.

So in simple terms, the system prompt defines the boundaries and available tools, the LLM does the reasoning and decision making inside those boundaries.

If you’re trying to build something similar yourself, the key is making your system prompt very specific about what each tool does and what its inputs and outputs look like. The more precise the tool descriptions, the better the LLM connects them in the right order.
Hope that helps with your research.