{
 "name": "Upit sa sajta: potvrda kupcu odmah, tebi samo ozbiljni",
 "nodes": [
  {
   "name": "Upit sa sajta",
   "type": "n8n-nodes-base.formTrigger",
   "typeVersion": 2.2,
   "position": [
    0,
    0
   ],
   "parameters": {
    "formTitle": "Pošaljite upit",
    "formFields": {
     "values": [
      {
       "fieldLabel": "Ime",
       "requiredField": true
      },
      {
       "fieldLabel": "Mejl",
       "fieldType": "email",
       "requiredField": true
      },
      {
       "fieldLabel": "Poruka",
       "fieldType": "textarea",
       "requiredField": true
      }
     ]
    },
    "options": {}
   }
  },
  {
   "name": "AI procenjuje upit",
   "type": "@n8n/n8n-nodes-langchain.agent",
   "typeVersion": 2.2,
   "position": [
    200,
    110
   ],
   "parameters": {
    "promptType": "define",
    "text": "=Upit: {{ $json.Poruka }}",
    "options": {
     "systemMessage": "Dobijaš upit koji je stigao preko forme na sajtu jedne male firme. Proceni ga i odgovori SAMO JSON-om:\n{\"ocena\": \"OZBILJAN\" ili \"RASPITUJE SE\", \"trazi\": \"<šta traži, najviše pet reči, u pravilnom padežu — npr. „popravka bojlera”>\", \"rok\": \"<kada mu treba, njegovim rečima; ili „nije naveden”>\", \"mesto\": \"<gde; ili „nije navedeno”>\"}\nOZBILJAN je upit u kom osoba kaže šta joj tačno treba I navede kada joj treba ili gde se nalazi.\nRASPITUJE SE je sve ostalo: bez roka, „možda”, „nekad”, „otprilike”, samo pitanje za cenu.\nPiši na jeziku upita, latinicom. Ništa ne dodaji."
    }
   }
  },
  {
   "name": "AI model",
   "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
   "typeVersion": 1.2,
   "position": [
    200,
    330
   ],
   "parameters": {
    "model": {
     "__rl": true,
     "value": "gpt-4o",
     "mode": "list",
     "cachedResultName": "gpt-4o"
    },
    "options": {
     "temperature": 0
    }
   }
  },
  {
   "name": "Potvrda kupcu",
   "type": "n8n-nodes-base.gmail",
   "typeVersion": 2.1,
   "position": [
    500,
    220
   ],
   "parameters": {
    "sendTo": "={{ $('Upit sa sajta').first().json.Mejl }}",
    "subject": "Stigao je vaš upit",
    "emailType": "text",
    "message": "=Zdravo, {{ $('Upit sa sajta').first().json.Ime }}, vaš upit je stigao. Javljamo se u toku radnog dana.",
    "options": {
     "appendAttribution": false
    }
   }
  },
  {
   "name": "Ozbiljan kupac?",
   "type": "n8n-nodes-base.if",
   "typeVersion": 2.2,
   "position": [
    700,
    330
   ],
   "parameters": {
    "conditions": {
     "options": {
      "caseSensitive": true,
      "leftValue": "",
      "typeValidation": "loose",
      "version": 2
     },
     "conditions": [
      {
       "id": "c1",
       "leftValue": "={{ JSON.parse($('AI procenjuje upit').first().json.output.replace(/```json|```/g, '')).ocena }}",
       "rightValue": "OZBILJAN",
       "operator": {
        "type": "string",
        "operation": "equals"
       }
      }
     ],
     "combinator": "and"
    },
    "looseTypeValidation": true,
    "options": {}
   }
  },
  {
   "name": "Javi tebi odmah",
   "type": "n8n-nodes-base.telegram",
   "typeVersion": 1.2,
   "position": [
    900,
    440
   ],
   "parameters": {
    "chatId": "TVOJ-TELEGRAM-ID",
    "text": "={{ $('Upit sa sajta').first().json.Ime + ' traži: ' + JSON.parse($('AI procenjuje upit').first().json.output.replace(/```json|```/g, '')).trazi + '.\\nRok: ' + JSON.parse($('AI procenjuje upit').first().json.output.replace(/```json|```/g, '')).rok + ' · ' + JSON.parse($('AI procenjuje upit').first().json.output.replace(/```json|```/g, '')).mesto + '\\n„' + $('Upit sa sajta').first().json.Poruka + '”' }}",
    "additionalFields": {
     "appendAttribution": false
    }
   }
  }
 ],
 "connections": {
  "Upit sa sajta": {
   "main": [
    [
     {
      "node": "AI procenjuje upit",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "AI procenjuje upit": {
   "main": [
    [
     {
      "node": "Potvrda kupcu",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Potvrda kupcu": {
   "main": [
    [
     {
      "node": "Ozbiljan kupac?",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Ozbiljan kupac?": {
   "main": [
    [
     {
      "node": "Javi tebi odmah",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "AI model": {
   "ai_languageModel": [
    [
     {
      "node": "AI procenjuje upit",
      "type": "ai_languageModel",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 }
}
