{
  "name": "Remix competitor ad patterns with Videotok references",
  "nodes": [
    {
      "parameters": {
        "content": "## Remix competitor ad patterns with Videotok references\n\n### How it works\n\n1. Manually triggers the workflow to start the process.\n2. Sets reference data for inspiration, including image URLs and offer details.\n3. Submits data to OpenAI's API to analyze inspiration references.\n4. Builds target data for initiating a Videotok reference.\n5. Posts reference data to Videotok and waits for the asset generation status.\n\n### Setup steps\n\n- [ ] Configure OpenAI API credentials\n- [ ] Configure Videotok API credentials\n\n### Customization\n\nAdjust the wait time in the 'Wait 90 Seconds' node to match the expected processing time. Before activating the workflow, test it with one item, review the generated creative in Videotok, and confirm the brand, platform, and publishing requirements.",
        "width": 480,
        "height": 688
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-1232, 0],
      "id": "99ffae02-40c4-4806-afe9-a176d7008fb3",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Trigger and set reference data\n\nManually trigger the workflow and set initial reference data.",
        "width": 464,
        "height": 304,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-672, 0],
      "id": "dfb1f2a2-248a-47d3-93d8-1e5a3b954931",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Analyze references with OpenAI\n\nSend the reference data to OpenAI API for analysis and build a target from the response.",
        "width": 480,
        "height": 304,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-128, 0],
      "id": "b0485e1e-2315-43ab-8a27-8dd90908aee8",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Post references to Videotok\n\nPost the reference data to Videotok, trigger generation and handling post-status check.",
        "width": 1024,
        "height": 272,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [448, 16],
      "id": "de481f6a-6c6d-4fb0-b2f8-2f2b0ea33f6b",
      "name": "Sticky Note3"
    },
    {
      "parameters": {},
      "id": "manual",
      "name": "Trigger when Inspired",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-624, 128]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "reference",
              "name": "reference_image_url",
              "type": "string",
              "value": "https://example.com/inspiration.png"
            },
            {
              "id": "product",
              "name": "product_image_url",
              "type": "string",
              "value": "https://example.com/product.png"
            },
            {
              "id": "offer",
              "name": "offer",
              "type": "string",
              "value": "A premium running shoe for city runners"
            }
          ]
        }
      },
      "id": "input",
      "name": "Set Ad Reference Data",
      "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\":\"Analyze this ad inspiration for reusable structure only. Return JSON with label, target_template_slug, target_template_category, generation_prompt, caption. Never copy identity. Input: \" + JSON.stringify($json)}"
      },
      "id": "analyze",
      "name": "Post Reference to OpenAI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-80, 128]
    },
    {
      "parameters": {
        "jsCode": "const source = $('Set Ad Reference Data').first().json;\nconst raw = $input.first().json.output_text || '{}';\nlet brief;\ntry { brief = JSON.parse(raw); } catch { brief = { label: 'Reference remix', target_template_slug: 'motion-graphics', target_template_category: 'video-templates', generation_prompt: raw }; }\nreturn [{ json: { ...brief, reference_image_url: source.reference_image_url, product_image_url: source.product_image_url } }];"
      },
      "id": "prepare-reference",
      "name": "Build AI Reference Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [208, 128]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://videotok.app/api/v1/reference-inspirations",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.VIDEOTOK_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"template_slug\":$json.target_template_slug || \"motion-graphics\",\"template_category\":$json.target_template_category || \"video-templates\",\"media_kind\":\"image\",\"visibility\":\"private\",\"label\":$json.label,\"image_urls\":[$json.reference_image_url]}"
      },
      "id": "save-reference",
      "name": "Submit to Videotok Reference API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [496, 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": "=reference-remix-{{$execution.id}}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"type\":\"video_ad\",\"template_slug\":$('Build AI Reference Data').first().json.target_template_slug || \"motion-graphics\",\"prompt\":$('Build AI Reference Data').first().json.generation_prompt,\"aspect_ratio\":\"9:16\",\"duration\":8,\"quality_tier\":\"high\",\"brand_kit_id\":$vars.VIDEOTOK_BRAND_KIT_ID,\"reference_image_urls\":[$('Build AI Reference Data').first().json.product_image_url],\"custom_reference_inspiration_id\":$json.id || $json.reference_inspiration_id,\"idempotency_key\":\"reference-remix-\" + $execution.id}"
      },
      "id": "generate",
      "name": "Initiate Videotok Generation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [800, 128]
    },
    {
      "parameters": {
        "amount": 90,
        "unit": "seconds"
      },
      "id": "wait",
      "name": "Wait for Generation Completion",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [1056, 128]
    },
    {
      "parameters": {
        "url": "=https://videotok.app/api/v1/generations/{{$json.id || $json.generation_id}}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.VIDEOTOK_API_KEY}}"
            }
          ]
        }
      },
      "id": "poll",
      "name": "Fetch Videotok Remix Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1328, 128]
    }
  ],
  "connections": {
    "Trigger when Inspired": {
      "main": [
        [
          {
            "node": "Set Ad Reference Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Ad Reference Data": {
      "main": [
        [
          {
            "node": "Post Reference to OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Reference to OpenAI": {
      "main": [
        [
          {
            "node": "Build AI Reference Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build AI Reference Data": {
      "main": [
        [
          {
            "node": "Submit to Videotok Reference API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit to Videotok Reference API": {
      "main": [
        [
          {
            "node": "Initiate Videotok Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initiate Videotok Generation": {
      "main": [
        [
          {
            "node": "Wait for Generation Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Generation Completion": {
      "main": [
        [
          {
            "node": "Fetch Videotok Remix Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": ["videotok", "openai", "reference inspiration", "ad research"],
  "active": false,
  "versionId": "videotok-competitor-reference-ad-remixer-1"
}
