{
  "name": "Seguimiento Inteligente de Propuestas Comerciales",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "GET",
        "path": "propuesta-vista",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "e5f6a7b8-0005-4a01-b001-ef1234567001",
      "name": "Webhook - Propuesta Abierta",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [250, 300]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "byName",
          "value": "Propuestas"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "estado": "Propuesta vista",
            "fecha_vista": "={{ $now.toISO() }}"
          }
        },
        "lookupColumn": "id_propuesta",
        "lookupValue": "={{ $json.query.propuesta_id }}",
        "options": {}
      },
      "id": "e5f6a7b8-0005-4a02-b002-ef1234567002",
      "name": "Google Sheets - Actualizar Estado",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [500, 300],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "amount": 24,
        "unit": "hours"
      },
      "id": "e5f6a7b8-0005-4a03-b003-ef1234567003",
      "name": "Wait - 24 Horas",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [750, 300]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.correo_prospecto }}",
        "subject": "=¿Pudiste revisar nuestra propuesta, {{ $json.nombre_prospecto }}?",
        "emailType": "html",
        "message": "=<p>Hola {{ $json.nombre_prospecto }},</p><p>Esperamos que hayas tenido la oportunidad de revisar nuestra propuesta. Queremos saber si tienes alguna duda o si podemos ajustar algo para que se adapte mejor a tus necesidades.</p><p>Estamos a tu disposición para una llamada rápida cuando lo prefieras.</p><p>Saludos cordiales,<br>{{ $json.vendedor }}</p>",
        "options": {}
      },
      "id": "e5f6a7b8-0005-4a04-b004-ef1234567004",
      "name": "Gmail - Seguimiento 24h",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [1000, 300],
      "credentials": {
        "gmailOAuth2": {
          "id": "",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "amount": 48,
        "unit": "hours"
      },
      "id": "e5f6a7b8-0005-4a05-b005-ef1234567005",
      "name": "Wait - 48 Horas Más",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [1250, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://graph.facebook.com/v17.0/FROM_PHONE_NUMBER_ID/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"messaging_product\": \"whatsapp\",\n  \"to\": \"{{ $json.telefono_prospecto }}\",\n  \"type\": \"text\",\n  \"text\": {\n    \"body\": \"Hola {{ $json.nombre_prospecto }}, soy {{ $json.vendedor }}. Te enviamos una propuesta hace unos días y queríamos saber si tienes alguna pregunta. Estamos para ayudarte. 😊\"\n  }\n}",
        "options": {}
      },
      "id": "e5f6a7b8-0005-4a06-b006-ef1234567006",
      "name": "WhatsApp - Seguimiento 72h",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [1500, 300]
    },
    {
      "parameters": {
        "amount": 5,
        "unit": "days"
      },
      "id": "e5f6a7b8-0005-4a07-b007-ef1234567007",
      "name": "Wait - 5 Días Total",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [1750, 300]
    },
    {
      "parameters": {
        "chatId": "",
        "text": "=🚨 *ESCALACIÓN - Propuesta sin respuesta*\n\nProspecto: {{ $json.nombre_prospecto }}\nEmpresa: {{ $json.empresa }}\nValor: ${{ $json.valor_propuesta }}\nDías sin respuesta: 5\n\n👉 Se requiere intervención personal del gerente.",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "e5f6a7b8-0005-4a08-b008-ef1234567008",
      "name": "Telegram - Escalar a Gerente",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [2000, 300],
      "credentials": {
        "telegramApi": {
          "id": "",
          "name": "Telegram account"
        }
      }
    }
  ],
  "connections": {
    "Webhook - Propuesta Abierta": {
      "main": [
        [
          {
            "node": "Google Sheets - Actualizar Estado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Actualizar Estado": {
      "main": [
        [
          {
            "node": "Wait - 24 Horas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait - 24 Horas": {
      "main": [
        [
          {
            "node": "Gmail - Seguimiento 24h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Seguimiento 24h": {
      "main": [
        [
          {
            "node": "Wait - 48 Horas Más",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait - 48 Horas Más": {
      "main": [
        [
          {
            "node": "WhatsApp - Seguimiento 72h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp - Seguimiento 72h": {
      "main": [
        [
          {
            "node": "Wait - 5 Días Total",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait - 5 Días Total": {
      "main": [
        [
          {
            "node": "Telegram - Escalar a Gerente",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "sales"
    },
    {
      "name": "seguimiento"
    },
    {
      "name": "propuestas"
    }
  ]
}
