{
  "name": "Tech My PME — Sync Ksaar to CRM Webhook",
  "nodes": [
    {
      "id": "6e4a2ea2-2316-4ac5-755a-b28ee7b6d58b",
      "name": "Webhook Ksaar",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        100,
        200
      ],
      "parameters": {
        "path": "ksaar-sync",
        "responseMode": "onReceived",
        "httpMethod": "POST"
      }
    },
    {
      "id": "bfd12049-102b-4439-6a6d-49489d1965a6",
      "name": "Transform Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        300,
        200
      ],
      "parameters": {
        "jsCode": "return {\n  contact_name: $input.first().body.name,\n  email: $input.first().body.email,\n  phone: $input.first().body.phone,\n  company: 'Agence Applications La Rochelle',\n  source: 'Ksaar',\n  sync_timestamp: new Date().toISOString()\n};"
      }
    },
    {
      "id": "662c533d-0bc2-4070-df2c-e4fe8b094784",
      "name": "Check Data",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        500,
        200
      ],
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            {
              "key": "contact_name",
              "condition": "notEmpty"
            },
            {
              "key": "email",
              "condition": "notEmpty"
            }
          ]
        }
      }
    },
    {
      "id": "c6f68653-21f6-4519-427e-88b516108904",
      "name": "Send to CRM",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        700,
        100
      ],
      "parameters": {
        "url": "https://crm.example.com/api/contacts",
        "method": "POST",
        "headerParameters": {
          "Content-Type": "application/json",
          "Authorization": "Bearer {{$env.CRM_API_KEY}}"
        },
        "bodyParameters": {
          "name": "={{ $node[\"Transform Data\"].json.contact_name }}",
          "email": "={{ $node[\"Transform Data\"].json.email }}",
          "phone": "={{ $node[\"Transform Data\"].json.phone }}",
          "company": "={{ $node[\"Transform Data\"].json.company }}",
          "source": "={{ $node[\"Transform Data\"].json.source }}"
        }
      }
    },
    {
      "id": "392d8f89-96a8-4385-b07d-b988f492018a",
      "name": "Log Error",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        700,
        300
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "error_status",
              "value": "Invalid data received"
            }
          ]
        }
      }
    }
  ],
  "connections": {
    "Webhook Ksaar": {
      "main": [
        [
          {
            "node": "Transform Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Data": {
      "main": [
        [
          {
            "node": "Check Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Data": {
      "main": [
        [
          {
            "node": "Send to CRM",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "versionId": "eacec0b9-4579-422d-b25c-c3d737273e81"
}