{
  "name": "Automate Pinterest product pins with Videotok",
  "nodes": [
    {
      "parameters": {
        "content": "## Pinterest product pin factory\n\nCreates fresh product pin creatives and video pin assets from a product row, seasonal keyword, or campaign theme.\n\nReplace the sample product with Shopify, Airtable, Sheets, or a PIM.\n\nRequired variables: VIDEOTOK_API_KEY, OPENAI_API_KEY, VIDEOTOK_BRAND_KIT_ID.",
        "height": 300,
        "width": 500,
        "color": 5
      },
      "id": "note-overview",
      "name": "Overview and setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-700, -260]
    },
    {
      "parameters": {},
      "id": "manual",
      "name": "Manual Pinterest product test",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-620, 120]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "product",
              "name": "product_name",
              "type": "string",
              "value": "Minimal ceramic desk lamp"
            },
            {
              "id": "season",
              "name": "seasonal_keyword",
              "type": "string",
              "value": "small apartment office ideas"
            },
            {
              "id": "image",
              "name": "product_image_url",
              "type": "string",
              "value": "https://example.com/product.png"
            }
          ]
        }
      },
      "id": "product-source",
      "name": "Replace with Pinterest product source",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [-360, 120]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/responses",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.OPENAI_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"model\":\"gpt-4.1-mini\",\"input\":\"Create Pinterest-native product creative JSON. Include static_pin_prompt, video_pin_prompt, pin_title, pin_description, keywords. Input: \" + JSON.stringify($json)}"
      },
      "id": "openai-pinterest",
      "name": "OpenAI writes Pinterest creative",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-80, 120]
    },
    {
      "parameters": {
        "jsCode": "const product = $('Replace with Pinterest product source').first().json;\nconst raw = $input.first().json.output_text || '{}';\nlet brief;\ntry { brief = JSON.parse(raw); } catch { brief = { static_pin_prompt: raw, video_pin_prompt: raw, pin_title: product.product_name, pin_description: raw }; }\nreturn [\n  { json: { type: 'static_ad', template_slug: 'product-shoot', prompt: brief.static_pin_prompt, aspect_ratio: '2:3', resolution: '1K', reference_image_urls: [product.product_image_url], brand_kit_id: $vars.VIDEOTOK_BRAND_KIT_ID, idempotency_key: `pinterest-static-${$execution.id}` } },\n  { json: { type: 'video_ad', template_slug: 'viral-video-ads', prompt: brief.video_pin_prompt, aspect_ratio: '2:3', duration: 8, quality_tier: 'high', reference_image_urls: [product.product_image_url], brand_kit_id: $vars.VIDEOTOK_BRAND_KIT_ID, idempotency_key: `pinterest-video-${$execution.id}` } }\n];"
      },
      "id": "prepare-pins",
      "name": "Prepare static and video pins",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [220, 120]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://videotok.app/api/v1/generations",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.VIDEOTOK_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Idempotency-Key",
              "value": "={{$json.idempotency_key}}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{$json}}"
      },
      "id": "create-pins",
      "name": "Create Videotok Pinterest assets",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [540, 120]
    }
  ],
  "connections": {
    "Manual Pinterest product test": {
      "main": [
        [
          {
            "node": "Replace with Pinterest product source",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace with Pinterest product source": {
      "main": [
        [
          {
            "node": "OpenAI writes Pinterest creative",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI writes Pinterest creative": {
      "main": [
        [
          {
            "node": "Prepare static and video pins",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare static and video pins": {
      "main": [
        [
          {
            "node": "Create Videotok Pinterest assets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "tags": ["videotok", "openai", "pinterest", "product pins"],
  "active": false,
  "versionId": "videotok-pinterest-product-pin-factory-1"
}
