{
  "name": "Automate Pinterest product pins with Videotok",
  "nodes": [
    {
      "parameters": {
        "content": "## Automate Pinterest product pins with Videotok\n\n### How it works\n\n1. The workflow is triggered manually.\n2. Pinterest product details are set.\n3. These details are sent to OpenAI for creative content.\n4. The response is used to build Pinterest pin content.\n5. Final assets are created by posting content to Videotok.\n\n### Setup steps\n\n- [ ] Configure OpenAI API credentials.\n- [ ] Configure Videotok API credentials.\n\n### Customization\n\nAdjust the API endpoints for OpenAI and Videotok calls if their URLs change. Before activating the workflow, test it with one item, review the generated creative in Videotok, and confirm the brand, platform, and publishing requirements. Teams can replace the sample source and review handoff with their production systems while keeping the same generation and approval flow.",
        "width": 480,
        "height": 672
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-1232, 0],
      "id": "85e5c924-882c-487a-9f12-3d372c9b3881",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Trigger and set product details\n\nInitiates the workflow and sets initial Pinterest product details.",
        "width": 464,
        "height": 304,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-672, 0],
      "id": "cff25737-c231-4b67-85c6-0145ce766f3c",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Generate creative content\n\nSends product details to OpenAI for generating creative content.",
        "width": 816,
        "height": 272,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-128, 16],
      "id": "be4bff33-5670-4b1a-b796-7887b9fd710c",
      "name": "Sticky Note2"
    },
    {
      "parameters": {},
      "id": "manual",
      "name": "Manual Start Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-624, 128]
    },
    {
      "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": "Prepare Product Details",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [-352, 128]
    },
    {
      "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": "Post Creative Request to OpenAI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-80, 128]
    },
    {
      "parameters": {
        "jsCode": "const product = $('Prepare Product Details').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": "Craft Pinterest Pin Content",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [224, 128]
    },
    {
      "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": "Send Assets to Videotok API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [544, 128]
    }
  ],
  "connections": {
    "Manual Start Trigger": {
      "main": [
        [
          {
            "node": "Prepare Product Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Product Details": {
      "main": [
        [
          {
            "node": "Post Creative Request to OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Creative Request to OpenAI": {
      "main": [
        [
          {
            "node": "Craft Pinterest Pin Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Craft Pinterest Pin Content": {
      "main": [
        [
          {
            "node": "Send Assets to Videotok API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": ["videotok", "openai", "pinterest", "product pins"],
  "active": false,
  "versionId": "videotok-pinterest-product-pin-factory-1"
}
