{
  "nodes": [
    {
      "id": "5f5bd65b-479b-47e9-ae78-68dc6d169082",
      "name": "Format Drive Content",
      "type": "n8n-nodes-base.set",
      "position": [
        1120,
        720
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "97b7d7fa-1c7e-480c-8a01-52f63cab87bb",
              "name": "Title",
              "type": "string",
              "value": "={{ $('Google Sheets').item.json.Title }}"
            },
            {
              "id": "72e6c291-ddc2-46f1-960a-ac2036c80105",
              "name": "Copy",
              "type": "string",
              "value": "={{ $('Google Sheets').item.json.Copy }}"
            },
            {
              "id": "f50748ec-1027-458d-b263-1b9c132bd5d2",
              "name": "Status",
              "type": "string",
              "value": "={{ $('Google Sheets').item.json.Status }}"
            },
            {
              "id": "e1a2b3c4-d5e6-f7g8-h9i0-j1k2l3m4n5o6",
              "name": "video_url",
              "type": "string",
              "value": "={{ $('Google Sheets').item.json[\"Video Link\"] }}"
            },
            {
              "id": "f1g2h3i4-j5k6-l7m8-n9o0-p1q2r3s4t5u6",
              "name": "is_drive_file",
              "type": "boolean",
              "value": true
            },
            {
              "id": "row-number-drive",
              "name": "row_number",
              "type": "number",
              "value": "={{ $('Google Sheets').item.json.row_number }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2d6766c2-f247-465b-828f-0e9509eab52a",
      "name": "Social Media Account IDs",
      "type": "n8n-nodes-base.set",
      "position": [
        1312,
        720
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9eeb5af9-55a3-47ab-ab27-a87bbd91755c",
              "name": "facebook id (Page Id)",
              "type": "string",
              "value": ""
            },
            {
              "id": "7e3308c5-bf44-4b1e-8d63-8efaccd4f763",
              "name": "board id (Pinterest)",
              "type": "string",
              "value": ""
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "42b31498-cacd-4306-b50f-cdbe147a1f97",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1808,
        768
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Posteado",
            "row_number": "={{ $('Google Sheets').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Copy",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Copy",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Video Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Video Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Plataforma",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Plataforma",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Fecha.Hora",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Fecha.Hora",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "D\u00eda",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "D\u00eda",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZKbnD7GM6eAHKzyDY98cvz9jMUib1HLU7d9gohYkR3s/edit#gid=0",
          "cachedResultName": "Video"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1ZKbnD7GM6eAHKzyDY98cvz9jMUib1HLU7d9gohYkR3s"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "de1b0952-97a3-4548-97c6-429506562615",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        880,
        736
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "057ea0fb-bba4-4394-bcda-c66fe860467b",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json['Readable time'] }}",
              "rightValue": "={{ $('Google Sheets').item.json[\"Fecha.Hora\"] }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "58fd593a-55e3-43f3-8a83-2e5c30faf08a",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        624,
        784
      ],
      "parameters": {
        "jsCode": "// Obtener la fecha del Schedule Trigger\nconst triggerData = $('Schedule Trigger').first().json;\nconst originalDate = new Date(triggerData.scheduled || triggerData.timestamp || new Date());\n\n// Convertir a zona horaria de Santiago de Chile\nconst santiagoDate = new Date(originalDate.toLocaleString(\"en-US\", {timeZone: \"America/Santiago\"}));\n\n// Arrays para traducir al espa\u00f1ol\nconst meses = [\n  'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',\n  'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'\n];\n\nconst diasSemana = [\n  'Domingo', 'Lunes', 'Martes', 'Mi\u00e9rcoles', 'Jueves', 'Viernes', 'S\u00e1bado'\n];\n\n// Extraer componentes de la fecha\nconst dia = santiagoDate.getDate();\nconst mes = meses[santiagoDate.getMonth()];\nlet horas = santiagoDate.getHours();\nconst ampm = horas >= 12 ? 'pm' : 'am';\n\n// Convertir a formato de 12 horas\nhoras = horas % 12;\nhoras = horas ? horas : 12; // la hora '0' debe ser '12'\n\nconst diaSemana = diasSemana[santiagoDate.getDay()];\n\n// Crear el formato deseado: \"22 de Junio a las 9 am\"\nconst readableTime = `${dia} de ${mes} a las ${horas} ${ampm}`;\n\nreturn [{\n  json: {\n    \"Readable time\": readableTime,\n    \"Day of week\": diaSemana\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "67e4c47c-6c50-4db7-980a-9f9d90c02171",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        64,
        704
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            },
            {
              "triggerAtHour": 21
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1d12a289-2338-4c17-ae47-03eb3e3029f0",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        368,
        768
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": true
        },
        "filtersUI": {
          "values": [
            {
              "lookupValue": "Listo para postear ",
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZKbnD7GM6eAHKzyDY98cvz9jMUib1HLU7d9gohYkR3s/edit#gid=0",
          "cachedResultName": "Video"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1ZKbnD7GM6eAHKzyDY98cvz9jMUib1HLU7d9gohYkR3s"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "b1fa7e04-f27a-4ad4-b1ea-705e5f4e0c57",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2160,
        736
      ],
      "parameters": {
        "text": "=**\ud83d\udcf9 Resultados de publicaci\u00f3n:**\n\n\ud83c\udfaf **Plataforma:** {{ $('Upload a video').item.json.results[0].platform }}\n\ud83d\udd17 **URL:** {{ $('Upload a video').item.json.results[0].post_url }}\n\u2705 **\u00c9xito:** {{ $('Upload a video').item.json.results[0].success }}\n\n---\n\n\ud83c\udfaf **Plataforma:** {{ $('Upload a video').item.json.results[1].platform }}\n\ud83d\udd17 **URL:** {{ $('Upload a video').item.json.results[1].post_url }}\n\u2705 **\u00c9xito:** {{ $('Upload a video').item.json.results[1].success }}\n\n---\n\n\ud83c\udfaf **Plataforma:** {{ $('Upload a video').item.json.results[2].platform }}\n\ud83d\udd17 **URL:** {{ $('Upload a video').item.json.results[2].post_url }}\n\u2705 **\u00c9xito:** {{ $('Upload a video').item.json.results[2].success }}",
        "chatId": "Your Chat Id ",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d8a3d499-d080-4b05-a72f-21b335807127",
      "name": "Upload a video",
      "type": "n8n-nodes-upload-post.uploadPost",
      "position": [
        1520,
        720
      ],
      "parameters": {
        "user": "JoseAI",
        "title": "={{ $('Social Media Account IDs').item.json.Title }}\n\n{{ $('Social Media Account IDs').item.json.Copy }}",
        "video": "={{ $('Social Media Account IDs').item.json.video_url }}",
        "platform": [
          "instagram",
          "linkedin",
          "tiktok"
        ],
        "operation": "uploadVideo"
      },
      "credentials": {
        "uploadPostApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e7b9ce97-22ad-4d42-a900-355fe8e88a8c",
      "name": "Sticky Note 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        416
      ],
      "parameters": {
        "width": 280,
        "height": 416,
        "content": "## \u23f0 Automatic Trigger\n\n**Runs twice daily:**\n- 9:00 AM\n- 9:00 PM\n\nTimezone: America/Santiago (Chile)\n\nYou can modify these times or add more trigger hours in the Schedule Trigger configuration."
      },
      "typeVersion": 1
    },
    {
      "id": "5238bc52-83b7-46cb-9bc6-99ce206f3d76",
      "name": "Sticky Note 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        384
      ],
      "parameters": {
        "width": 220,
        "height": 544,
        "content": "## \ud83d\udcca Fetch Scheduled Posts\n\n**Reads Google Sheets** to find posts ready to publish.\n\n**Filter criteria:**\n- Status = \"Listo para postear\"\n- Returns only the first match\n\n**Required columns:**\n- Title, Copy, Video Link\n- Status, Fecha.Hora\n- row_number (for tracking)"
      },
      "typeVersion": 1
    },
    {
      "id": "9a9c2db6-b679-4692-9575-e1f119ba11ae",
      "name": "Sticky Note 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        304
      ],
      "parameters": {
        "width": 236,
        "height": 672,
        "content": "## \ud83d\udd50 Time Formatter\n\n**Converts trigger timestamp** to Spanish readable format.\n\n**Output example:**\n\"16 de Octubre a las 9 am\"\n\n**Includes:**\n- Day of week (Spanish)\n- Month name (Spanish)\n- 12-hour format with AM/PM\n- You can change the code with Claude to english and that is it.\n\nThis format must match exactly with the \"Fecha.Hora\" column in Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "eefaa4a9-1e27-4420-94d0-05d5d84ffaca",
      "name": "Sticky Note 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        240
      ],
      "parameters": {
        "width": 188,
        "height": 624,
        "content": "## \u2705 Time Validation\n\n**Checks if it's time to post** by comparing:\n\n- Current formatted time (from Code node)\n- Scheduled time in Google Sheets\n\n**If match:**\n\u2705 Continues to posting workflow\n\n**If no match:**\n\u274c Workflow stops here\n\nThis prevents posting at wrong times."
      },
      "typeVersion": 1
    },
    {
      "id": "a7cb50a7-4b55-4e95-af31-289703097eb2",
      "name": "Sticky Note 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        256
      ],
      "parameters": {
        "width": 204,
        "height": 624,
        "content": "## \ud83d\udcdd Data Preparation\n\n**Extracts and organizes** post data:\n\n- Title (post title)\n- Copy (caption/description)\n- Status (current status)\n- video_url (Google Drive link)\n- is_drive_file (set to true)\n- row_number (for tracking)\n\nCleans and formats data for upload API."
      },
      "typeVersion": 1
    },
    {
      "id": "df4652fc-c2a2-4857-8a12-64a9394eb3bf",
      "name": "Sticky Note 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        432
      ],
      "parameters": {
        "width": 188,
        "height": 464,
        "content": "## \ud83c\udd94 Account Configuration\n\n**Prepares social media account identifiers.**\n\nYou can specify different account IDs for each platform:\n- Facebook ID\n- Pinterest Board ID\n- etc."
      },
      "typeVersion": 1
    },
    {
      "id": "47ed06b8-1c25-43e1-9c83-a04da050c2d3",
      "name": "Sticky Note 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1472,
        272
      ],
      "parameters": {
        "width": 252,
        "height": 608,
        "content": "## \ud83c\udfac Multi-Platform Upload\n\n**Posts video simultaneously** to:\n- Instagram\n- LinkedIn\n- TikTok\n\n(You can add more Platforms)\n\n**Uses UploadPost API**\n\n**Content includes:**\n- Title + Copy as caption\n- Video from Google Drive URL\n\n**Credentials required:**\nUploadPost API account with connected social media profiles."
      },
      "typeVersion": 1
    },
    {
      "id": "6e65eca8-544a-425a-be1f-3dbde7ac67d1",
      "name": "Sticky Note 8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        368
      ],
      "parameters": {
        "width": 300,
        "height": 560,
        "content": "## \ud83d\udcca Update Sheet Status\n\n**Marks post as published** in Google Sheets.\n\n**Changes:**\n- Status: \"Listo para postear\" \u2192 \"Posteado\"\n\n**Prevents:**\n- Duplicate posts\n- Re-processing same content\n\n**Matches by:** row_number column to ensure accurate update."
      },
      "typeVersion": 1
    },
    {
      "id": "6c0d0d18-73b6-4e52-814c-b394708410c9",
      "name": "Sticky Note 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2064,
        288
      ],
      "parameters": {
        "width": 300,
        "height": 624,
        "content": "## \ud83d\udcf1 Telegram Notification\n\n**Sends detailed success report** with:\n\n**For each platform:**\n- Platform name\n- Post URL (clickable link)\n- Success status\n\n**Includes results for:**\n- Instagram\n- LinkedIn\n- TikTok\n\nYou'll receive this message immediately after posting completes."
      },
      "typeVersion": 1
    },
    {
      "id": "98854a34-69db-46da-9714-90f85110eb9c",
      "name": "Sticky Note Main",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 2432,
        "height": 1248,
        "content": "# Automated Social Media Video Posting\n\n## \ud83c\udfaf Complete workflow for scheduling and posting videos to Instagram, LinkedIn, and TikTok\n\n### Key Features:\n\u2705 Automated scheduling (twice daily)\n\u2705 Multi-platform posting\n\u2705 Status tracking in Google Sheets\n\u2705 Telegram notifications\n\u2705 Duplicate prevention"
      },
      "typeVersion": 1
    },
    {
      "id": "642ec7b5-a698-485e-a12e-c5add5bbe1f9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2064,
        1024
      ],
      "parameters": {
        "height": 192,
        "content": "## Google Sheets \n\nhttps://docs.google.com/spreadsheets/d/1ZKbnD7GM6eAHKzyDY98cvz9jMUib1HLU7d9gohYkR3s/edit?usp=sharing"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Format Drive Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload a video": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Drive Content": {
      "main": [
        [
          {
            "node": "Social Media Account IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Social Media Account IDs": {
      "main": [
        [
          {
            "node": "Upload a video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}