{
  "name": "Workshop – AI agent: kvalifikácia leadu",
  "active": false,
  "nodes": [
    {
      "id": "b1",
      "name": "Formulár – nový dopyt",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        0
      ],
      "webhookId": "ws-dopyt-formular",
      "parameters": {
        "formTitle": "Nezáväzný dopyt",
        "formDescription": "Cvičný formulár z workshopu AI Automatizácia v marketingu.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Meno",
              "requiredField": true
            },
            {
              "fieldLabel": "E-mail",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Firma"
            },
            {
              "fieldLabel": "Web firmy",
              "placeholder": "https://"
            },
            {
              "fieldLabel": "S čím potrebujete pomôcť?",
              "fieldType": "textarea",
              "requiredField": true
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "b2",
      "name": "AI agent – kvalifikácia leadu",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        280,
        0
      ],
      "parameters": {
        "promptType": "define",
        "text": "=Nový dopyt z webového formulára:\nMeno: {{ $json['Meno'] }}\nE-mail: {{ $json['E-mail'] }}\nFirma: {{ $json['Firma'] }}\nWeb firmy: {{ $json['Web firmy'] }}\nSpráva: {{ $json['S čím potrebujete pomôcť?'] }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=Si asistent obchodného tímu marketingovej agentúry, ktorá robí PPC kampane (Google Ads, Meta Ads) pre firmy. Tvojou úlohou je ohodnotiť nový dopyt a pripraviť odpoveď. Dnes je {{ $now.format('dd.MM.yyyy') }}.\n\nKategórie:\n- hot: firma s jasnou potrebou, ktorú vieme riešiť (reklama, kampane, meranie), ideálne s uvedeným rozpočtom alebo termínom\n- warm: relevantný záujem, ale chýba rozsah, rozpočet alebo je dopyt všeobecný\n- cold: študent, uchádzač o prácu, ponuka služieb pre nás, spam alebo dopyt mimo našich služieb\n\nAk je uvedený web firmy, najprv si ho pozri a zohľadni, čo firma robí. Ak web chýba alebo sa nedá načítať, rozhodni len podľa správy a nič si nedomýšľaj.\n\nNávrh odpovede píš po slovensky, vykaj, najviac 5 viet, bez sľubov o cene a výsledkoch.",
          "maxIterations": 6
        }
      }
    },
    {
      "id": "b3",
      "name": "Chat model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        200,
        240
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0.2
        }
      }
    },
    {
      "id": "b4",
      "name": "Pozri web firmy",
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        380,
        240
      ],
      "parameters": {
        "toolDescription": "Načíta text úvodnej stránky webu firmy, aby si zistil, čím sa firma zaoberá. Použi najviac raz, len keď lead uviedol web. Ak volanie zlyhá, pokračuj bez neho.",
        "url": "={{ $fromAI('url', 'Celá URL webu firmy vrátane https://, napr. https://www.firma.sk', 'string') }}",
        "optimizeResponse": true,
        "responseType": "html",
        "onlyContent": true,
        "truncateResponse": true,
        "maxLength": 3000
      }
    },
    {
      "id": "b5",
      "name": "Štruktúrovaný výstup",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        560,
        240
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"kategoria\": {\"type\": \"string\", \"enum\": [\"hot\", \"warm\", \"cold\"]},\n    \"dovod\": {\"type\": \"string\", \"description\": \"Jedna až dve vety, prečo táto kategória\"},\n    \"navrh_odpovede\": {\"type\": \"string\", \"description\": \"Návrh e-mailovej odpovede leadovi\"}\n  },\n  \"required\": [\"kategoria\", \"dovod\", \"navrh_odpovede\"]\n}",
        "autoFix": true
      }
    },
    {
      "id": "b6",
      "name": "Podľa kategórie",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        680,
        0
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c1",
                    "leftValue": "={{ $json.output.kategoria }}",
                    "rightValue": "hot",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "hot"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c2",
                    "leftValue": "={{ $json.output.kategoria }}",
                    "rightValue": "warm",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "warm"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c3",
                    "leftValue": "={{ $json.output.kategoria }}",
                    "rightValue": "cold",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "cold"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "b7",
      "name": "Hot → upozorni obchodníka",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        960,
        -200
      ],
      "parameters": {
        "sendTo": "vas@email.sk",
        "subject": "=[CVIČNÝ] HOT lead: {{ $('Formulár – nový dopyt').item.json['Meno'] }} ({{ $('Formulár – nový dopyt').item.json['Firma'] }})",
        "emailType": "html",
        "message": "=<p><b>{{ $('Formulár – nový dopyt').item.json['Meno'] }}</b> – {{ $('Formulár – nový dopyt').item.json['E-mail'] }}</p>\n<p><b>Správa:</b> {{ $('Formulár – nový dopyt').item.json['S čím potrebujete pomôcť?'] }}</p>\n<p><b>Prečo hot:</b> {{ $json.output.dovod }}</p>\n<p><b>Návrh odpovede:</b><br>{{ $json.output.navrh_odpovede }}</p>",
        "options": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "b8",
      "name": "Warm → koncept odpovede na schválenie",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        960,
        0
      ],
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "subject": "Ďakujeme za váš dopyt",
        "emailType": "html",
        "message": "={{ $json.output.navrh_odpovede }}",
        "options": {
          "sendTo": "={{ $('Formulár – nový dopyt').item.json['E-mail'] }}"
        }
      }
    },
    {
      "id": "b9",
      "name": "Cold → nič neposielaj",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        960,
        200
      ],
      "parameters": {}
    }
  ],
  "connections": {
    "Formulár – nový dopyt": {
      "main": [
        [
          {
            "node": "AI agent – kvalifikácia leadu",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI agent – kvalifikácia leadu": {
      "main": [
        [
          {
            "node": "Podľa kategórie",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat model": {
      "ai_languageModel": [
        [
          {
            "node": "AI agent – kvalifikácia leadu",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Štruktúrovaný výstup",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pozri web firmy": {
      "ai_tool": [
        [
          {
            "node": "AI agent – kvalifikácia leadu",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Štruktúrovaný výstup": {
      "ai_outputParser": [
        [
          {
            "node": "AI agent – kvalifikácia leadu",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Podľa kategórie": {
      "main": [
        [
          {
            "node": "Hot → upozorni obchodníka",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Warm → koncept odpovede na schválenie",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Cold → nič neposielaj",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}