{
  "name": "WhatsApp Lead to CRM",
  "nodes": [
    {
      "id": "a1b2c3d4-0001-0001-0001-000000000001",
      "name": "Webhook WhatsApp",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "whatsapp-lead",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "a1b2c3d4-0001-0001-0001-000000000002",
      "name": "Mapear Campos Lead",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        300
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "fields": {
          "values": [
            {
              "name": "nome",
              "type": "stringValue",
              "value": "={{ $json.body.pushName || $json.body.from }}"
            },
            {
              "name": "telefone",
              "type": "stringValue",
              "value": "={{ $json.body.from.replace('@s.whatsapp.net', '') }}"
            },
            {
              "name": "mensagem",
              "type": "stringValue",
              "value": "={{ $json.body.message.conversation }}"
            },
            {
              "name": "origem",
              "type": "stringValue",
              "value": "WhatsApp"
            },
            {
              "name": "data_contato",
              "type": "stringValue",
              "value": "={{ new Date().toISOString() }}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "a1b2c3d4-0001-0001-0001-000000000003",
      "name": "Criar Lead no CRM",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.seucrm.com/v1/leads",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ name: $json.nome, phone: $json.telefone, message: $json.mensagem, source: $json.origem, created_at: $json.data_contato }) }}",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a1b2c3d4-0001-0001-0001-000000000004",
      "name": "Responder Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        900,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: true, lead_id: $json.id, message: 'Lead criado com sucesso' }) }}",
        "options": {
          "responseCode": 200
        }
      }
    }
  ],
  "connections": {
    "Webhook WhatsApp": {
      "main": [
        [
          {
            "node": "Mapear Campos Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mapear Campos Lead": {
      "main": [
        [
          {
            "node": "Criar Lead no CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Criar Lead no CRM": {
      "main": [
        [
          {
            "node": "Responder Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "id": "a1b2c3d4-0001-0001-0001-000000000000",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}