{
  "name": "Du Webhook à la Production : Automatisation Métier avec APIs et IA",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "algeria-talk-demo",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -480,
        0
      ],
      "id": "e0b96837-e547-4c12-9c98-129487c95b71",
      "name": "01. Webhook Entrant",
      "webhookId": "algeria-talk-demo"
    },
    {
      "parameters": {
        "jsCode": "// Étape 02 : Contrôle d'intégrité et validation du schéma\nconst body = $json.body || $json;\n\nif (!body.email || !body.email.includes('@')) {\n  throw new Error('Validation échouée : adresse email manquante ou invalide');\n}\n\nif (!body.message || body.message.trim().length < 5) {\n  throw new Error('Validation échouée : message trop court ou manquant');\n}\n\nreturn {\n  json: {\n    validatedAt: new Date().toISOString(),\n    leadName: body.name || 'Anonyme',\n    leadEmail: body.email.trim().toLowerCase(),\n    leadCompany: body.company || 'Non renseigné',\n    rawMessage: body.message.trim(),\n    origin: 'Webhook Inbound Algeria 2.0'\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -240,
        0
      ],
      "id": "782f506e-1d57-4f7b-91bb-bfae3a6358db",
      "name": "02. Validation Payload"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.tassili.ai/v1/enrich",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"domain\": \"{{ $json.leadEmail.split('@')[1] }}\",\n  \"company\": \"{{ $json.leadCompany }}\"\n}",
        "options": {
          "retryOnFail": true,
          "maxTries": 3,
          "waitBetweenTries": 1000
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        0
      ],
      "id": "a90b4d45-6679-4509-a1b7-4a0058b8ef42",
      "name": "03. Appel API Métier (Enrichissement)",
      "continueOnFail": true
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Tu es un assistant IA spécialisé dans la qualification commerciale.\nAnalyse la demande suivante reçue par webhook :\n\n- Nom : {{ $('02. Validation Payload').item.json.leadName }}\n- Email : {{ $('02. Validation Payload').item.json.leadEmail }}\n- Entreprise : {{ $('02. Validation Payload').item.json.leadCompany }}\n- Message : {{ $('02. Validation Payload').item.json.rawMessage }}\n\nRetourne un objet JSON avec les clés suivantes :\n1. \"score\": note de 1 à 10 sur la pertinence du projet\n2. \"priorite\": \"HAUTE\", \"MOYENNE\" ou \"BASSE\"\n3. \"besoin_resume\": résumé en une phrase du besoin technique\n4. \"technologies_detectees\": tableau des technos mentionnées (n8n, API, LLM, etc.)",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        260,
        0
      ],
      "id": "c1f7da44-88aa-4785-80f0-c5339d37bb67",
      "name": "04. Classement IA & Qualification"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list"
        },
        "options": {
          "temperature": 0.2
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        220,
        220
      ],
      "id": "d44b55fa-92eb-44c6-b52e-0fa39281e59c",
      "name": "Modèle LLM OpenAI / Tassili"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXX",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": \"🚀 *Nouveau lead qualifié automatiquement via n8n*\",\n  \"blocks\": [\n    {\n      \"type\": \"section\",\n      \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": \"*Lead:* {{ $('02. Validation Payload').item.json.leadName }} ({{ $('02. Validation Payload').item.json.leadEmail }})\\n*Priorité:* {{ $json.priorite || 'MOYENNE' }}\\n*Besoin:* {{ $json.besoin_resume || $('02. Validation Payload').item.json.rawMessage }}\"\n      }\n    }\n  ]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        540,
        -100
      ],
      "id": "e8d697b4-4b57-48f8-b391-7f99990176df",
      "name": "05a. Notification Alerte (Slack / Webhook)"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"success\": true,\n  \"message\": \"Demande réceptionnée, validée et traitée par le workflow IA n8n.\",\n  \"timestamp\": \"{{ new Date().toISOString() }}\",\n  \"trace_id\": \"{{ $execution.id }}\"\n}",
        "options": {
          "responseCode": 200
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        540,
        100
      ],
      "id": "b38dc76e-57b1-4f9e-bc8e-2895690cd411",
      "name": "05b. Réponse Client (HTTP 200)"
    },
    {
      "parameters": {
        "content": "## Workflow Conférence Algeria 2.0 (17-21 nov 2026)\n\n**Intervenant :** Bouzid Mustapha (Mus) — AI Engineer chez Tassili AI\n**Sujet :** Automatiser un vrai processus métier avec n8n, Webhooks et APIs\n\n### Étapes du pipeline :\n1. **Webhook entrant** (capture HTTP POST synchrone/asynchrone)\n2. **Validation stricte** du schéma et intégrité des données\n3. **Appel API métier** avec gestion des retries et résilience\n4. **Qualification intelligente** par agent IA & LLM\n5. **Notification d'alerte** et accusé de réception instantané (200 OK)",
        "height": 420,
        "width": 520
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -540,
        -480
      ],
      "id": "fa9134ac-56f8-41cc-883a-d688005ebf39",
      "name": "Documentation Conférence"
    }
  ],
  "pinData": {},
  "connections": {
    "01. Webhook Entrant": {
      "main": [
        [
          {
            "node": "02. Validation Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "02. Validation Payload": {
      "main": [
        [
          {
            "node": "03. Appel API Métier (Enrichissement)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "03. Appel API Métier (Enrichissement)": {
      "main": [
        [
          {
            "node": "04. Classement IA & Qualification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Modèle LLM OpenAI / Tassili": {
      "ai_languageModel": [
        [
          {
            "node": "04. Classement IA & Qualification",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "04. Classement IA & Qualification": {
      "main": [
        [
          {
            "node": "05a. Notification Alerte (Slack / Webhook)",
            "type": "main",
            "index": 0
          },
          {
            "node": "05b. Réponse Client (HTTP 200)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c8b671a0-711c-4b53-8472-35dbfa01e699",
  "meta": {
    "instanceId": "algeria-2026-mus-n8n"
  },
  "id": "algeria-2026-workflow-n8n",
  "tags": [
    {
      "name": "Algeria 2.0"
    },
    {
      "name": "n8n"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "AI Agent"
    }
  ]
}
