{
  "name": "Automate Instagram Reels and carousels with Videotok",
  "nodes": [
    {
      "parameters": {
        "content": "## Automate Instagram Reels and carousels with Videotok\n\n### How it works\n\n1. The workflow is manually triggered to start the process.\n2. Sets Instagram content brief details such as product image and goals.\n3. Sends a POST request to the OpenAI API to generate content.\n4. Builds Instagram payloads using custom code.\n5. Posts the prepared payloads to the Videotok API to automate Instagram Reels and carousel creation.\n\n### Setup steps\n\n- [ ] Ensure you have n8n credentials set up for OpenAI API.\n- [ ] Ensure you have n8n credentials set up for Videotok API.\n- [ ] Configure content brief details such as 'instagram_brief', 'product_image_url', and 'goal'.\n\n### Customization\n\nYou can customize the payload structure within the 'Build Instagram Payloads' node to suit different Instagram content strategies.",
        "width": 480,
        "height": 720
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-1232, 0],
      "id": "c50abd89-14dc-461b-b720-94ea4d402285",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Trigger and set content brief\n\nInitial trigger and setting of Instagram content details.",
        "width": 464,
        "height": 304,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-672, 0],
      "id": "04048b79-46a7-46bf-8d6d-5253d985b882",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Generate content using OpenAI\n\nSend details to OpenAI for content generation.",
        "width": 816,
        "height": 272,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-128, 16],
      "id": "9d20e53b-0659-4fdd-a3ce-bdabb80c337b",
      "name": "Sticky Note2"
    },
    {
      "parameters": {},
      "id": "manual",
      "name": "When Manually Triggered",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-624, 128]
    },
    {
      "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": "Set Instagram Brief",
      "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\":\"Turn this Instagram brief into strict JSON with reel_prompt, carousel_prompt, caption, slide_outline, hashtags. Input: \" + JSON.stringify($json)}"
      },
      "id": "openai-instagram",
      "name": "Submit to OpenAI API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-80, 128]
    },
    {
      "parameters": {
        "jsCode": "const source = $('Set Instagram 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 Instagram Content",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [224, 128]
    },
    {
      "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": "Send to Videotok API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [544, 128]
    }
  ],
  "connections": {
    "When Manually Triggered": {
      "main": [
        [
          {
            "node": "Set Instagram Brief",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Instagram Brief": {
      "main": [
        [
          {
            "node": "Submit to OpenAI API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit to OpenAI API": {
      "main": [
        [
          {
            "node": "Prepare Instagram Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Instagram Content": {
      "main": [
        [
          {
            "node": "Send to Videotok API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": ["videotok", "openai", "instagram", "reels", "carousels"],
  "active": false,
  "versionId": "videotok-instagram-reels-carousel-studio-1"
}
