AutomationFlowsSocial Media › Generación_publicaciones (workflow 3) Webhook All Platforms Decrypt Publicar Git

Generación_publicaciones (workflow 3) Webhook All Platforms Decrypt Publicar Git

generación_publicaciones (workflow 3) webhook all platforms decrypt publicar git. Uses dataTable, linkedIn, httpRequest. Webhook trigger; 50 nodes.

Webhook trigger★★★★★ complexity50 nodesData TableLinkedInHTTP Request
Social Media Trigger: Webhook Nodes: 50 Complexity: ★★★★★ Added:

This workflow follows the Datatable → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "generaci\u00f3n_publicaciones (workflow 3) webhook all platforms decrypt publicar git",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "publish-social-content",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -768,
        32
      ],
      "id": "8b966662-94a9-4225-bb0e-886a520373f5",
      "name": "Webhook"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        1808,
        -192
      ],
      "id": "efd2dc9c-73c7-4682-ab9f-8ed832971f8e",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": "content_sessions",
          "cachedResultUrl": ""
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "session_id",
              "keyValue": "={{$('decrypt credentials').first().json.session_id }}"
            }
          ]
        },
        "limit": 1
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        64,
        32
      ],
      "id": "8b90a42e-41c7-4ccd-b605-3ffad0abf4f8",
      "name": "Get row(s)"
    },
    {
      "parameters": {
        "jsCode": "const inputItems = $input.all();\n\nif (!inputItems.length) {\n  return [\n    {\n      json: {\n        error: true,\n        message: \"No se han recibido items\"\n      }\n    }\n  ];\n}\n\nconst output = [];\n\nconst webhookRaw = $(\"Webhook\").first().json || {};\nconst webhookData = webhookRaw.body || webhookRaw;\n\nconst decryptRaw = $(\"decrypt credentials\").first().json || {};\nconst decryptData = decryptRaw.body || decryptRaw;\n\nfor (const item of inputItems) {\n\n  const row = item.json || {};\n\n  const credentialsRaw = row.credentials || \"{}\";\n\n  let credentials = {};\n\n  try {\n    credentials =\n      typeof credentialsRaw === \"string\"\n        ? JSON.parse(credentialsRaw)\n        : credentialsRaw;\n  } catch (e) {\n    credentials = {};\n  }\n\n  const body = {\n    ...row,\n    ...webhookData,\n    ...decryptData,\n    ...credentials\n  };\n\n  const allowRepublish =\n    body.allow_republish === true ||\n    body.allow_republish === \"true\";\n\n  const version = Number(\n    body.version ||\n    body.selected_version ||\n    1\n  );\n\n  let platforms = [];\n\n  const platformsInput =\n    body.platforms ||\n    body.selected_platforms ||\n    body.publish_platforms ||\n    {};\n\n  // Objeto tipo { web:true, linkedin:true }\n  if (\n    platformsInput &&\n    typeof platformsInput === \"object\" &&\n    !Array.isArray(platformsInput)\n  ) {\n\n    if (\n      platformsInput.web === true ||\n      platformsInput.web === \"true\" ||\n      platformsInput.wordpress === true ||\n      platformsInput.wordpress === \"true\"\n    ) {\n      platforms.push(\"wordpress\");\n    }\n\n    if (\n      platformsInput.linkedin === true ||\n      platformsInput.linkedin === \"true\"\n    ) {\n      platforms.push(\"linkedin\");\n    }\n\n    if (\n      platformsInput.facebook === true ||\n      platformsInput.facebook === \"true\"\n    ) {\n      platforms.push(\"facebook\");\n    }\n\n    if (\n      platformsInput.instagram === true ||\n      platformsInput.instagram === \"true\"\n    ) {\n      platforms.push(\"instagram\");\n    }\n\n    if (\n      platformsInput.twitter === true ||\n      platformsInput.twitter === \"true\" ||\n      platformsInput.x === true ||\n      platformsInput.x === \"true\"\n    ) {\n      platforms.push(\"x\");\n    }\n  }\n\n  // Array\n  if (Array.isArray(platformsInput)) {\n    platforms.push(...platformsInput);\n  }\n\n  // String tipo \"wordpress,linkedin\"\n  if (\n    typeof platformsInput === \"string\" &&\n    platformsInput.trim()\n  ) {\n    platforms.push(\n      ...platformsInput\n        .split(\",\")\n        .map(p => p.trim())\n        .filter(Boolean)\n    );\n  }\n\n  const toggleMap = {\n    wordpress: body.wordpress || body.web,\n    linkedin: body.linkedin,\n    facebook: body.facebook,\n    instagram: body.instagram,\n    x: body.x || body.twitter\n  };\n\n  for (const [platform, value] of Object.entries(toggleMap)) {\n    if (\n      value === true ||\n      value === \"true\" ||\n      value === 1 ||\n      value === \"1\"\n    ) {\n      platforms.push(platform);\n    }\n  }\n\n  platforms = [\n    ...new Set(\n      platforms\n        .map(p => String(p).toLowerCase().trim())\n        .map(p => p === \"web\" ? \"wordpress\" : p)\n        .map(p => p === \"twitter\" ? \"x\" : p)\n        .filter(p =>\n          [\n            \"wordpress\",\n            \"linkedin\",\n            \"facebook\",\n            \"instagram\",\n            \"x\"\n          ].includes(p)\n        )\n    )\n  ];\n\n  const wpUser = String(\n    body.wordpress_user || \"\"\n  ).trim();\n\n  const wpPassword = String(\n    body.wordpress_password || \"\"\n  ).replace(/\\s+/g, \"\");\n\n  const wpBasicAuth =\n    \"Basic \" +\n    Buffer.from(\n      `${wpUser}:${wpPassword}`\n    ).toString(\"base64\");\n\n  if (!platforms.length) {\n\n    output.push({\n      json: {\n        ...body,\n\n        wordpress_user: wpUser,\n        wordpress_password: wpPassword,\n        wp_basic_auth: wpBasicAuth,\n\n        has_platforms: false,\n        status: \"no_platform_selected\",\n        message: \"No hay plataformas seleccionadas\",\n\n        debug_platformsInput: platformsInput,\n        debug_webhook_platforms: webhookData.platforms,\n        debug_decrypt_platforms: decryptData.platforms,\n        debug_keys: Object.keys(body)\n      }\n    });\n\n    continue;\n  }\n\n  // MUY IMPORTANTE\n  delete body.platform;\n\n  for (const currentPlatform of platforms) {\n\n    const publishedIdField = {\n      wordpress: \"wp_post_id\",\n      linkedin: \"linkedin_post_id\",\n      facebook: \"facebook_post_id\",\n      instagram: \"instagram_post_id\",\n      x: \"x_post_id\"\n    }[currentPlatform];\n\n    const publishedUrlField = {\n      wordpress: \"wp_post_url\",\n      linkedin: \"linkedin_post_url\",\n      facebook: \"facebook_post_url\",\n      instagram: \"instagram_post_url\",\n      x: \"x_post_url\"\n    }[currentPlatform];\n\n    const alreadyPublished =\n      Boolean(row[publishedIdField]);\n\n    output.push({\n      json: {\n\n        ...body,\n\n        wordpress_user: wpUser,\n        wordpress_password: wpPassword,\n        wp_basic_auth: wpBasicAuth,\n\n        has_platforms: true,\n\n        allow_republish: allowRepublish,\n        selected_version: version,\n\n        already_published: alreadyPublished,\n\n        published_id_field: publishedIdField,\n        published_url_field: publishedUrlField,\n\n        published_id:\n          row[publishedIdField] || \"\",\n\n        published_url:\n          row[publishedUrlField] || \"\",\n\n        should_publish: true,\n\n        // FORZADO AL FINAL\n        platform: currentPlatform\n      }\n    });\n  }\n}\n\nreturn output;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        256,
        32
      ],
      "id": "8592ada9-6a1c-4d72-91b4-576b201fd411",
      "name": "Preparar publicaci\u00f3n multicanal",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "86c2b219-55b2-4424-b4c1-5670ca4bc991",
              "leftValue": "={{ $json.has_platforms }}",
              "rightValue": "reviewed",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        448,
        32
      ],
      "id": "304351eb-8e37-49cf-aef4-4cd12e35c243",
      "name": "\u00bfPlataformas seleccionadas?"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        736,
        16
      ],
      "id": "103be4d5-e3cd-4e73-8086-37e45e0d9375",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.platform === \"wordpress\" }}",
                    "rightValue": "wordpress",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "id": "6d3b3ef3-6804-436d-b421-2730dc1c5021"
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "de6b48bd-f02f-4a48-993f-9a56c1ed8eaa",
                    "leftValue": "={{ $json.platform === \"linkedin\" }}",
                    "rightValue": "linkedin",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "5b4fc943-ae0d-4c04-aeab-c017cecf5b13",
                    "leftValue": "={{ $json.platform === \"x\" }}",
                    "rightValue": "x",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "f479b7a3-c2d5-49a8-a92d-addfb1248e93",
                    "leftValue": "={{ $json.platform === \"instagram\" }}",
                    "rightValue": "instagram",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "0e1d9730-fe37-46f2-b904-b748bfceb08c",
                    "leftValue": "={{ $json.platform === \"facebook\" }}",
                    "rightValue": "facebook",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "e8b94ad0-9d47-4ab8-9838-9197c8702c0b",
                    "leftValue": "",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        864,
        592
      ],
      "id": "4ff9327e-d598-4c32-a71d-0e9505cb429c",
      "name": "Controlador plataformas seleccionadas"
    },
    {
      "parameters": {
        "jsCode": "const crypto = require(\"crypto\");\n\nconst input = $json || {};\n\nlet body = input.body || input;\n\nif (!body.payload || !body.iv || !body.tag || !body.timestamp || !body.signature) {\n  const webhookData = $(\"Webhook\").first().json || {};\n  body = webhookData.body || webhookData;\n}\n\nconst encryptionKeyRaw = $env.WEBHOOK_ENCRYPTION_KEY;\nconst hmacSecret = $env.WEBHOOK_HMAC_SECRET;\n\nif (!encryptionKeyRaw) {\n  throw new Error(\"Falta WEBHOOK_ENCRYPTION_KEY\");\n}\n\nif (!hmacSecret) {\n  throw new Error(\"Falta WEBHOOK_HMAC_SECRET\");\n}\n\nif (!body.payload || !body.iv || !body.tag || !body.timestamp || !body.signature) {\n  throw new Error(\n    `Faltan campos cifrados obligatorios. Campos disponibles: ${Object.keys(body).join(\", \")}`\n  );\n}\n\nconst encryptionKey = Buffer.from(encryptionKeyRaw, \"base64\");\n\nif (encryptionKey.length !== 32) {\n  throw new Error(\"WEBHOOK_ENCRYPTION_KEY debe tener 32 bytes tras decodificar Base64\");\n}\n\nconst now = Math.floor(Date.now() / 1000);\nconst timestamp = Number(body.timestamp);\n\nif (!timestamp || Math.abs(now - timestamp) > 300) {\n  throw new Error(\"Petici\u00f3n expirada\");\n}\n\nconst dataToSign = `${body.payload}.${body.iv}.${body.tag}.${body.timestamp}`;\n\nconst calculatedSignature = crypto\n  .createHmac(\"sha256\", hmacSecret)\n  .update(dataToSign)\n  .digest(\"hex\");\n\nconst receivedSignature = String(body.signature);\n\nif (\n  calculatedSignature.length !== receivedSignature.length ||\n  !crypto.timingSafeEqual(\n    Buffer.from(calculatedSignature, \"hex\"),\n    Buffer.from(receivedSignature, \"hex\")\n  )\n) {\n  throw new Error(\"Firma HMAC inv\u00e1lida\");\n}\n\nconst decipher = crypto.createDecipheriv(\n  \"aes-256-gcm\",\n  encryptionKey,\n  Buffer.from(body.iv, \"base64\")\n);\n\ndecipher.setAuthTag(Buffer.from(body.tag, \"base64\"));\n\nconst decrypted = Buffer.concat([\n  decipher.update(Buffer.from(body.payload, \"base64\")),\n  decipher.final(),\n]);\n\nconst parsed = JSON.parse(decrypted.toString(\"utf8\"));\n\nconst setData = { ...input };\n\n// Limpiar campos de publicaci\u00f3n que no deben arrastrarse\ndelete setData.platform;\ndelete setData.published_id_field;\ndelete setData.published_url_field;\ndelete setData.published_id;\ndelete setData.published_url;\ndelete setData.should_publish;\ndelete setData.already_published;\ndelete setData.has_platforms;\n\nconst wordpressUser = parsed.wordpress_user || \"\";\nconst wordpressPassword = String(parsed.wordpress_password || \"\").replace(/\\s+/g, \"\");\n\nconst wpAuthHeader =\n  wordpressUser && wordpressPassword\n    ? \"Basic \" + Buffer.from(`${wordpressUser}:${wordpressPassword}`).toString(\"base64\")\n    : null;\n\nreturn [\n  {\n    json: {\n      ...setData,\n\n      session_id: parsed.session_id || setData.session_id || null,\n\n      wordpress_urlapi: parsed.wordpress_urlapi || null,\n      wordpress_user: wordpressUser || null,\n      wordpress_password: wordpressPassword || null,\n      wp_auth_header: wpAuthHeader,\n\n      linkedin_urloauthredirect: parsed.linkedin_urloauthredirect || null,\n      linkedin_clientid: parsed.linkedin_clientid || null,\n      linkedin_clientsecret: parsed.linkedin_clientsecret || null,\n\n      x_urloauthredirect: parsed.x_urloauthredirect || null,\n      x_clientid: parsed.x_clientid || null,\n      x_clientsecret: parsed.x_clientsecret || null\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -352,
        0
      ],
      "id": "9a6c4058-b114-4282-8f1b-718262c5a5bc",
      "name": "decrypt credentials"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": "content_sessions",
          "cachedResultUrl": ""
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "session_id",
              "keyValue": "={{ $('id').first().json.session_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "credentials": "={{ JSON.stringify({\n  wordpress_urlapi: $('decrypt credentials').first().json.wordpress_urlapi,\n  wordpress_user: $('decrypt credentials').first().json.wordpress_user,\n  wordpress_password: $('decrypt credentials').first().json.wordpress_password,\n\n  linkedin_urloauthredirect: $('decrypt credentials').first().json.linkedin_urloauthredirect,\n  linkedin_clientid: $('decrypt credentials').first().json.linkedin_clientid,\n  linkedin_clientsecret: $('decrypt credentials').first().json.linkedin_clientsecret,\n\n  x_urloauthredirect: $('decrypt credentials').first().json.x_urloauthredirect,\n  x_clientid: $('decrypt credentials').first().json.x_clientid,\n  x_clientsecret: $('decrypt credentials').first().json.x_clientsecret\n}) }}",
            "session_id": "={{ $('decrypt credentials').first().json.session_id }}",
            "status": "={{ $('Webhook').item.json.body.status }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "session_id",
              "displayName": "session_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "title_current",
              "displayName": "title_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "content_current",
              "displayName": "content_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "excerpt_current",
              "displayName": "excerpt_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "meta_current",
              "displayName": "meta_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "category_current",
              "displayName": "category_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "image_current",
              "displayName": "image_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tags_current",
              "displayName": "tags_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "text_versions",
              "displayName": "text_versions",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "image_versions",
              "displayName": "image_versions",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "updated_at",
              "displayName": "updated_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "review_action",
              "displayName": "review_action",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "wp_post_id",
              "displayName": "wp_post_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "wp_post_url",
              "displayName": "wp_post_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "featured_media_id",
              "displayName": "featured_media_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "featured_media",
              "displayName": "featured_media",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "keyword_current",
              "displayName": "keyword_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "image_prompt_current",
              "displayName": "image_prompt_current",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "objetivo",
              "displayName": "objetivo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "publico_objetivo",
              "displayName": "publico_objetivo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "nivel_tecnico",
              "displayName": "nivel_tecnico",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tono",
              "displayName": "tono",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "formato_texto",
              "displayName": "formato_texto",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "publication_type",
              "displayName": "publication_type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "visual_style",
              "displayName": "visual_style",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "image_format",
              "displayName": "image_format",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "visual_reference",
              "displayName": "visual_reference",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "storytelling_format",
              "displayName": "storytelling_format",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "viral_format",
              "displayName": "viral_format",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "professional_linkedin_format",
              "displayName": "professional_linkedin_format",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "cta",
              "displayName": "cta",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "custom_cta",
              "displayName": "custom_cta",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "cta_intensity",
              "displayName": "cta_intensity",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "generate_image",
              "displayName": "generate_image",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "idioma",
              "displayName": "idioma",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tamano",
              "displayName": "tamano",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "custom_category",
              "displayName": "custom_category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "descripcion",
              "displayName": "descripcion",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "title_wordpress",
              "displayName": "title_wordpress",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "content_wordpress",
              "displayName": "content_wordpress",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tags_wordpress",
              "displayName": "tags_wordpress",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "title_linkedin",
              "displayName": "title_linkedin",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "content_linkedin",
              "displayName": "content_linkedin",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tags_linkedin",
              "displayName": "tags_linkedin",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "title_x",
              "displayName": "title_x",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "content_x",
              "displayName": "content_x",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tags_x",
              "displayName": "tags_x",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "title_instagram",
              "displayName": "title_instagram",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "content_instagram",
              "displayName": "content_instagram",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tags_instagram",
              "displayName": "tags_instagram",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "title_facebook",
              "displayName": "title_facebook",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "content_facebook",
              "displayName": "content_facebook",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "tags_facebook",
              "displayName": "tags_facebook",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "linkedin_post_id",
              "displayName": "linkedin_post_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "facebook_post_id",
              "displayName": "facebook_post_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "instagram_post_id",
              "displayName": "instagram_post_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "x_post_id",
              "displayName": "x_post_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "linkedin_post_url",
              "displayName": "linkedin_post_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "facebook_post_url",
              "displayName": "facebook_post_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "instagram_post_url",
              "displayName": "instagram_post_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "x_post_url",
              "displayName": "x_post_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        -144,
        0
      ],
      "id": "4f7742c7-6d1a-4f88-b7f9-0fa0a44ad8e7",
      "name": "Update row(s)1",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "8679979d-2c78-4ed3-859d-47cd018bfc3a",
              "name": "session_id",
              "value": "={{ $json.body.session_id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -576,
        16
      ],
      "id": "2cfc4e6b-9d19-4d34-9f92-02709eac432b",
      "name": "id"
    },
    {
      "parameters": {
        "jsCode": "const previous = $(\"Preparador Linkedin\").first().json;\nconst response = $(\"LinkedIn Posts\").first().json;\n\nconst headers = response.headers || {};\n\nconst linkedinPostId =\n  headers[\"x-restli-id\"] ||\n  headers[\"X-RestLi-Id\"] ||\n  null;\n\nconst linkedinPostUrl = linkedinPostId\n  ? `https://www.linkedin.com/feed/update/${linkedinPostId}/`\n  : null;\n\nreturn [\n  {\n    json: {\n      ...previous,\n      linkedin_success: true,\n      linkedin_status: \"published\",\n      linkedin_post_id: linkedinPostId,\n      linkedin_post_url: linkedinPostUrl,\n      linkedin_api_status_code: response.statusCode || null,\n      linkedin_published_at: new Date().toISOString(),\n      linkedin_message: \"Publicado correctamente en LinkedIn\"\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2208,
        80
      ],
      "id": "e7f0e22f-a064-430b-8513-8280a94e4cb4",
      "name": "linkedin respuesta1"
    },
    {
      "parameters": {
        "jsCode": "const previous = $(\"Preparador Linkedin\").first().json;\nconst response = $(\"LinkedIn post\").first().json;\n\nconst linkedinPostId =\n  response.urn ||\n  response.headers?.[\"x-restli-id\"] ||\n  response.headers?.[\"X-RestLi-Id\"] ||\n  null;\n\nconst linkedinPostUrl = linkedinPostId\n  ? `https://www.linkedin.com/feed/update/${linkedinPostId}/`\n  : null;\n\nreturn [\n  {\n    json: {\n      ...previous,\n      linkedin_success: true,\n      linkedin_status: \"published\",\n      linkedin_post_id: linkedinPostId,\n      linkedin_post_url: linkedinPostUrl,\n      linkedin_api_status_code: response.statusCode || null,\n      linkedin_published_at: new Date().toISOString(),\n      linkedin_message: \"Publicado correctamente en LinkedIn\"\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2608,
        416
      ],
      "id": "c41c6856-5336-4d77-91fe-701bca66209c",
      "name": "linkedin respuesta"
    },
    {
      "parameters": {
        "person": "",
        "text": "={{ $(\"Preparador Linkedin\").first().json.linkedin_body.commentary }}",
        "shareMediaCategory": "IMAGE",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.linkedIn",
      "typeVersion": 1,
      "position": [
        2256,
        320
      ],
      "id": "ce5f3b72-61b1-4e78-be45-2714c46be9f3",
      "name": "LinkedIn post",
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Auxiliar dinamic modes\nusing httprequest for LinkedIn post (with images)",
        "height": 352,
        "width": 1296
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1088,
        -32
      ],
      "id": "9b094912-7d55-4fa7-8309-c403d1c6e59e",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.linkedin.com/rest/posts",
        "sendHeaders": true,
        "specifyHeaders": "json",
        "jsonHeaders": "{\n  \"Authorization\": \"Bearer {{$json.linkedin_access_token}}\",\n  \"X-Restli-Protocol-Version\": \"2.0.0\",\n  \"LinkedIn-Version\": \"202604\",\n  \"Content-Type\": \"application/json\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{\n{\n  author: $(\"Preparador Linkedin\").first().json.linkedin_author,\n  commentary: $(\"Preparador Linkedin\").first().json.linkedin_body.commentary,\n  visibility: \"PUBLIC\",\n  distribution: {\n    feedDistribution: \"MAIN_FEED\",\n    targetEntities: [],\n    thirdPartyDistributionChannels: []\n  },\n  content: {\n    media: {\n      id: $(\"linkedin image upload\").first().json.value.image,\n      altText: $(\"Preparador Linkedin\").first().json.title_linkedin || $(\"Preparador Linkedin\").first().json.title_current || \"Imagen del post\"\n    }\n  },\n  lifecycleState: \"PUBLISHED\",\n  isReshareDisabledByAuthor: false\n}\n}}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2016,
        80
      ],
      "id": "841382bd-6861-4b2b-a862-5a7d799189f3",
      "name": "LinkedIn Posts",
      "alwaysOutputData": false,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.linkedin.com/rest/images?action=initializeUpload",
        "sendHeaders": true,
        "specifyHeaders": "json",
        "jsonHeaders": "{\n  \"X-Restli-Protocol-Version\": \"2.0.0\",\n  \"LinkedIn-Version\": \"202604\",\n  \"Content-Type\": \"application/json\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{  initializeUploadRequest: {    owner: $(\"Preparador Linkedin\").first().json.linkedin_author  }}}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1376,
        368
      ],
      "id": "dec6ed70-37fc-4490-af82-80dcf0279e1e",
      "name": "linkedin image upload"
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "={{ $('linkedin image upload').first().json.value.uploadUrl }}",
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "=data",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1840,
        80
      ],
      "id": "0449d4f5-f4ff-4abe-977b-9080371cb352",
      "name": "linkedin upload binary"
    },
    {
      "parameters": {
        "content": "## WP GET me CHECK\nIn case of error, use this to identify the cause",
        "height": 272,
        "width": 400
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -464,
        352
      ],
      "id": "a48bc60d-3437-49d7-a607-760de6e1e24b",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "url": "={{ $('Preparador Linkedin').first().json.image_current }}",
        "sendHeaders": true,
        "specifyHeaders": "json",
        "jsonHeaders": "{\n  \"User-Agent\": \"Mozilla/5.0\",\n  \"Accept\": \"image/jpeg,image/png,image/webp,*/*\"\n}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1680,
        80
      ],
      "id": "7ccd4216-5e60-40cb-969d-b66988ad1576",
      "name": "download image to linkedIn"
    },
    {
      "parameters": {
        "url": "={{ $('Preparador X/Twitter').first().json.image_source_url || $('Preparador X/Twitter').first().json.image_current }}\n",
        "sendHeaders": true,
        "specifyHeaders": "json",
        "jsonHeaders": "{\n  \"User-Agent\": \"Mozilla/5.0\",\n  \"Accept\": \"image/jpeg,image/png,image/webp,*/*\"\n}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1552,
        672
      ],
      "id": "8e05687c-4f21-47e3-a93e-4984616f0ebb",
      "name": "download image to X/Twitter"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://upload.twitter.com/1.1/media/upload.json?media_category=tweet_image",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "media",
              "inputDataFieldName": "data"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1728,
        672
      ],
      "id": "765e01a3-cea6-4c52-bb92-b4ffba24b32e",
      "name": "upload media X",
      "alwaysOutputData": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.twitter.com/2/tweets",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": \"{{$('Preparar body X').first().json.x_body.text}}\",\n  \"media\": {\n    \"media_ids\": [\"{{$('Preparar body X').first().json.x_body.media.media_ids[0]}}\"]\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2400,
        656
      ],
      "id": "c59e39b6-4377-49ef-afcc-bbea8e4e68ed",
      "name": "Twitter/X posts"
    },
    {
      "parameters": {
        "jsCode": "const cleanLinkedIn = ($json.content_linkedin || \"\")\n  .replace(/<[^>]*>/g, \" \")\n  .replace(/&nbsp;/g, \" \")\n  .trim()\n  .substring(0, 3000);\n\nreturn [\n  {\n    json: {\n      ...$json,\n\n      // URL maestra de la imagen WP\n      linkedin_image_source: $json.image_current,\n\n      linkedin_body: {\n        author: linkedinAuthor,\n        commentary: cleanLinkedIn,\n        visibility: \"PUBLIC\",\n        distribution: {\n          feedDistribution: \"MAIN_FEED\"\n        },\n        lifecycleState: \"PUBLISHED\"\n      },\n\n      linkedin_success: true,\n      content_linkedin_length: cleanLinkedIn.length\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1136,
        400
      ],
      "id": "141f2c47-8d59-4b57-be89-dbba91fb9cfa",
      "name": "Preparador Linkedin"
    },
    {
      "parameters": {
        "jsCode": "const data = $json;\n\nconst text =\n  data.content_x ||\n  data.content_current ||\n  \"\";\n\nreturn [\n  {\n    json: {\n      ...data,\n      x_text: text.substring(0, 280),\n      image_source_url: data.image_source_url || data.image_current || \"\"\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1360,
        672
      ],
      "id": "5999c0be-2acf-482a-b917-c9d417fd17c9",
      "name": "Preparador X/Twitter"
    },
    {
      "parameters": {
        "jsCode": "const previous = $(\"Preparador X/Twitter\").first().json;\nconst mediaId = $(\"upload media X\").first().json.media_id_string;\n\nreturn [\n  {\n    json: {\n      ...previous,\n      x_body: {\n        text: previous.x_text,\n        media: {\n          media_ids: [mediaId]\n        }\n      }\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1952,
        672
      ],
      "id": "b4fd3c49-7060-4ee8-b99e-a05732200f42",
      "name": "Preparar body X"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('decrypt credentials').first().json.wordpress_urlapi }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0"
            },
            {
              "name": "Authorization",
              "value": "={{ $('decrypt credentials').first().json.wp_auth_header }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "title",
              "value": "={{ $json.title_current }}"
            },
            {
              "name": "content",
              "value": "={{ $json.content_current }}"
            },
            {
              "name": "featured_media",
              "value": "={{ $json.featured_media_id }}"
            },
            {
              "name": "tags",
              "value": "={{ JSON.parse($json.tags_current).map(Number) }}"
            },
            {
              "name": "categories",
              "value": "={{ JSON.parse($json.category_current).map(Number) }}"
            },
            {
              "name": "status",
              "value": "={{ $json.status }}"
            },
            {
              "name": "date",
              "value": "={{ $json.date }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        336,
        464
      ],
      "id": "644ea7ce-2a69-41d1-b29e-bf7dc2862fd0",
      "name": "WP Posts dinamico",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "waitBetweenTries": 2500
    },
    {
      "parameters": {
        "method": "POST",
        "url": "",
        "sendHeaders": true,
        "specifyHeaders": "json",
        "jsonHeaders": "{\n  \"Accept\": \"application/json\",\n  \"Content-Type\": \"application/json\",\n  \"User-Agent\": \"Mozilla/5.0\"\n}",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "title",
              "value": "={{ $json.title_current }}"
            },
            {
              "name": "content",
              "value": "={{ $json.content_current }}"
            },
            {
              "name": "featured_media",
              "value": "={{ $json.featured_media_id }}"
            },
            {
              "name": "tags",
              "value": "={{ JSON.parse($json.tags_current).map(Number) }}"
            },
            {
              "name": "categories",
              "value": "={{ JSON.parse($json.category_current).map(Number) }}"
            },
            {
              "name": "status",
              "value": "={{ $json.status }}"
            },
            {
              "name": "date",
              "value": "={{ $json.date }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        96,
        368
      ],
      "id": "478500c2-c7d9-4e43-a765-69d3fbf72235",
      "name": "WP Posts estatico",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "waitBetweenTries": 2500
    },
    {
      "parameters": {
        "url": "",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendHeaders": true,
        "specifyHeaders": "json",
        "jsonHeaders": "{\n  \"Accept\": \"application/json\",\n  \"User-Agent\": \"Mozilla/5.0\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        -320,
        464
      ],
      "id": "aa09cd8c-3592-4fcd-bb9f-f7b7cac81e45",
      "name": "WP Posts estatico/dinamico",
      "alwaysOutputData": false,
      "retryOnFail": false,
      "waitBetweenTries": 2500,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "jsCode": "const input = $json || {};\n\n// Datos base\nconst title = input.title || input.post_title || \"\";\nconst contentInstagram =\n  input.content_instagram ||\n  input.instagram_text ||\n  input.content_social ||\n  input.content_current ||\n  input.content ||\n  \"\";\n\n// Imagen p\u00fablica ya subida en WP o recibida del WF1\nconst imageUrl =\n  input.image_url ||\n  input.featured_image_url ||\n  input.media_url ||\n  input.source_url ||\n  \"\";\n\n// Credenciales / IDs\nconst instagramUserId =\n  input.instagram_user_id ||\n  input.ig_user_id ||\n  input.credentials?.instagram_user_id ||\n  input.credentials?.ig_user_id ||\n  \"\";\n\nconst instagramAccessToken =\n  input.instagram_access_token ||\n  input.access_token ||\n  input.credentials?.instagram_access_token ||\n  input.credentials?.access_token ||\n  \"\";\n\nif (!instagramUserId) {\n  throw new Error(\"Falta instagram_user_id / ig_user_id\");\n}\n\nif (!instagramAccessToken) {\n  throw new Error(\"Falta instagram_access_token\");\n}\n\nif (!imageUrl) {\n  throw new Error(\"Falta image_url p\u00fablica para Instagram\");\n}\n\nconst caption = contentInstagram || title;\n\nif (!caption) {\n  throw new Error(\"Falta texto/caption para Instagram\");\n}\n\nreturn [\n  {\n    json: {\n      ...input,\n\n      platform: \"instagram\",\n\n      instagram_user_id: instagramUserId,\n      instagram_access_token: instagramAccessToken,\n\n      image_url: imageUrl,\n      caption,\n\n      create_media_url: `https://graph.facebook.com/v23.0/${instagramUserId}/media`,\n      publish_media_url: `https://graph.facebook.com/v23.0/${instagramUserId}/media_publish`\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -352,
        928
      ],
      "id": "f76e61e8-5cfd-4c7e-b726-9e73d44497b5",
      "name": "Preparador instagram"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "946eb96f-504e-4127-8a68-aa8f39bd89cf",
              "leftValue": "",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "6b69a575-27b0-4bb8-b30d-649d9c860331",
              "leftValue": "",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -176,
        928
      ],
      "id": "46a85b2b-dc15-4eb8-85ee-9491729d4529",
      "name": "existe image_url publica?"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v23.0/{{ $json.instagram_user_id }}/media\n",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image_url",
              "value": "={{ $json.public_image_url || $json.image_url }}"
            },
            {
              "name": "caption",
              "value": "={{ $json.caption }}"
            },
            {
              "name": "=access_token",
              "value": "={{ $json.instagram_access_token }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        848,
        1184
      ],
      "id": "1a4c230a-0345-4a39-b701-6c1f6f8b9c9e",
      "name": "media container instagram"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v23.0/{{ $json.instagram_user_id }}/media_publish",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "=creation_id",
              "value": "={{ $json.id }}"
            },
            {
              "name": "=access_token",
              "value": "={{ $('Preparador instagram').first().json.instagram_access_token }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        528,
        560
      ],
      "id": "1dba023f-3497-4352-9ab6-1deb013acba9",
      "name": "publish media instagram"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.cloudinary.com/v1_1/{{$json.cloud_name}}/image/upload",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            },
            {
              "name": "upload_preset",
              "value": "instagram_public"
            }
          ]
        },
        "options": {}
      },
   

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

generación_publicaciones (workflow 3) webhook all platforms decrypt publicar git. Uses dataTable, linkedIn, httpRequest. Webhook trigger; 50 nodes.

Source: https://github.com/arturolg20/n8n-social-media-automation-/blob/main/workflow-3-publishing-distribution.json — original creator credit. Request a take-down →

More Social Media workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Social Media

This workflow leverages n8n to automate LinkedIn content creation from start to finish. Upload an image and quote through a web form, and get a professionally designed post with AI-generated captions,

HTTP Request, LinkedIn, Edit Image
Social Media

aban — Publish Fanout. Uses linkedIn, twitter, httpRequest. Webhook trigger; 6 nodes.

LinkedIn, Twitter, HTTP Request
Social Media

This workflow automates the post-publish process for YouTube videos, combining advanced SEO optimization, cross-platform promotion, and analytics reporting. It is designed for creators, marketers, and

YouTube, HTTP Request, LinkedIn +6
Social Media

Automatically scrape LinkedIn posts with Apify, transform them into optimized tweets and threads using Claude AI, store them in Airtable for approval, and publish to X on a daily schedule.

@Apify/N8N Nodes Apify, Output Parser Structured, Chain Llm +6
Social Media

Every time you publish a blog post on WordPress, this workflow automatically creates unique, platform-optimised captions for Facebook, Instagram, Twitter and LinkedIn — and publishes them all simultan

Agent, Output Parser Structured, OpenRouter Chat +3