{
  "name": "Create Videotok carousels from a social content calendar",
  "nodes": [
    {
      "parameters": {
        "content": "## Create Videotok carousels from a social content calendar\n\n### How it works\n\n1. Initiates when a social content calendar row is marked as approved.\n2. Sets relevant details from the calendar row for processing.\n3. Uses OpenAI to generate a creative brief for a video carousel.\n4. Prepares and sends a payload to the Videotok API to create the slideshow.\n5. Waits for a set period before checking the status of the created slideshow.\n6. Updates the social content calendar with the slideshow data.\n\n### Setup steps\n\n- [ ] Configure calendar approval trigger.\n- [ ] Set up API credentials for OpenAI and Videotok.\n\n### Customization\n\nAdjust the waiting time or API endpoints to suit different conditions.",
        "width": 480,
        "height": 704
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-1232, 0],
      "id": "5269454b-d583-4df1-b552-3166087bcf22",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Prepare and send API requests\n\nSets up details for processing and communicates with OpenAI to generate brief. Triggers workflow on calendar row approval.",
        "width": 736,
        "height": 304,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-672, 0],
      "id": "18bbbf6f-61e4-40c6-a211-91cef0c08972",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Slideshow payload and creation\n\nBuilds payload and sends to Videotok API to create slideshow.",
        "width": 480,
        "height": 304,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [160, 0],
      "id": "31809b79-7bca-4eac-807e-2cb92e391f78",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Wait and fetch results\n\nWaits before checking status and updating calendar with the results.",
        "width": 704,
        "height": 272,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [720, 16],
      "id": "95632ba3-1a34-46ad-9a9b-76bc1542d79e",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 */6 * * *"
            }
          ]
        }
      },
      "id": "schedule",
      "name": "When Approval Received",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [-624, 128]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "topic",
              "name": "topic",
              "type": "string",
              "value": "Five mistakes killing your paid social creative"
            },
            {
              "id": "campaign",
              "name": "campaign",
              "type": "string",
              "value": "Q3 creative engineering campaign"
            },
            {
              "id": "product",
              "name": "product_image_url",
              "type": "string",
              "value": "https://example.com/product.png"
            }
          ]
        }
      },
      "id": "calendar-row",
      "name": "Set Content 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\":\"Turn this content calendar row into JSON for a 6-slide social carousel. Include title, prompt, product_context, caption, hashtags. Row: \" + JSON.stringify($json)}"
      },
      "id": "openai-carousel",
      "name": "Send Brief to OpenAI API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-80, 128]
    },
    {
      "parameters": {
        "jsCode": "const row = $('Set Content Details').first().json;\nconst raw = $input.first().json.output_text || '{}';\nlet brief;\ntry { brief = JSON.parse(raw); } catch { brief = { title: row.topic, prompt: raw, product_context: row.campaign, caption: raw.slice(0, 220), hashtags: '#videotok #socialmedia' }; }\nreturn [{ json: { ...brief, product_image_url: row.product_image_url, idempotency_key: `calendar-carousel-${$execution.id}` } }];"
      },
      "id": "prepare",
      "name": "Prepare Slideshow Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [208, 128]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://videotok.app/api/v1/slideshows",
        "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": "={\"title\":$json.title,\"prompt\":$json.prompt,\"slide_count\":6,\"aspect_ratio\":\"4:5\",\"product_image_urls\":[$json.product_image_url],\"brand_kit_id\":$vars.VIDEOTOK_BRAND_KIT_ID,\"language\":\"English\",\"product_context\":$json.product_context,\"generate_text_overlays\":false,\"idempotency_key\":$json.idempotency_key}"
      },
      "id": "create-slideshow",
      "name": "Send to Videotok for Slideshow",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [496, 128]
    },
    {
      "parameters": {
        "amount": 120,
        "unit": "seconds"
      },
      "id": "wait",
      "name": "Wait 2 Minutes",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [768, 128]
    },
    {
      "parameters": {
        "url": "=https://videotok.app/api/v1/slideshows/{{$json.slideshow_id}}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.VIDEOTOK_API_KEY}}"
            }
          ]
        }
      },
      "id": "poll",
      "name": "Get Slideshow Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1024, 128]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "caption",
              "name": "suggested_caption",
              "type": "string",
              "value": "={{$('Prepare Slideshow Data').first().json.caption}}"
            },
            {
              "id": "url",
              "name": "videotok_url",
              "type": "string",
              "value": "={{$json.url}}"
            }
          ]
        }
      },
      "id": "handoff",
      "name": "Update Calendar with Output",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1280, 128]
    }
  ],
  "connections": {
    "When Approval Received": {
      "main": [
        [
          {
            "node": "Set Content Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Content Details": {
      "main": [
        [
          {
            "node": "Send Brief to OpenAI API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Brief to OpenAI API": {
      "main": [
        [
          {
            "node": "Prepare Slideshow Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Slideshow Data": {
      "main": [
        [
          {
            "node": "Send to Videotok for Slideshow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to Videotok for Slideshow": {
      "main": [
        [
          {
            "node": "Wait 2 Minutes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 Minutes": {
      "main": [
        [
          {
            "node": "Get Slideshow Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Slideshow Status": {
      "main": [
        [
          {
            "node": "Update Calendar with Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": ["videotok", "openai", "content calendar", "carousel"],
  "active": false,
  "versionId": "videotok-social-calendar-carousel-machine-1"
}
