{ "name": "AI Vision GUI Agent Flow", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "vision-agent-trigger", "responseMode": "lastNode", "options": {} }, "id": "node-trigger", "name": "🚀 Trigger (Webhook)", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [0, 300], "notes": "Start the flow. POST {task: 'your task', image_url: 'optional'}" }, { "parameters": { "method": "POST", "url": "https://YOUR-HF-SPACE.hf.space/node/capture", "sendBody": true, "contentType": "multipart-form-data", "bodyParameters": { "parameters": [ { "name": "file", "value": "={{ $json.screenshot_b64 }}", "parameterType": "formBinaryData" } ] }, "options": {} }, "id": "node-capture", "name": "📸 NODE 1 — Capture", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [240, 300], "notes": "Upload screenshot. Returns image_b64 + dimensions." }, { "parameters": { "method": "POST", "url": "https://YOUR-HF-SPACE.hf.space/node/detect", "sendBody": true, "contentType": "json", "body": "={\n \"image_b64\": \"{{ $json.image_b64 }}\",\n \"target_colors\": [\"#FF90E8\",\"#000000\",\"#0066FF\"]\n}", "options": {} }, "id": "node-detect", "name": "🔍 NODE 2 — Detect Elements", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [480, 300], "notes": "Finds UI buttons/fields by color analysis. Returns element list." }, { "parameters": { "method": "POST", "url": "https://YOUR-HF-SPACE.hf.space/node/decide", "sendBody": true, "contentType": "json", "body": "={\n \"task\": \"{{ $('🚀 Trigger (Webhook)').item.json.task }}\",\n \"elements\": {{ $json.elements }},\n \"safety_mode\": true\n}", "options": {} }, "id": "node-decide", "name": "🧠 NODE 3 — LLM Decide (Groq)", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [720, 300], "notes": "Groq llama-3.3-70b picks action + target coords. Safety mode flags medical." }, { "parameters": { "conditions": { "options": { "caseSensitive": true }, "conditions": [ { "leftValue": "={{ $json.blocked }}", "rightValue": true, "operator": { "type": "boolean", "operation": "equals" } } ] } }, "id": "node-safety-check", "name": "🛡️ Safety Gate", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [960, 300], "notes": "If blocked=true → send HITL alert. Else → proceed to execute." }, { "parameters": { "method": "POST", "url": "https://YOUR-HF-SPACE.hf.space/node/execute", "sendBody": true, "contentType": "json", "body": "={\n \"action\": \"{{ $('🧠 NODE 3 — LLM Decide (Groq)').item.json.action }}\",\n \"target_x\": {{ $('🧠 NODE 3 — LLM Decide (Groq)').item.json.target_x }},\n \"target_y\": {{ $('🧠 NODE 3 — LLM Decide (Groq)').item.json.target_y }},\n \"text\": \"{{ $('🧠 NODE 3 — LLM Decide (Groq)').item.json.text }}\",\n \"dry_run\": true\n}", "options": {} }, "id": "node-execute", "name": "⚡ NODE 4 — Execute Action", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1200, 180], "notes": "Runs the action. dry_run=true = simulate. Set false for real clicks." }, { "parameters": { "jsCode": "// HITL Alert — blocked action\nconst decision = $('🧠 NODE 3 — LLM Decide (Groq)').item.json;\nreturn [{\n json: {\n alert: 'HUMAN REVIEW REQUIRED',\n reason: decision.reason || 'Sensitive action flagged',\n action: decision.action,\n target: { x: decision.target_x, y: decision.target_y },\n timestamp: new Date().toISOString()\n }\n}];" }, "id": "node-hitl", "name": "🚨 HITL Alert", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [1200, 420], "notes": "Human-in-the-loop: blocked actions go here for review." }, { "parameters": { "method": "POST", "url": "https://YOUR-HF-SPACE.hf.space/node/verify", "sendBody": true, "contentType": "json", "body": "={\n \"before_b64\": \"{{ $('📸 NODE 1 — Capture').item.json.image_b64 }}\",\n \"after_b64\": \"{{ $('📸 NODE 1 — Capture').item.json.image_b64 }}\",\n \"threshold\": 0.02\n}", "options": {} }, "id": "node-verify", "name": "✅ NODE 5 — Verify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1440, 180], "notes": "Compare before/after screenshots. Returns diff% and success verdict." }, { "parameters": { "method": "POST", "url": "https://YOUR-HF-SPACE.hf.space/node/report", "sendBody": true, "contentType": "json", "body": "={\n \"task\": \"{{ $('🚀 Trigger (Webhook)').item.json.task }}\",\n \"results\": [\n {{ $('📸 NODE 1 — Capture').item.json }},\n {{ $('🔍 NODE 2 — Detect Elements').item.json }},\n {{ $('🧠 NODE 3 — LLM Decide (Groq)').item.json }},\n {{ $('⚡ NODE 4 — Execute Action').item.json }},\n {{ $json }}\n ]\n}", "options": {} }, "id": "node-report", "name": "📊 NODE 6 — Report", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1680, 180], "notes": "Aggregates all node outputs → final summary. Optional webhook to Slack." } ], "connections": { "🚀 Trigger (Webhook)": { "main": [[{ "node": "📸 NODE 1 — Capture", "type": "main", "index": 0 }]] }, "📸 NODE 1 — Capture": { "main": [[{ "node": "🔍 NODE 2 — Detect Elements", "type": "main", "index": 0 }]] }, "🔍 NODE 2 — Detect Elements": { "main": [[{ "node": "🧠 NODE 3 — LLM Decide (Groq)", "type": "main", "index": 0 }]] }, "🧠 NODE 3 — LLM Decide (Groq)": { "main": [[{ "node": "🛡️ Safety Gate", "type": "main", "index": 0 }]] }, "🛡️ Safety Gate": { "main": [ [{ "node": "🚨 HITL Alert", "type": "main", "index": 0 }], [{ "node": "⚡ NODE 4 — Execute Action", "type": "main", "index": 0 }] ] }, "⚡ NODE 4 — Execute Action": { "main": [[{ "node": "✅ NODE 5 — Verify", "type": "main", "index": 0 }]] }, "✅ NODE 5 — Verify": { "main": [[{ "node": "📊 NODE 6 — Report", "type": "main", "index": 0 }]] } }, "pinData": {}, "settings": { "executionOrder": "v1" }, "tags": [{ "name": "vision-agent" }, { "name": "gui-automation" }] }