{
  "name": "Automatizaci\u00f3n Total Noticias",
  "nodes": [
    {
      "parameters": {
        "triggerTimes": [
          {
            "mode": "everyX",
            "value": 30,
            "unit": "minutes"
          }
        ]
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        200,
        200
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "sheetId": "13OsU4gREp4xZkNRq86UVBx7h2ZNFiClel-6lM3ZdnBk",
        "range": "Control!A2:Z",
        "options": {}
      },
      "name": "Leer Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        400,
        200
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json[\"estado\"] }}",
              "operation": "equal",
              "value2": "pendiente"
            }
          ]
        }
      },
      "name": "Filtrar Pendientes",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        600,
        200
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o",
        "messages": [
          {
            "role": "system",
            "content": "Eres un redactor profesional. Genera t\u00edtulo y cuerpo de noticia."
          },
          {
            "role": "user",
            "content": "Tema: {{$json[\"tema\"]}}. Escribe la noticia en Espa\u00f1ol, Ingl\u00e9s y Chino. Divide con etiquetas [ES], [EN], [ZH]."
          }
        ],
        "options": {}
      },
      "name": "Generar Noticia IA",
      "type": "n8n-nodes-base.openaiChat",
      "typeVersion": 1,
      "position": [
        800,
        200
      ],
      "credentials": {
        "openAIApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "const text = $json.choices[0].message.content;\nconst es = text.match(/\\[ES\\]([\\s\\S]*?)\\[EN\\]/)[1].trim();\nconst en = text.match(/\\[EN\\]([\\s\\S]*?)\\[ZH\\]/)[1].trim();\nconst zh = text.match(/\\[ZH\\]([\\s\\S]*)/)[1].trim();\nreturn [{json:{ES:es,EN:en,ZH:zh,id:$json.id}}];"
      },
      "name": "Separar Idiomas",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1000,
        200
      ]
    },
    {
      "parameters": {
        "conversionMode": "webhookResponse",
        "responseCode": 200,
        "responseData": "={{ { message: 'Noticia generada para ID '+$json.id } }}"
      },
      "name": "Respond Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1200,
        200
      ]
    }
  ],
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "Leer Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Leer Sheet": {
      "main": [
        [
          {
            "node": "Filtrar Pendientes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filtrar Pendientes": {
      "main": [
        [
          {
            "node": "Generar Noticia IA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generar Noticia IA": {
      "main": [
        [
          {
            "node": "Separar Idiomas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Separar Idiomas": {
      "main": [
        [
          {
            "node": "Respond Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true
}