AutomationFlowsAI & RAG › Generate and Publish AI Home Cam Shorts with Openai, Kie.ai and Youtube

Generate and Publish AI Home Cam Shorts with Openai, Kie.ai and Youtube

Byayo.o @flowgramming101 on n8n.io

This workflow runs three times daily to generate an AI “home cam” short video concept with OpenAI, create the video via kie.ai, then download and archive it to Google Drive, upload it to YouTube as a public video, and send a confirmation email via Gmail. Runs on a schedule three…

Cron / scheduled trigger★★★★☆ complexityAI-powered23 nodesAgentOpenAI ChatMemory Buffer WindowTool ThinkOutput Parser StructuredHTTP RequestGoogle DriveYouTube
AI & RAG Trigger: Cron / scheduled Nodes: 23 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #16439 — we link there as the canonical source.

This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "3tTWToiNywXNNrfN",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true,
    "templateCredsSetupCompleted": true
  },
  "name": "Generate and publish AI home cam videos to YouTube automatically",
  "tags": [],
  "nodes": [
    {
      "id": "ec753abe-3c90-4844-997b-5e7551b31456",
      "name": "Configure Workflow Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        896,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "config-001",
              "name": "notificationEmail",
              "type": "string",
              "value": "REPLACE_WITH_YOUR_EMAIL"
            },
            {
              "id": "config-002",
              "name": "googleDriveFolderId",
              "type": "string",
              "value": "REPLACE_WITH_YOUR_GOOGLE_DRIVE_FOLDER_ID"
            },
            {
              "id": "config-003",
              "name": "callbackUrl",
              "type": "string",
              "value": "https://your-domain.com/api/callback"
            },
            {
              "id": "config-004",
              "name": "videoIdeaMin",
              "type": "string",
              "value": "1"
            },
            {
              "id": "config-005",
              "name": "videoIdeaMax",
              "type": "string",
              "value": "50"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "46525bd2-482e-47ad-bad9-377f54315946",
      "name": "Trigger on Schedule (3x Daily)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        704,
        896
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            },
            {
              "triggerAtHour": 12
            },
            {
              "triggerAtHour": 18
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "886c2199-6cd8-4a11-835e-b975e584f230",
      "name": "Pick Idea At Random",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        896
      ],
      "parameters": {
        "jsCode": "const min = parseInt($('Configure Workflow Variables').item.json.videoIdeaMin) || 1;\nconst max = parseInt($('Configure Workflow Variables').item.json.videoIdeaMax) || 50;\nconst randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;\nreturn [{ json: { randomNumber } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "81ecb20e-a886-4b63-b6f7-3b8600762826",
      "name": "Generate Video Script and Metadata",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1280,
        896
      ],
      "parameters": {
        "text": "=Generate a JSON object for video scenario number {{ $json.randomNumber }}. Return ONLY valid JSON with no markdown formatting, no code blocks, no explanations - just the raw JSON object.",
        "options": {
          "systemMessage": "=CRITICAL: Your response must be ONLY the JSON object. Do not include markdown code blocks or any text outside the JSON.\n\nYou are an AI that generates random video prompts for short form content of a person.\nYour ONLY output must strictly follow this JSON structure:\n{\n  \"output\": {\n    \"title\": \"Dog Caught on Home Cam Raiding Trash\",\n    \"description\": \"Watch as a sneaky dog gets caught on camera raiding the trash.\",\n    \"prompt\": \"Home security camera footage showing a dog trying to get into a trash can.\",\n    \"tags\": [\"dog caught on camera\", \"funny pets\", \"home security footage\"]\n  }\n}\n\nGuidelines:\n- Title: short, catchy, includes keywords like \"Caught on Camera\" or \"Home Cam Footage\"\n- Description: 1-3 sentences, fun and engaging\n- Prompt: detailed AI video generation description, at least 5 sentences\n- Tags: 6-10 SEO-friendly tags\n- Never repeat a scenario, cycle through all 50 scenarios\n- Never break JSON format\n\nPrimary video types: Dog Shenanigans (scenarios 1-15), Cat Antics (scenarios 16-30), General Home Mishaps (scenarios 31-50). Pick based on the scenario number provided."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "086563c3-ddbc-4b01-8a69-260b0654f0f9",
      "name": "OpenAI GPT-4 Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1072,
        1152
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0ee59415-ab76-44b7-9028-11e164e26e1a",
      "name": "Conversation Memory Buffer",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1200,
        1232
      ],
      "parameters": {
        "sessionKey": "=23152",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "757cdcbe-8bda-403d-8025-9672e36b9f6e",
      "name": "Think Through Video Concept",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1360,
        1312
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "a04f997d-7a8b-49b8-872a-b04469592376",
      "name": "Validate Video Script JSON",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1440,
        1152
      ],
      "parameters": {
        "autoFix": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"title\": { \"type\": \"string\" },\n    \"description\": { \"type\": \"string\" },\n    \"prompt\": { \"type\": \"string\" },\n    \"tags\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n  },\n  \"required\": [\"title\", \"description\", \"prompt\", \"tags\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "01263e72-4c7b-4fd3-a696-dc45329bb1eb",
      "name": "Prepare Video Generation Request",
      "type": "n8n-nodes-base.code",
      "position": [
        1744,
        896
      ],
      "parameters": {
        "jsCode": "const aiOutput = $input.first().json.output;\nconst callbackUrl = $('Configure Workflow Variables').item.json.callbackUrl;\n\nconst requestBody = {\n  model: \"sora-2-text-to-video\",\n  callBackUrl: callbackUrl,\n  input: {\n    prompt: aiOutput.prompt,\n    aspect_ratio: \"portrait\",\n    n_frames: \"10\",\n    remove_watermark: true\n  }\n};\n\nreturn [{\n  json: {\n    requestBody: requestBody,\n    aiOutput: aiOutput\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "3edecf94-e655-4e7e-84ee-5db0a3735954",
      "name": "Submit Video to kie.ai",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1968,
        896
      ],
      "parameters": {
        "url": "https://api.kie.ai/api/v1/jobs/createTask",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"sora-2-text-to-video\",\n  \"callBackUrl\": \"{{ $('Configure Workflow Variables').item.json.callbackUrl }}\",\n  \"input\": {\n    \"prompt\": \"{{ $json.requestBody.input.prompt }}\",\n    \"aspect_ratio\": \"portrait\",\n    \"n_frames\": \"10\",\n    \"remove_watermark\": true\n  }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.3
    },
    {
      "id": "a32dd3ea-fda3-407e-90a0-2d02f4612eaf",
      "name": "Wait for Video Generation",
      "type": "n8n-nodes-base.wait",
      "position": [
        2192,
        896
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "0a8bff48-37d7-4a4c-87a9-74eab0e202d9",
      "name": "Poll kie.ai for Video Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2416,
        832
      ],
      "parameters": {
        "url": "https://api.kie.ai/api/v1/jobs/recordInfo",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "taskId",
              "value": "={{ $json.data.taskId }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "5f922e03-ee1c-4ed9-8d06-6068e8bbb2ab",
      "name": "Check if Video is Ready",
      "type": "n8n-nodes-base.if",
      "position": [
        2640,
        896
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ad118c28-cbe3-45a7-a0ec-eebe27319304",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.state }}",
              "rightValue": "success"
            },
            {
              "id": "62bc50b6-34e8-41f4-b646-a791043f04d5",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.resultJson }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f8f2bebe-34ec-4dc3-8a62-433765a9b756",
      "name": "Extract Video Download URL",
      "type": "n8n-nodes-base.code",
      "position": [
        2864,
        896
      ],
      "parameters": {
        "jsCode": "const response = $input.first().json;\nconst resultData = JSON.parse(response.data.resultJson);\nconst cleanUrl = resultData.resultUrls[0];\nreturn [{ json: { result: cleanUrl } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "c817d61f-8206-4f8c-80da-df0682f7f963",
      "name": "Download Generated Video File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3088,
        896
      ],
      "parameters": {
        "url": "={{ $json.result }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "b8608ba4-6543-42e4-baad-8aa977470f0d",
      "name": "Upload Video to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        3312,
        704
      ],
      "parameters": {
        "name": "={{ $('Generate Video Script and Metadata').item.json.output.title }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Configure Workflow Variables').item.json.googleDriveFolderId }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "573d9db5-428c-4caa-bb3d-54f286332ed0",
      "name": "Publish Video to YouTube",
      "type": "n8n-nodes-base.youTube",
      "position": [
        3312,
        896
      ],
      "parameters": {
        "title": "={{ $('Prepare Video Generation Request').item.json.aiOutput.title }}",
        "options": {
          "tags": "={{ $('Prepare Video Generation Request').item.json.aiOutput.tags.join(',') }}",
          "description": "={{ $('Prepare Video Generation Request').item.json.aiOutput.description }}",
          "privacyStatus": "public",
          "notifySubscribers": true
        },
        "resource": "video",
        "operation": "upload",
        "categoryId": "15",
        "regionCode": "US"
      },
      "typeVersion": 1
    },
    {
      "id": "dc2d4c94-26cc-47de-abe5-429fd1618b16",
      "name": "Send Video Notification Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3312,
        1088
      ],
      "parameters": {
        "sendTo": "={{ $('Configure Workflow Variables').item.json.notificationEmail }}",
        "message": "=<h2>Your YouTube Shorts video is ready</h2>\n<p>Your AI-generated home cam video has been successfully created and uploaded.</p>\n<p><strong>Prompt used:</strong><br>{{ $('Prepare Video Generation Request').item.json.requestBody.input.prompt }}</p>\n<p>Video link:<br><a href=\"{{ $('Extract Video Download URL').item.json.result }}\">{{ $('Extract Video Download URL').item.json.result }}</a></p>\n<p>The video has been saved to Google Drive and published to YouTube.</p>",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {}
            ]
          }
        },
        "subject": "Your YouTube Shorts video is ready"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "7f39f1fe-4247-4a32-ba3e-e7c1e002a093",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        672
      ],
      "parameters": {
        "width": 912,
        "height": 944,
        "content": "## Generate and publish AI home cam videos to YouTube automatically\n\n### How it works\n\n1. The workflow triggers three times daily (8am, 12pm, 6pm).\n2. Pick Idea At Random selects a random number between 1 and 50.\n3. Generate Video Script and Metadata uses OpenAI to create a title, description, tags, and video prompt.\n4. Prepare Video Generation Request formats the kie.ai API payload.\n5. Submit Video to kie.ai sends the prompt to generate the video.\n6. The workflow polls every 30 seconds until the video is ready.\n7. The finished video is downloaded, uploaded to Google Drive, and published to YouTube.\n8. A confirmation email is sent with the video link.\n\n### Setup steps\n\n- [ ] Add your kie.ai API key as HTTP Header Auth credentials.\n- [ ] Connect OpenAI, Google Drive, YouTube, and Gmail credentials.\n- [ ] Open the Configure Workflow Variables node and set:\n  - notificationEmail \u2014 your email address\n  - googleDriveFolderId \u2014 your Drive folder ID\n  - callbackUrl \u2014 your domain callback URL (optional)\n- [ ] Activate the workflow.\n\n### Customization\n\n- Increase videoIdeaMax beyond 50 to expand your scenario pool.\n- Change privacyStatus from \"public\" to \"private\" to review before publishing.\n- Add a Google Sheets node to log all published videos."
      },
      "typeVersion": 1
    },
    {
      "id": "b75a4a29-fc20-496a-86f5-3b154b8c6ed9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        144
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 768,
        "height": 368,
        "content": "## Configure here first\n\nSet your email, Google Drive folder ID, and callback URL in this node before activating the workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "7d5ca866-c922-4df6-ac5e-d34c5dc6a214",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        656
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 1088,
        "height": 768,
        "content": "## Generate video concept\n\nThe scheduler fires three times daily. A random scenario number seeds the OpenAI agent, which returns a title, description, video prompt, and tags as structured JSON."
      },
      "typeVersion": 1
    },
    {
      "id": "8d9e2fd5-70c6-4280-b0a1-525d4745ea4c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        704
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 1088,
        "height": 624,
        "content": "## Generate and poll video\n\nThe prompt is sent to kie.ai's Sora-2 API. The workflow waits 30 seconds between each poll until the video status returns as successful and a download URL is available."
      },
      "typeVersion": 1
    },
    {
      "id": "45be54ec-c9ff-4e6c-b184-f3a09db9288b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        544
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 832,
        "height": 784,
        "content": "## Publish and notify\n\nThe video is downloaded, archived to Google Drive, and published to YouTube with AI-generated metadata. A notification email is sent with the video link."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "callerPolicy": "workflowsFromSameOwner",
    "timeSavedMode": "fixed",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "e9a8c05c-e808-489e-9e93-23c7acbe3f98",
  "connections": {
    "OpenAI GPT-4 Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Video Script and Metadata",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Validate Video Script JSON",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pick Idea At Random": {
      "main": [
        [
          {
            "node": "Generate Video Script and Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit Video to kie.ai": {
      "main": [
        [
          {
            "node": "Wait for Video Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Video is Ready": {
      "main": [
        [
          {
            "node": "Extract Video Download URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Video Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Video Generation": {
      "main": [
        [
          {
            "node": "Poll kie.ai for Video Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory Buffer": {
      "ai_memory": [
        [
          {
            "node": "Generate Video Script and Metadata",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Extract Video Download URL": {
      "main": [
        [
          {
            "node": "Download Generated Video File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Video Script JSON": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Video Script and Metadata",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Think Through Video Concept": {
      "ai_tool": [
        [
          {
            "node": "Generate Video Script and Metadata",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Configure Workflow Variables": {
      "main": [
        [
          {
            "node": "Pick Idea At Random",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Poll kie.ai for Video Status": {
      "main": [
        [
          {
            "node": "Check if Video is Ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Generated Video File": {
      "main": [
        [
          {
            "node": "Upload Video to Google Drive",
            "type": "main",
            "index": 0
          },
          {
            "node": "Publish Video to YouTube",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Video Notification Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger on Schedule (3x Daily)": {
      "main": [
        [
          {
            "node": "Configure Workflow Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Video Generation Request": {
      "main": [
        [
          {
            "node": "Submit Video to kie.ai",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Video Script and Metadata": {
      "main": [
        [
          {
            "node": "Prepare Video Generation Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow runs three times daily to generate an AI “home cam” short video concept with OpenAI, create the video via kie.ai, then download and archive it to Google Drive, upload it to YouTube as a public video, and send a confirmation email via Gmail. Runs on a schedule three…

Source: https://n8n.io/workflows/16439/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This n8n automation workflow automates the creation, scripting, production, and posting of YouTube videos. It leverages AI (OpenAI), image generation (PIAPI), video rendering (Shotstack), and platform

Agent, OpenAI Chat, Airtable Tool +7
AI & RAG

This workflow automates the creation, rendering, approval, and posting of TikTok-style POV (Point of View) videos to Instagram, with cross-posting to Facebook and YouTube. It eliminates manual video p

OpenAI Chat, Output Parser Item List, HTTP Request +10
AI & RAG

This workflow was born out of a very real problem.

Output Parser Structured, OpenAI Chat, Memory Buffer Window +11
AI & RAG

kisisel asistan. Uses toolWorkflow, toolHttpRequest, toolCalculator, toolThink. Scheduled trigger; 43 nodes.

Tool Workflow, Tool Http Request, Tool Calculator +15
AI & RAG

This workflow automates end-to-end sustainability lifecycle management for corporate sustainability teams, ESG governance officers, and circular economy programme leads. It addresses the challenge of

Form Trigger, Agent, OpenAI Chat +11