{
  "name": "3ADK Starter — Notification Slack Nouveau Lead",
  "nodes": [
    {
      "parameters": {
        "content": "## 🔔 Workflow Starter — Notification Slack Nouveau Lead\n\n**Ce workflow fait (8 nœuds) :**\n1. Reçoit un lead via webhook (Typeform, Tally, formulaire site)\n2. Normalise les données reçues (prénom, email, entreprise, besoin, source)\n3. Vérifie que l'email est présent et valide\n4. Envoie une notification Slack formatée avec les infos du lead\n5. Répond au webhook (succès ou erreur)\n\n**Configuration requise (5 min) :**\n- ⚙️ Remplacer [VOTRE_SLACK_WEBHOOK_URL] dans le nœud Notification Slack\n- ⚙️ Copier l'URL Webhook n8n dans votre formulaire\n\n**Obtenir votre Slack Webhook URL :**\nhttps://api.slack.com/messaging/webhooks\n\n**Support :** contact@3adkagency.fr — 3ADK Agency",
        "height": 280,
        "width": 400,
        "color": 4
      },
      "id": "note-main-3adk-slack-v1",
      "name": "📋 Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-280, -220]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "nouveau-lead-slack",
        "responseMode": "responseNode",
        "options": {
          "rawBody": false
        }
      },
      "id": "webhook-3adk-lead-slack-v1",
      "name": "📥 Réception Lead (Webhook)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [200, 300],
      "webhookId": "3adk-slack-starter-v1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "s1",
              "name": "prenom",
              "value": "={{ $json.prenom || $json.first_name || $json.firstName || 'Inconnu' }}",
              "type": "string"
            },
            {
              "id": "s2",
              "name": "nom",
              "value": "={{ $json.nom || $json.last_name || $json.lastName || '' }}",
              "type": "string"
            },
            {
              "id": "s3",
              "name": "email",
              "value": "={{ ($json.email || '').toLowerCase().trim() }}",
              "type": "string"
            },
            {
              "id": "s4",
              "name": "entreprise",
              "value": "={{ $json.entreprise || $json.company || $json.organization || 'Non renseigné' }}",
              "type": "string"
            },
            {
              "id": "s5",
              "name": "besoin",
              "value": "={{ $json.besoin || $json.message || $json.need || 'Non précisé' }}",
              "type": "string"
            },
            {
              "id": "s6",
              "name": "source",
              "value": "={{ $json.source || $json.utm_source || 'formulaire' }}",
              "type": "string"
            },
            {
              "id": "s7",
              "name": "date_reception",
              "value": "={{ $now.format('DD/MM/YYYY HH:mm') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "set-normalize-3adk-slack-v1",
      "name": "🔧 Normalisation des données",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [440, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.email }}",
              "rightValue": "@",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "if-email-valide-3adk-slack-v1",
      "name": "✅ Email valide ?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://hooks.slack.com/services/[VOTRE_SLACK_WEBHOOK_URL]",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": \"Nouveau lead reçu — {{ $json.date_reception }}\",\n  \"blocks\": [\n    {\n      \"type\": \"header\",\n      \"text\": {\n        \"type\": \"plain_text\",\n        \"text\": \"🔔 Nouveau lead — {{ $json.prenom }} {{ $json.nom }}\",\n        \"emoji\": true\n      }\n    },\n    {\n      \"type\": \"section\",\n      \"fields\": [\n        { \"type\": \"mrkdwn\", \"text\": \"*Email :*\\n{{ $json.email }}\" },\n        { \"type\": \"mrkdwn\", \"text\": \"*Entreprise :*\\n{{ $json.entreprise }}\" },\n        { \"type\": \"mrkdwn\", \"text\": \"*Besoin :*\\n{{ $json.besoin }}\" },\n        { \"type\": \"mrkdwn\", \"text\": \"*Source :*\\n{{ $json.source }}\" }\n      ]\n    },\n    {\n      \"type\": \"divider\"\n    },\n    {\n      \"type\": \"context\",\n      \"elements\": [\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"Reçu le {{ $json.date_reception }} · Workflow 3ADK Slack Starter v1\"\n        }\n      ]\n    }\n  ]\n}",
        "options": {}
      },
      "id": "http-slack-3adk-v1",
      "name": "📣 Notification Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [920, 200]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"status\": \"success\",\n  \"message\": \"Lead reçu — notification Slack envoyée\",\n  \"lead\": {\n    \"prenom\": \"{{ $('🔧 Normalisation des données').item.json.prenom }}\",\n    \"email\": \"{{ $('🔧 Normalisation des données').item.json.email }}\",\n    \"recu_le\": \"{{ $('🔧 Normalisation des données').item.json.date_reception }}\"\n  }\n}",
        "options": {}
      },
      "id": "respond-success-3adk-slack-v1",
      "name": "✅ Réponse Succès",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [1160, 200]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"status\": \"error\",\n  \"message\": \"Email manquant ou invalide — lead non traité\"\n}",
        "options": {
          "responseCode": 400
        }
      },
      "id": "respond-error-3adk-slack-v1",
      "name": "❌ Réponse Erreur (email manquant)",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [920, 440]
    },
    {
      "parameters": {
        "content": "**⚙️ Configuration Slack Incoming Webhook :**\n\n1. Aller sur https://api.slack.com/apps\n2. Créer une app → From scratch\n3. Menu gauche → Incoming Webhooks → Activer\n4. Add New Webhook to Workspace\n5. Choisir le canal Slack de destination\n6. Copier l'URL générée\n7. Remplacer [VOTRE_SLACK_WEBHOOK_URL] dans le nœud Notification Slack\n\n**Format de l'URL :**\nhttps://hooks.slack.com/services/T.../B.../...\n\n**Test rapide :** curl -X POST -H 'Content-type: application/json' --data '{\"text\":\"test\"}' VOTRE_URL",
        "height": 240,
        "width": 380,
        "color": 7
      },
      "id": "note-config-slack-3adk-v1",
      "name": "⚙️ Guide Config Slack",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [880, -120]
    }
  ],
  "connections": {
    "📥 Réception Lead (Webhook)": {
      "main": [
        [
          {
            "node": "🔧 Normalisation des données",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔧 Normalisation des données": {
      "main": [
        [
          {
            "node": "✅ Email valide ?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "✅ Email valide ?": {
      "main": [
        [
          {
            "node": "📣 Notification Slack",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "❌ Réponse Erreur (email manquant)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📣 Notification Slack": {
      "main": [
        [
          {
            "node": "✅ Réponse Succès",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "pinData": {}
}
