{
  "name": "Automatización de Diseños en Canva para Redes Sociales",
  "flow": [
    {
      "id": 1,
      "module": "google-sheets:searchRows",
      "version": 2,
      "parameters": {
        "spreadsheetId": "{{SPREADSHEET_CONTENIDO_ID}}",
        "sheetId": "Calendario Editorial",
        "filter": "F:F=Pendiente"
      },
      "mapper": {},
      "metadata": {
        "designer": { "x": 0, "y": 0 },
        "restore": {
          "spreadsheetId": { "label": "Calendario de Contenido" },
          "sheetId": { "label": "Calendario Editorial" }
        },
        "expect": [
          { "name": "spreadsheetId", "type": "text", "label": "Spreadsheet ID" },
          { "name": "sheetId", "type": "text", "label": "Sheet Name" }
        ]
      }
    },
    {
      "id": 2,
      "module": "builtin:BasicRouter",
      "version": 1,
      "parameters": {},
      "mapper": {},
      "routes": [
        {
          "label": "Instagram Post",
          "filter": { "conditions": [{ "a": "{{1.plataforma}}", "o": "text:equal", "b": "instagram" }] },
          "flow": [3]
        },
        {
          "label": "Facebook Post",
          "filter": { "conditions": [{ "a": "{{1.plataforma}}", "o": "text:equal", "b": "facebook" }] },
          "flow": [3]
        },
        {
          "label": "Instagram Story",
          "filter": { "conditions": [{ "a": "{{1.plataforma}}", "o": "text:equal", "b": "story" }] },
          "flow": [3]
        }
      ],
      "metadata": {
        "designer": { "x": 300, "y": 0 },
        "restore": {},
        "expect": []
      }
    },
    {
      "id": 3,
      "module": "canva:createDesign",
      "version": 1,
      "parameters": {
        "accessToken": "{{CANVA_ACCESS_TOKEN}}"
      },
      "mapper": {
        "templateId": "{{if(1.plataforma = \"instagram\"; TEMPLATE_IG_POST; if(1.plataforma = \"facebook\"; TEMPLATE_FB_POST; TEMPLATE_IG_STORY))}}",
        "title": "{{1.textoPrincipal}} - {{formatDate(now; \"DD-MM-YYYY\")}}",
        "replacements": [
          {
            "find": "TEXTO_PRINCIPAL",
            "replace": "{{1.textoPrincipal}}"
          },
          {
            "find": "TEXTO_SECUNDARIO",
            "replace": "{{1.textoSecundario}}"
          },
          {
            "find": "URL_IMAGEN",
            "replace": "{{1.urlImagen}}"
          }
        ]
      },
      "metadata": {
        "designer": { "x": 600, "y": 0 },
        "restore": {},
        "expect": [
          { "name": "accessToken", "type": "text", "label": "Access Token" },
          { "name": "templateId", "type": "text", "label": "Template ID" }
        ]
      }
    },
    {
      "id": 4,
      "module": "canva:exportDesign",
      "version": 1,
      "parameters": {
        "accessToken": "{{CANVA_ACCESS_TOKEN}}"
      },
      "mapper": {
        "designId": "{{3.designId}}",
        "format": "png",
        "quality": "high"
      },
      "metadata": {
        "designer": { "x": 900, "y": 0 },
        "restore": {},
        "expect": [
          { "name": "designId", "type": "text", "label": "Design ID" }
        ]
      }
    },
    {
      "id": 5,
      "module": "google-drive:uploadFile",
      "version": 2,
      "parameters": {
        "folderId": "{{CARPETA_DISENOS_ID}}/{{formatDate(now; \"YYYY-MM\")}}"
      },
      "mapper": {
        "name": "{{1.plataforma}}_{{formatDate(now; \"YYYY-MM-DD\")}}_{{1.textoPrincipal}}.png",
        "data": "{{4.exportedFile}}",
        "mimeType": "image/png"
      },
      "metadata": {
        "designer": { "x": 1200, "y": 0 },
        "restore": {},
        "expect": [
          { "name": "folderId", "type": "text", "label": "Folder ID" }
        ]
      }
    },
    {
      "id": 6,
      "module": "google-sheets:updateRow",
      "version": 2,
      "parameters": {
        "spreadsheetId": "{{SPREADSHEET_CONTENIDO_ID}}",
        "sheetId": "Calendario Editorial",
        "rowId": "{{1.__ROW_NUMBER__}}"
      },
      "mapper": {
        "values": {
          "5": "Generado",
          "6": "{{5.webViewLink}}",
          "7": "{{formatDate(now; \"DD/MM/YYYY HH:mm\")}}"
        }
      },
      "metadata": {
        "designer": { "x": 1500, "y": 0 },
        "restore": {},
        "expect": [
          { "name": "spreadsheetId", "type": "text", "label": "Spreadsheet ID" },
          { "name": "rowId", "type": "number", "label": "Row Number" }
        ]
      }
    }
  ],
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": true
    },
    "designer": {
      "orphans": []
    },
    "zone": "us1.make.com"
  }
}