{
  "name": "Vixo ERP — Sync new clients to Google Sheets + Slack notification",
  "description": "Every hour, searches for new clients created in Vixo in the last 60 minutes. Appends them to a Google Sheet (CRM tracker) and sends a Slack notification to the sales channel. Ideal for companies that want real-time visibility of new business in external tools.",
  "tags": [
    "mediavox",
    "vixo",
    "erp",
    "crm",
    "clients",
    "google-sheets",
    "slack",
    "latam"
  ],
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 1
            }
          ]
        }
      },
      "name": "Every Hour",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        240,
        300
      ],
      "id": "0d00815c-eb58-405f-ab5a-ef838e1f9903"
    },
    {
      "parameters": {
        "method": "clients.search",
        "params": "={{ JSON.stringify({ query: '', page: 1, pageSize: 50, sort: 'fechacreacion:desc' }) }}",
        "product": "vixo"
      },
      "name": "Search Recent Clients",
      "type": "n8n-nodes-mediavox.mediavox",
      "position": [
        460,
        300
      ],
      "credentials": {
        "mediavoxApi": {
          "name": "Mediavox Vixo"
        }
      },
      "notes": "Fetches clients sorted by creation date. Filter in Code node for last 60 min.",
      "typeVersion": 2,
      "id": "e458ceb5-4f65-4547-8714-647a020eceb9"
    },
    {
      "parameters": {
        "functionCode": "const cutoff = new Date(Date.now() - 60 * 60 * 1000);\nconst clients = ($input.first().json.data || []).filter(c => new Date(c.fechacreacion) > cutoff);\nif (clients.length === 0) return [];\nreturn clients.map(c => ({ json: { nombre: c.nombre, identificacion: c.identificacion, telefono: c.telefono || '', ciudad: c.ciudad || '', created: c.fechacreacion } }));"
      },
      "name": "Filter Last Hour",
      "type": "n8n-nodes-base.code",
      "position": [
        680,
        300
      ],
      "notes": "Only keeps clients created in the last 60 minutes. Stops flow if none.",
      "id": "e3bbc368-1284-467e-a63d-d2cd53167ae7"
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "YOUR_SHEET_ID",
        "range": "Clients!A:E",
        "columns": "nombre,identificacion,telefono,ciudad,created"
      },
      "name": "Append to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        900,
        250
      ],
      "notes": "Appends new clients to your Google Sheet. Create columns: Nombre, ID, Teléfono, Ciudad, Fecha.",
      "id": "1c29a901-6245-418c-8dcf-31a31c38c330"
    },
    {
      "parameters": {
        "channel": "#new-clients",
        "text": "=🆕 New client: *{{ $json.nombre }}* ({{ $json.ciudad }}) — {{ $json.identificacion }}"
      },
      "name": "Slack Notify",
      "type": "n8n-nodes-base.slack",
      "position": [
        900,
        380
      ],
      "notes": "Posts to your Slack sales channel. Requires Slack OAuth credentials.",
      "id": "b7ac35e4-f320-46ff-ae9d-7e20ee2e21f7"
    }
  ],
  "connections": {
    "Every Hour": {
      "main": [
        [
          {
            "node": "Search Recent Clients",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Recent Clients": {
      "main": [
        [
          {
            "node": "Filter Last Hour",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Last Hour": {
      "main": [
        [
          {
            "node": "Append to Sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack Notify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "active": false,
  "versionId": "a31b139d-739f-4bc0-8964-f44dc1caa404",
  "meta": {
    "templateCredsSetupCompleted": true
  }
}