{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0c5eaaff-a604-403a-95b5-ab7657675921",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 392,
        "content": "# Bulk publish Pinterest Pins from Google Sheets\n\nThis template uses **Google Sheets as the input queue**, **n8n as the orchestration layer**, and **PinBridge as the Pinterest publishing layer**.\n\n### How it works\n1. Read rows from the `Pins` sheet\n2. Skip rows already marked as published\n3. Validate required row fields\n4. Download the image\n5. Upload the image to PinBridge\n6. Submit the Pinterest publish job\n7. Write the result back to the same sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "b0542cfe-aac5-42ac-ad9f-8b4559b9fb59",
      "name": "Sticky Note - Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 760,
        "height": 384,
        "content": "## Setup checklist\n\nBefore running this workflow, replace the placeholders and connect credentials:\n\n- Add a **Google Sheets** credential\n- Add a **PinBridge** credential\n- Replace `YOUR_GOOGLE_SHEET_ID`\n- Replace `YOUR_PINTEREST_ACCOUNT_ID`\n- Confirm the sheet tab name is `Pins`\n- Confirm each row has a unique `row_id`\n- Confirm `image_url` points to a **publicly reachable image**\n- Confirm `board_id` is the **real Pinterest board ID**\n\n### Expected columns\n`row_id`, `title`, `description`, `link_url`, `image_url`, `board_id`, `alt_text`, `dominant_color`, `status`, `job_id`, `published_at`, `error_message`"
      },
      "typeVersion": 1
    },
    {
      "id": "96c28e52-0b66-4414-9366-4cacb4116f99",
      "name": "Sticky Note - Read and filter",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        432
      ],
      "parameters": {
        "color": 4,
        "width": 720,
        "height": 460,
        "content": "## Read and filter rows\n\nThe workflow starts manually, then reads all rows from the `Pins` tab.\n\n`Skip Published Rows` prevents rows already marked as `published` from being processed again.\n\nThis keeps re-runs safer and gives you a clear place to define future reprocessing logic."
      },
      "typeVersion": 1
    },
    {
      "id": "792de724-15ca-40ac-8e2a-6440c9ca323c",
      "name": "Sticky Note - Valid rows",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        432
      ],
      "parameters": {
        "width": 1464,
        "height": 460,
        "content": "## Validate and submit valid rows\n\n`Validate Required Fields` checks that the row contains: `title` | `description` | `link_url` | `image_url` | `board_id`\n\n\nIf valid, the workflow downloads the image, uploads it to PinBridge, then submits the Pinterest publish job.\n\nOn success, the workflow writes:\n- `status = submitted` | `job_id` | `published_at` | empty `error_message`"
      },
      "typeVersion": 1
    },
    {
      "id": "a99a1cfa-7507-4868-97b2-1e5195c0a88e",
      "name": "Sticky Note - Invalid rows",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        944
      ],
      "parameters": {
        "color": 6,
        "width": 520,
        "height": 476,
        "content": "## Handle invalid rows\n\nRows missing one or more required fields do **not** continue to external steps.\n\nInstead, the workflow marks the row as:\n\n- `status = invalid`\n- `error_message = Missing one or more required fields...`\n\n\nThis makes the sheet self-correcting and easier to review after each run."
      },
      "typeVersion": 1
    },
    {
      "id": "19d95fbf-6c27-4464-aa74-c826acd998f4",
      "name": "Sticky Note - Scope",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 696,
        "height": 380,
        "content": "## What this template covers\n\nThis template records **successful job submission** only.\n\nA separate workflow should handle:\n- webhook callbacks\n- final publish confirmation\n- retries for downstream failures\n- notifications and reporting\n\nThat keeps this template easier to import, test, and understand."
      },
      "typeVersion": 1
    },
    {
      "id": "78071c8e-da9d-417a-8c84-aee5736f556e",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -640,
        720
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9718aea3-2e14-40fc-82dd-0e8704816805",
      "name": "Read Sheet Rows",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -416,
        720
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Pins"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "e7f2c694-6f52-4454-a680-b9fb52b6a9e8",
      "name": "Skip Published Rows",
      "type": "n8n-nodes-base.if",
      "position": [
        -192,
        720
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "skip-published",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ ($json.status || '').toString().toLowerCase() }}",
              "rightValue": "published"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2b54e4d0-1e4d-4bcd-a79d-163a6ff040c9",
      "name": "Validate Required Fields",
      "type": "n8n-nodes-base.if",
      "position": [
        144,
        704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-title",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ !!$json.title }}",
              "rightValue": true
            },
            {
              "id": "has-description",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ !!$json.description }}",
              "rightValue": true
            },
            {
              "id": "has-link",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ !!$json.link_url }}",
              "rightValue": true
            },
            {
              "id": "has-image",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ !!$json.image_url }}",
              "rightValue": true
            },
            {
              "id": "has-board",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ !!$json.board_id }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "23fd98f8-9b47-42fc-a153-dac2c2a82a94",
      "name": "Download Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        384,
        688
      ],
      "parameters": {
        "url": "={{ $json.image_url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "0b2820b8-53f5-4697-9e0e-9c2296022bb5",
      "name": "Upload Image to PinBridge",
      "type": "n8n-nodes-pinbridge.pinBridge",
      "position": [
        624,
        688
      ],
      "parameters": {
        "resource": "assets"
      },
      "credentials": {
        "pinBridgeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b1c66fce-3ce6-47a1-b1a6-634be9eedbd3",
      "name": "Publish to Pinterest",
      "type": "n8n-nodes-pinbridge.pinBridge",
      "position": [
        864,
        688
      ],
      "parameters": {
        "title": "={{ $json.title }}",
        "altText": "={{ $json.alt_text || '' }}",
        "boardId": "={{ $json.board_id }}",
        "linkUrl": "={{ $json.link_url }}",
        "accountId": "YOUR_PINTEREST_ACCOUNT_ID",
        "description": "={{ $json.description }}",
        "dominantColor": "={{ $json.dominant_color || '#ffffff' }}"
      },
      "credentials": {
        "pinBridgeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "86c27bb9-1967-4b5f-863a-4750b80dd523",
      "name": "Build Success Result",
      "type": "n8n-nodes-base.set",
      "position": [
        1104,
        688
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "set-status",
              "name": "status",
              "type": "string",
              "value": "submitted"
            },
            {
              "id": "set-job-id",
              "name": "job_id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "set-published-at",
              "name": "published_at",
              "type": "string",
              "value": "={{ $now }}"
            },
            {
              "id": "set-error",
              "name": "error_message",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "40bf111a-abd4-4e01-8771-25dde90245bd",
      "name": "Update Sheet Success",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1344,
        688
      ],
      "parameters": {
        "columns": {
          "value": {
            "job_id": "={{ $json.job_id }}",
            "status": "={{ $json.status }}",
            "published_at": "={{ $json.published_at }}",
            "error_message": "={{ $json.error_message }}"
          },
          "schema": [
            {
              "id": "row_id",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "row_id",
              "defaultMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "job_id",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "job_id",
              "defaultMatch": false
            },
            {
              "id": "published_at",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "published_at",
              "defaultMatch": false
            },
            {
              "id": "error_message",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "error_message",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Pins"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "ba480360-c7df-40f8-8186-73a67e12a2fa",
      "name": "Build Invalid Result",
      "type": "n8n-nodes-base.set",
      "position": [
        384,
        1264
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "invalid-status",
              "name": "status",
              "type": "string",
              "value": "invalid"
            },
            {
              "id": "invalid-error",
              "name": "error_message",
              "type": "string",
              "value": "Missing one or more required fields: title, description, link_url, image_url, board_id"
            },
            {
              "id": "invalid-job-id",
              "name": "job_id",
              "type": "string",
              "value": ""
            },
            {
              "id": "invalid-published-at",
              "name": "published_at",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "80561e34-0cb2-41b0-970d-872fa5814a6d",
      "name": "Update Sheet Invalid Row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        656,
        1264
      ],
      "parameters": {
        "columns": {
          "value": {
            "job_id": "={{ $json.job_id }}",
            "status": "={{ $json.status }}",
            "published_at": "={{ $json.published_at }}",
            "error_message": "={{ $json.error_message }}"
          },
          "schema": [
            {
              "id": "row_id",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "row_id",
              "defaultMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "job_id",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "job_id",
              "defaultMatch": false
            },
            {
              "id": "published_at",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "published_at",
              "defaultMatch": false
            },
            {
              "id": "error_message",
              "type": "string",
              "display": true,
              "readOnly": false,
              "required": false,
              "displayName": "error_message",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Pins"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "connections": {
    "Download Image": {
      "main": [
        [
          {
            "node": "Upload Image to PinBridge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Read Sheet Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Sheet Rows": {
      "main": [
        [
          {
            "node": "Skip Published Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip Published Rows": {
      "main": [
        [
          {
            "node": "Validate Required Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Invalid Result": {
      "main": [
        [
          {
            "node": "Update Sheet Invalid Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Success Result": {
      "main": [
        [
          {
            "node": "Update Sheet Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish to Pinterest": {
      "main": [
        [
          {
            "node": "Build Success Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Required Fields": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Invalid Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Image to PinBridge": {
      "main": [
        [
          {
            "node": "Publish to Pinterest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}