The n8n workflow runs as a sequential agentic pipeline with 12 nodes.


Node-by-Node Breakdown

Node 1 — Webhook Trigger

Method: POST. Receives the raw form submission payload. Configured for persistent uptime via Cloudflare Zero Trust tunnel on Oracle Cloud VM.

Node 2 — Validate Input

Code node. Checks all required fields are present. Sanitises special characters. Structures the payload into a clean object for downstream processing.

Node 3 — Format for Agent

Code node. Assembles the structured prompt context — combining cleaned form data into a formatted string the Gemini agent can reason over consistently.

Node 4 — Gemini Agent

LLM reasoning node. Evaluates the lead against the 6-factor scoring rubric. Temperature set to 0.2 for deterministic output. Instructed to return strict JSON only — no markdown, no preamble.

Node 5 — Parse AI Response

Code node. Extracts the output field from the Gemini response. Strips residual markdown artifacts. Parses JSON. Validates structure. Applies safe defaults if any field is missing. Calculates processing latency in milliseconds.

Node 6 — Priority Router (IF Node)

Condition: score ≥ 80. TRUE path → high-priority branch. FALSE path → standard branch.

Node 7a — Set High Priority Email

Code node (TRUE branch). Assembles personalised email using AI summary, lead name, and company context from the scored output.

Node 7b — Set Standard Email

Code node (FALSE branch). Assembles the standard response email for lower-scored leads.

Node 8 — Send Email via Brevo