{
  "name": "AI Lead Agent - סוכן לידים חכם",
  "nodes": [
    {
      "parameters": {
        "formTitle": "דברו איתנו - Ilan AI Studio",
        "formDescription": "ספרו לנו מה אתם צריכים ונחזור אליכם תוך 24 שעות",
        "formFields": {
          "values": [
            {
              "fieldLabel": "שם מלא",
              "requiredField": true
            },
            {
              "fieldLabel": "חברה"
            },
            {
              "fieldLabel": "אימייל",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "מה אתם מחפשים?",
              "fieldType": "textarea",
              "requiredField": true
            },
            {
              "fieldLabel": "תקציב משוער",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "עד 5,000 ₪"
                  },
                  {
                    "option": "5,000 - 20,000 ₪"
                  },
                  {
                    "option": "מעל 20,000 ₪"
                  },
                  {
                    "option": "עדיין לא יודעים"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "appendAttribution": false,
          "respondWithOptions": {
            "values": {
              "formSubmittedText": "תודה! קיבלנו את הפנייה - נחזור אליכם בקרוב 🙌"
            }
          }
        }
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        -864,
        -32
      ],
      "id": "form-trigger-node",
      "name": "טופס ליד נכנס"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=פנייה חדשה מהאתר:\nשם: {{ $json['שם מלא'] }}\nחברה: {{ $json['חברה'] }}\nאימייל: {{ $json['אימייל'] }}\nמה מחפשים: {{ $json['מה אתם מחפשים?'] }}\nתקציב: {{ $json['תקציב משוער'] }}",
        "hasOutputParser": true,
        "messages": {
          "messageValues": [
            {
              "message": "אתה אנליסט לידים של סטודיו ישראלי ליישום AI (אוטומציות, סוכני AI, אינטגרציות). נתח את הפנייה וקבע: score (0-100, רצינות והתאמה), tier (hot מעל 70 / warm 40-70 / cold מתחת), reasons (2-3 נימוקים קצרים בעברית), next_action (המלצה קונקרטית אחת בעברית). שקול: בהירות הצורך, התאמה לשירותי הסטודיו, תקציב, סימני דחיפות. החזר JSON בלבד."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -528,
        -96
      ],
      "id": "qualify-node",
      "name": "ניתוח וציון הליד (Claude)"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "claude-sonnet-4-5"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.3,
      "position": [
        -672,
        176
      ],
      "id": "claude-model-node",
      "name": "Claude Sonnet"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"score\": 85,\n  \"tier\": \"hot\",\n  \"reasons\": [\"תקציב מוגדר\", \"צורך ברור באוטומציה\"],\n  \"next_action\": \"לקבוע שיחת היכרות של 20 דקות השבוע\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -416,
        208
      ],
      "id": "parser-node",
      "name": "Structured Output"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=כתוב טיוטת מייל תשובה קצרה וחמה בעברית לליד הבא. בלי נושא, רק גוף המייל. חתום בשם אילן.\n\nשם הפונה: {{ $('טופס ליד נכנס').item.json['שם מלא'] }}\nמה ביקשו: {{ $('טופס ליד נכנס').item.json['מה אתם מחפשים?'] }}\nהמלצת האנליסט: {{ $json.output.next_action }}",
        "messages": {
          "messageValues": [
            {
              "message": "אתה עוזר כתיבה של סטודיו ליישום AI. כתוב מיילים קצרים (עד 80 מילים), חמים ומקצועיים בעברית, שמסתיימים בהצעה לצעד הבא."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -128,
        -192
      ],
      "id": "draft-node",
      "name": "טיוטת מייל (Ollama מקומי)"
    },
    {
      "parameters": {
        "model": "aya-expanse:8b",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "typeVersion": 1,
      "position": [
        -176,
        80
      ],
      "id": "ollama-model-node",
      "name": "Ollama (על השרת שלי)"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "hot-cond",
              "leftValue": "={{ $('ניתוח וציון הליד (Claude)').item.json.output.score }}",
              "rightValue": 70,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        176,
        16
      ],
      "id": "if-node",
      "name": "ליד חם?"
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "text": "=🔥 ליד חם חדש! ציון {{ $('ניתוח וציון הליד (Claude)').item.json.output.score }}/100\n\n👤 {{ $('טופס ליד נכנס').item.json['שם מלא'] }} | {{ $('טופס ליד נכנס').item.json['חברה'] }}\n📧 {{ $('טופס ליד נכנס').item.json['אימייל'] }}\n💰 {{ $('טופס ליד נכנס').item.json['תקציב משוער'] }}\n\n📝 {{ $('טופס ליד נכנס').item.json['מה אתם מחפשים?'] }}\n\n🎯 המלצה: {{ $('ניתוח וציון הליד (Claude)').item.json.output.next_action }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        496,
        -176
      ],
      "id": "alert-node",
      "name": "🔥 התראת טלגרם"
    },
    {
      "parameters": {
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_DATA_TABLE_ID",
          "cachedResultName": "Leads CRM"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "name": "={{ $('טופס ליד נכנס').item.json['שם מלא'] }}",
            "company": "={{ $('טופס ליד נכנס').item.json['חברה'] }}",
            "email": "={{ $('טופס ליד נכנס').item.json['אימייל'] }}",
            "need": "={{ $('טופס ליד נכנס').item.json['מה אתם מחפשים?'] }}",
            "budget": "={{ $('טופס ליד נכנס').item.json['תקציב משוער'] }}",
            "score": "={{ $('ניתוח וציון הליד (Claude)').item.json.output.score }}",
            "tier": "={{ $('ניתוח וציון הליד (Claude)').item.json.output.tier }}",
            "next_action": "={{ $('ניתוח וציון הליד (Claude)').item.json.output.next_action }}",
            "email_draft": "={{ $('טיוטת מייל (Ollama מקומי)').item.json.text }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "name",
              "displayName": "name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "company",
              "displayName": "company",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email",
              "displayName": "email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "need",
              "displayName": "need",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "budget",
              "displayName": "budget",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "score",
              "displayName": "score",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "tier",
              "displayName": "tier",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "next_action",
              "displayName": "next_action",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_draft",
              "displayName": "email_draft",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        704,
        80
      ],
      "id": "log-placeholder",
      "name": "רישום ב-CRM"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "mail-cond",
              "leftValue": "={{ $('ניתוח וציון הליד (Claude)').item.json.output.score }}",
              "rightValue": 20,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        960,
        96
      ],
      "id": "if-send-mail",
      "name": "לא ספאם?"
    },
    {
      "parameters": {
        "fromEmail": "Ilan AI Studio <ilan@ilans.net>",
        "toEmail": "={{ $('טופס ליד נכנס').item.json['אימייל'] }}",
        "subject": "=קיבלנו את הפנייה שלך, {{ $('טופס ליד נכנס').item.json['שם מלא'] }} · Ilan AI Studio",
        "html": "=<div dir=\"rtl\" style=\"font-family:Arial,sans-serif;max-width:560px;margin:0 auto;background:#f7f8fb;padding:24px;border-radius:12px\"><h2 style=\"color:#1a1f36;margin:0 0 4px\">היי {{ $('טופס ליד נכנס').item.json['שם מלא'] }} 👋</h2><p style=\"color:#3c4257;font-size:15px;line-height:1.7\">תודה שפנית אלינו! קיבלנו את הבקשה שלך:</p><div style=\"background:#fff;border:1px solid #e3e8ee;border-radius:8px;padding:14px 16px;color:#1a1f36;font-size:14px;line-height:1.6\">{{ $('טופס ליד נכנס').item.json['מה אתם מחפשים?'] }}</div><p style=\"color:#3c4257;font-size:15px;line-height:1.7\">אנחנו עוברים על הפנייה ו<b>נחזור אליך תוך 24 שעות</b> עם כיוון ראשוני והצעה לשיחה קצרה.</p><p style=\"color:#3c4257;font-size:15px\">בינתיים, אפשר להציץ בעבודות שלנו: <a href=\"https://ai.ilans.net\" style=\"color:#635bff\">ai.ilans.net</a></p><p style=\"color:#1a1f36;font-size:15px;margin-top:20px\">נדבר בקרוב,<br><b>אילן לנצנר</b><br><span style=\"color:#8792a2;font-size:13px\">Ilan AI Studio · מיישם AI לעסקים</span></p></div>",
        "options": {}
      },
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1184,
        -64
      ],
      "id": "send-confirm-mail",
      "name": "✉️ מייל אישור לליד"
    }
  ],
  "connections": {
    "טופס ליד נכנס": {
      "main": [
        [
          {
            "node": "ניתוח וציון הליד (Claude)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ניתוח וציון הליד (Claude)": {
      "main": [
        [
          {
            "node": "טיוטת מייל (Ollama מקומי)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Sonnet": {
      "ai_languageModel": [
        [
          {
            "node": "ניתוח וציון הליד (Claude)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "ניתוח וציון הליד (Claude)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "טיוטת מייל (Ollama מקומי)": {
      "main": [
        [
          {
            "node": "ליד חם?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama (על השרת שלי)": {
      "ai_languageModel": [
        [
          {
            "node": "טיוטת מייל (Ollama מקומי)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "ליד חם?": {
      "main": [
        [
          {
            "node": "🔥 התראת טלגרם",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "רישום ב-CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔥 התראת טלגרם": {
      "main": [
        [
          {
            "node": "רישום ב-CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "רישום ב-CRM": {
      "main": [
        [
          {
            "node": "לא ספאם?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "לא ספאם?": {
      "main": [
        [
          {
            "node": "✉️ מייל אישור לליד",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "note": "AI Lead Agent - exported from a live self-hosted n8n 2.31.6. Credentials, chat IDs and table IDs replaced with placeholders. Wire your own: Anthropic API, Ollama (http://127.0.0.1:11434), Telegram bot, SMTP."
  }
}