{
  "name": "AI Araçlar - Formdan CRM talep kuyruğu",
  "nodes": [
    {
      "parameters": {},
      "id": "manual-trigger",
      "name": "Sentetik testi başlat",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-700, 180]
    },
    {
      "parameters": {
        "jsCode": "return [\n { json: { talep_id: 'F-3001', ad: 'Selin', eposta: 'selin@example.com', ihtiyac: 'Teklif ve fiyat bilgisi', izin: true } },\n { json: { talep_id: 'F-3002', ad: 'Arda', eposta: '', ihtiyac: 'Hesabıma erişemiyorum', izin: true } },\n { json: { talep_id: 'F-3003', ad: 'Bot', eposta: 'spam@example.com', ihtiyac: 'BUY NOW http://spam.example', izin: false } },\n { json: { talep_id: 'F-3001', ad: 'Selin', eposta: 'selin@example.com', ihtiyac: 'Aynı talep yeniden geldi', izin: true } }\n];"
      },
      "id": "fixture-data",
      "name": "Form test kayıtları",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [-470, 180]
    },
    {
      "parameters": { "httpMethod": "POST", "path": "aiaraclar-talep", "responseMode": "onReceived", "options": {} },
      "id": "webhook",
      "name": "Form webhook'u",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [-470, -40],
      "webhookId": "replace-after-import",
      "disabled": true
    },
    {
      "parameters": {
        "jsCode": "const seen = new Set();\nreturn $input.all().map((item) => {\n const row = item.json.body ?? item.json;\n const id = String(row.talep_id ?? '').trim();\n const email = String(row.eposta ?? '').trim().toLocaleLowerCase('en-US');\n const need = String(row.ihtiyac ?? '').trim();\n const duplicate = Boolean(id && seen.has(id));\n if (id) seen.add(id);\n const spam = /https?:\\/\\/|buy now|casino/i.test(need);\n const valid = Boolean(id && email.includes('@') && need && row.izin === true && !duplicate && !spam);\n const tag = /eriş|hata|sorun|destek/i.test(need) ? 'destek' : /teklif|fiyat|satın/i.test(need) ? 'satış' : 'iş ortaklığı';\n const priority = /acil|erişemiyorum|üretim durdu/i.test(need) ? 'yüksek' : 'normal';\n return { json: { talep_id: id, ad: String(row.ad ?? '').trim(), eposta: email, ihtiyac: need, etiket: tag, oncelik: priority, durum: valid ? 'crm_kuyrugu' : 'incele', hata_notu: duplicate ? 'yinelenen talep_id' : spam ? 'spam şüphesi' : valid ? '' : 'zorunlu alan veya izin eksik' } };\n});"
      },
      "id": "normalize",
      "name": "Doğrula ve CRM alanlarına eşle",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [-190, 100]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 },
          "conditions": [{ "id": "valid", "leftValue": "={{ $json.durum }}", "rightValue": "crm_kuyrugu", "operator": { "type": "string", "operation": "equals" } }],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "route",
      "name": "CRM'e uygun mu?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [70, 100]
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "upsert",
        "email": "={{ $json.eposta }}",
        "additionalFields": { "firstName": "={{ $json.ad }}" }
      },
      "id": "hubspot",
      "name": "HubSpot kişisini oluştur veya güncelle",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [350, 0],
      "disabled": true
    },
    {
      "parameters": { "jsCode": "return $input.all().map((item) => ({ json: { ...item.json, sonuc: 'CRM yazımı durduruldu; insan incelemesi gerekli' } }));" },
      "id": "review",
      "name": "İnceleme kuyruğu",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [350, 210]
    },
    {
      "parameters": {
        "content": "## Yayına alma sırası\nSentetik testte 1 geçerli, 1 eksik, 1 spam ve 1 tekrar kayıt görünmelidir. Sonra webhook'u açın, form alanlarını eşleyin ve HubSpot credential'ını seçin. CRM düğümü bilerek kapalıdır; sandbox'ta beş kaydı elle karşılaştırmadan etkinleştirmeyin. Başka CRM kullanıyorsanız son düğümü değiştirin, `talep_id` eşsiz anahtarını koruyun.",
        "height": 240,
        "width": 430
      },
      "id": "note",
      "name": "Kurulum notu",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-700, -290]
    }
  ],
  "connections": {
    "Sentetik testi başlat": { "main": [[{ "node": "Form test kayıtları", "type": "main", "index": 0 }]] },
    "Form test kayıtları": { "main": [[{ "node": "Doğrula ve CRM alanlarına eşle", "type": "main", "index": 0 }]] },
    "Form webhook'u": { "main": [[{ "node": "Doğrula ve CRM alanlarına eşle", "type": "main", "index": 0 }]] },
    "Doğrula ve CRM alanlarına eşle": { "main": [[{ "node": "CRM'e uygun mu?", "type": "main", "index": 0 }]] },
    "CRM'e uygun mu?": { "main": [[{ "node": "HubSpot kişisini oluştur veya güncelle", "type": "main", "index": 0 }], [{ "node": "İnceleme kuyruğu", "type": "main", "index": 0 }]] }
  },
  "pinData": {},
  "active": false,
  "settings": { "executionOrder": "v1" },
  "versionId": "c0cc674d-a56f-4585-91e3-21e28aafbcfa",
  "meta": { "templateCredsSetupCompleted": false },
  "tags": []
}
