{
  "name": "Automate Instagram Reels and carousels with Videotok",
  "nodes": [
    {
      "parameters": {
        "content": "## Instagram Reels and carousel studio\n\nTurns an approved Instagram brief into a Reel-style video asset and a carousel/slideshow asset using the Videotok API.\n\nReplace the sample brief with Notion, Airtable, Google Sheets, or your approval workflow.\n\nRequired variables: VIDEOTOK_API_KEY, OPENAI_API_KEY, VIDEOTOK_BRAND_KIT_ID.",
        "height": 320,
        "width": 520,
        "color": 6
      },
      "id": "note-overview",
      "name": "Overview and setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-700, -280]
    },
    {
      "parameters": {},
      "id": "manual",
      "name": "Manual Instagram brief test",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-620, 120]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "brief",
              "name": "instagram_brief",
              "type": "string",
              "value": "Launch post for a new AI social media automation feature"
            },
            {
              "id": "product",
              "name": "product_image_url",
              "type": "string",
              "value": "https://example.com/product.png"
            },
            {
              "id": "goal",
              "name": "goal",
              "type": "string",
              "value": "Drive trials and saves"
            }
          ]
        }
      },
      "id": "brief-source",
      "name": "Replace with Instagram content brief",
      "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\":\"Turn this Instagram brief into strict JSON with reel_prompt, carousel_prompt, caption, slide_outline, hashtags. Input: \" + JSON.stringify($json)}"
      },
      "id": "openai-instagram",
      "name": "OpenAI writes Instagram assets",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-80, 120]
    },
    {
      "parameters": {
        "jsCode": "const source = $('Replace with Instagram content brief').first().json;\nconst raw = $input.first().json.output_text || '{}';\nlet brief;\ntry { brief = JSON.parse(raw); } catch { brief = { reel_prompt: raw, carousel_prompt: raw, caption: raw, slide_outline: raw }; }\nreturn [\n  { json: { endpoint: 'generations', body: { type: 'video_ad', template_slug: 'viral-video-ads', prompt: brief.reel_prompt, aspect_ratio: '9:16', duration: 8, quality_tier: 'high', reference_image_urls: [source.product_image_url], brand_kit_id: $vars.VIDEOTOK_BRAND_KIT_ID, idempotency_key: `instagram-reel-${$execution.id}` } } },\n  { json: { endpoint: 'slideshows', body: { prompt: brief.carousel_prompt, title: source.instagram_brief, aspect_ratio: '4:5', product_image_urls: [source.product_image_url], brand_kit_id: $vars.VIDEOTOK_BRAND_KIT_ID, idempotency_key: `instagram-carousel-${$execution.id}` } } }\n];"
      },
      "id": "prepare-assets",
      "name": "Prepare Reel and carousel payloads",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [220, 120]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://videotok.app/api/v1/{{$json.endpoint}}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.VIDEOTOK_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Idempotency-Key",
              "value": "={{$json.body.idempotency_key}}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{$json.body}}"
      },
      "id": "create-assets",
      "name": "Create Videotok Instagram assets",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [540, 120]
    }
  ],
  "connections": {
    "Manual Instagram brief test": {
      "main": [
        [
          {
            "node": "Replace with Instagram content brief",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace with Instagram content brief": {
      "main": [
        [
          {
            "node": "OpenAI writes Instagram assets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI writes Instagram assets": {
      "main": [
        [
          {
            "node": "Prepare Reel and carousel payloads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Reel and carousel payloads": {
      "main": [
        [
          {
            "node": "Create Videotok Instagram assets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "tags": ["videotok", "openai", "instagram", "reels", "carousels"],
  "active": false,
  "versionId": "videotok-instagram-reels-carousel-studio-1"
}
