{
  "name": "Programador de Blogs con IA y Publicación Automática",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [1],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "id": "f6a7b8c9-0006-4a01-b001-ef1234567001",
      "name": "Schedule Trigger - Semanal",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [250, 300]
    },
    {
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "byName",
          "value": "Calendario de Contenidos"
        },
        "filters": {
          "column": "estado",
          "value": "Pendiente"
        },
        "options": {
          "range": "A:F"
        }
      },
      "id": "f6a7b8c9-0006-4a02-b002-ef1234567002",
      "name": "Google Sheets - Leer Tema Semanal",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [500, 300],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "message",
        "model": "gpt-4",
        "messages": {
          "values": [
            {
              "content": "=Eres un redactor experto en SEO para blogs en español latinoamericano. Genera un artículo de blog completo sobre el siguiente tema:\n\nTema: {{ $json.tema }}\nPalabras clave: {{ $json.palabras_clave }}\nPúblico objetivo: {{ $json.publico_objetivo }}\n\nEl artículo debe:\n- Tener entre 800-1200 palabras\n- Incluir un título atractivo con la palabra clave principal\n- Tener subtítulos H2 y H3\n- Incluir una introducción enganchadora\n- Usar un tono cercano y profesional\n- Incluir un llamado a la acción al final\n- Estar optimizado para SEO\n\nFormato: HTML listo para WordPress."
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxTokens": 2000
        }
      },
      "id": "f6a7b8c9-0006-4a03-b003-ef1234567003",
      "name": "OpenAI - Generar Artículo",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [750, 300],
      "credentials": {
        "openAiApi": {
          "id": "",
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "operation": "create",
        "title": "=Borrador: {{ $json.tema }} - {{ $now.format('yyyy-MM-dd') }}",
        "content": "={{ $json.message.content }}",
        "folderId": "",
        "options": {}
      },
      "id": "f6a7b8c9-0006-4a04-b004-ef1234567004",
      "name": "Google Docs - Crear Borrador",
      "type": "n8n-nodes-base.googleDocs",
      "typeVersion": 1,
      "position": [1000, 300],
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "",
          "name": "Google Docs account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "byName",
          "value": "Calendario de Contenidos"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "estado": "Borrador generado",
            "enlace_borrador": "={{ $json.documentId }}",
            "fecha_generado": "={{ $now.toISO() }}"
          }
        },
        "lookupColumn": "tema",
        "lookupValue": "={{ $json.tema }}",
        "options": {}
      },
      "id": "f6a7b8c9-0006-4a05-b005-ef1234567005",
      "name": "Google Sheets - Actualizar Estado",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [1250, 300],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://tu-sitio.com/wp-json/wp/v2/posts",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": \"{{ $json.titulo }}\",\n  \"content\": \"{{ $json.contenido_html }}\",\n  \"status\": \"draft\",\n  \"categories\": [1],\n  \"tags\": []\n}",
        "options": {}
      },
      "id": "f6a7b8c9-0006-4a06-b006-ef1234567006",
      "name": "HTTP Request - WordPress Draft",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [1500, 300]
    }
  ],
  "connections": {
    "Schedule Trigger - Semanal": {
      "main": [
        [
          {
            "node": "Google Sheets - Leer Tema Semanal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Leer Tema Semanal": {
      "main": [
        [
          {
            "node": "OpenAI - Generar Artículo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Generar Artículo": {
      "main": [
        [
          {
            "node": "Google Docs - Crear Borrador",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Docs - Crear Borrador": {
      "main": [
        [
          {
            "node": "Google Sheets - Actualizar Estado",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Actualizar Estado": {
      "main": [
        [
          {
            "node": "HTTP Request - WordPress Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "content-creation"
    },
    {
      "name": "blog"
    },
    {
      "name": "ia"
    }
  ]
}
