This commit is contained in:
nusquama
2025-11-12 19:01:53 +01:00
parent 52f0cf165e
commit 33cdeddea8
@@ -0,0 +1,368 @@
Generate Viral CCTV Animal Videos using GPT and Veo3 AI for TikTok
https://n8nworkflows.xyz/workflows/generate-viral-cctv-animal-videos-using-gpt-and-veo3-ai-for-tiktok-9184
# Generate Viral CCTV Animal Videos using GPT and Veo3 AI for TikTok
### 1. Workflow Overview
This workflow automates the creation and publishing of viral CCTV-style animal videos for TikTok using AI technologies. It leverages OpenAI GPT models and the Veo3 AI video generation API to produce hyper-realistic, security camera-style animal videos with engaging titles and hashtags optimized for social media virality.
**Target Use Cases:**
- Automated viral video content creation for social media marketing, especially TikTok.
- Generating themed animal videos with a realistic CCTV aesthetic.
- Streamlining video generation, metadata creation, upload, and posting processes.
**Logical Blocks:**
- **1.1 Scheduled Trigger & Prompt Generation:** Periodically triggers the workflow and generates detailed video prompts using GPT.
- **1.2 Video Generation & Status Polling:** Sends the prompt to Veo3 AI for video creation, waits, and polls for completion status.
- **1.3 Content Metadata Creation:** Generates TikTok-optimized titles and hashtags based on the video prompt using GPT.
- **1.4 Data Storage & Media Upload:** Inserts metadata and video URLs into a data table and uploads media to Blotato.
- **1.5 TikTok Posting & Status Update:** Creates and publishes the TikTok post, updates data table status, and sends the video on Telegram for notification.
---
### 2. Block-by-Block Analysis
---
#### 2.1 Scheduled Trigger & Prompt Generation
**Overview:**
This block initiates the workflow every 4 hours, generating a hyper-realistic CCTV security camera style prompt for viral animal footage. It dynamically selects or accepts animal, location, and action inputs, creating a JSON output with image and video prompts.
**Nodes Involved:**
- Schedule Trigger
- Prompt for CCTV (OpenAI GPT-5 Chat)
**Node Details:**
- **Schedule Trigger**
- Type: Schedule Trigger
- Role: Initiates the workflow every 4 hours automatically.
- Configuration: Interval set to every 4 hours.
- Inputs: None (trigger node)
- Outputs: Connected to "Prompt for CCTV" node.
- Edge Cases: Workflow wont start if n8n instance is down at scheduled time.
- **Prompt for CCTV**
- Type: OpenAI GPT Chat Node (LangChain)
- Role: Generates detailed CCTV-style image and video prompts based on input or random animal, location, and action selections.
- Configuration: Uses GPT-5-chat-latest model with a complex prompt template including fallback arrays for animal names, locations, and actions if inputs are missing. Prompts include requirements for CCTV aesthetics like grainy black & white, timestamp overlays, infrared lighting, and motion blur.
- Key Expressions: Uses JavaScript expressions to select random animal/location/action if not provided in JSON input; formats timestamps dynamically; constructs JSON output with `image_prompt` and `video_prompt`.
- Inputs: Trigger from Schedule Trigger node.
- Outputs: JSON output sent to "Video Creation" node.
- Edge Cases: Possible failures include OpenAI authentication errors, invalid prompt formatting, or API timeout.
---
#### 2.2 Video Generation & Status Polling
**Overview:**
This block sends the AI-generated video prompt to the Veo3 API for video creation, waits for the video to be generated, and polls the API to check for completion.
**Nodes Involved:**
- Video Creation (HTTP Request)
- Wait
- Get the Status (HTTP Request)
- If (Conditional)
**Node Details:**
- **Video Creation**
- Type: HTTP Request
- Role: Sends POST request to Veo3 AI API to initiate video generation using the video prompt from GPT.
- Configuration:
- URL: https://api.kie.ai/api/v1/veo/generate
- Method: POST
- Body: JSON with prompt, model "veo3_fast", aspectRatio "9:16"
- Headers: Authorization bearer token from Veo API credentials
- Batching: batchSize 1
- Inputs: Receives prompt from "Prompt for CCTV" node.
- Outputs: Task info (including taskId) sent to "Wait" node.
- Edge Cases: API errors, invalid API key, network issues.
- **Wait**
- Type: Wait
- Role: Pauses workflow execution for a defined time to allow video processing.
- Configuration: Wait for a configurable number of minutes (default unit: minutes).
- Inputs: Receives task info from "Video Creation" or "Get the Status" nodes.
- Outputs: Proceeds to "Get the Status" HTTP request node.
- Edge Cases: Misconfiguration causing too short or too long wait times.
- **Get the Status**
- Type: HTTP Request
- Role: Queries Veo3 API to check if video generation task has completed.
- Configuration:
- URL: https://api.kie.ai/api/v1/veo/record-info
- Query parameter: taskId from previous response
- Headers: Authorization bearer token from Veo API credentials
- Inputs: Receives taskId from "Wait" node output.
- Outputs: Response JSON with status sent to "If" node.
- Edge Cases: API errors, invalid taskId, network failures.
- **If**
- Type: Conditional node
- Role: Checks if the video generation status message equals "success".
- Configuration: Compares `msg` field in JSON to string "success" (case-sensitive).
- Inputs: Receives status response from "Get the Status".
- Outputs:
- If true: proceeds to "Tiktok Title and Hashtags" node.
- If false: loops back to "Wait" node to poll again.
- Edge Cases: If status field changes or is missing, could cause logic failure or infinite loop.
---
#### 2.3 Content Metadata Creation
**Overview:**
Generates a TikTok-optimized title and set of hashtags based on the video prompt using a specialized GPT model chain. Output is parsed into structured JSON for downstream use.
**Nodes Involved:**
- Tiktok Title and Hashtags (Chain LLM)
- Json parser
- OpenAI Chat Model
**Node Details:**
- **Tiktok Title and Hashtags**
- Type: LangChain Chain LLM node
- Role: Analyzes the video prompt text and produces a viral TikTok title and 5 hashtags using a social media content strategist persona.
- Configuration:
- Uses GPT-4.1-mini model for generation.
- Input text is the video prompt from "Prompt for CCTV" node's video_prompt.
- Includes detailed instructions on title and hashtag creation with strict JSON output format.
- Inputs: Triggered by "If" node on successful video.
- Outputs: Machine-parseable JSON array with title and hashtags.
- Edge Cases: Output format errors causing parser failures.
- **Json parser**
- Type: Structured Output Parser (LangChain)
- Role: Parses the GPT output JSON string into structured fields for title and hashtags.
- Configuration: Uses a JSON schema example to validate output.
- Inputs: Receives raw text output from "Tiktok Title and Hashtags".
- Outputs: Parsed JSON data for "Insert row" node.
- Edge Cases: Parsing fails if GPT output deviates from expected JSON format.
- **OpenAI Chat Model**
- Type: LangChain OpenAI Chat Model
- Role: Backend language model used by "Tiktok Title and Hashtags" node.
- Configuration: GPT-4.1-mini selected.
- Inputs: Internal to chain, no direct connections.
- Outputs: Internal to chain LLM node.
---
#### 2.4 Data Storage & Media Upload
**Overview:**
Stores the video metadata and URLs in a data table, uploads the generated video to Blotato media platform, and prepares for posting.
**Nodes Involved:**
- Insert row (Data Table)
- Upload media (Blotato)
**Node Details:**
- **Insert row**
- Type: Data Table node
- Role: Inserts a new record with video title, hashtags, status ("created"), and video URL into a designated data table.
- Configuration:
- Columns: title, tags, status, video_url
- Status initialized to "created"
- Video URL extracted from "If" nodes successful response URLs.
- Table ID and Project ID from credentials.
- Inputs: Receives parsed JSON from "Tiktok Title and Hashtags".
- Outputs: Passes data to "Upload media" node.
- Edge Cases: Data table API errors, missing fields.
- **Upload media**
- Type: Blotato Media Upload node
- Role: Uploads the generated video media URL to the Blotato media platform for TikTok posting.
- Configuration: Uses video_url from data table insertion output.
- Inputs: Receives video_url from "Insert row".
- Outputs: Passes uploaded media URL to "Create post" node.
- Edge Cases: Upload failures, invalid media URL.
---
#### 2.5 TikTok Posting & Status Update
**Overview:**
Posts the uploaded video to TikTok with the generated title and hashtags, updates the data table row status to "posted," and sends the video to Telegram for notification.
**Nodes Involved:**
- Create post (Blotato TikTok)
- Update row(s) (Data Table)
- Send a video (Telegram)
**Node Details:**
- **Create post**
- Type: Blotato TikTok post node
- Role: Creates a TikTok post using the uploaded video URL and generated metadata.
- Configuration:
- Platform: TikTok
- Account ID from credentials
- Post content text combined from inserted rows title and tags
- Media URLs from uploaded video
- Flagged as AI-generated content
- Inputs: Receives media URL from "Upload media" and metadata from "Insert row".
- Outputs: Passes post confirmation to "Update row(s)".
- Edge Cases: Posting failures, API errors, invalid credentials.
- **Update row(s)**
- Type: Data Table node
- Role: Updates the status of the inserted row to "posted" after successful TikTok posting.
- Configuration: Matches row by ID from "Insert row".
- Inputs: Receives confirmation from "Create post".
- Outputs: Passes video URL to "Send a video".
- Edge Cases: Update failures, row ID mismatch.
- **Send a video**
- Type: Telegram node
- Role: Sends the final video to a Telegram chat as a notification or backup.
- Configuration:
- Operation: sendVideo
- Chat ID from Telegram credentials
- File URL from updated row video_url field
- Inputs: Receives updated row data from "Update row(s)".
- Outputs: Terminal node of workflow.
- Edge Cases: Telegram API failures, invalid chat ID, file access issues.
---
### 3. Summary Table
| Node Name | Node Type | Functional Role | Input Node(s) | Output Node(s) | Sticky Note |
|-----------------------|--------------------------------------|----------------------------------------------|------------------------------|------------------------------|----------------------------------------------------|
| Schedule Trigger | Schedule Trigger | Starts workflow every 4 hours | | Prompt for CCTV | ## Viral CCTV Camera Animals Videos |
| Prompt for CCTV | OpenAI GPT Chat (LangChain) | Generates CCTV-style image & video prompt | Schedule Trigger | Video Creation | |
| Video Creation | HTTP Request | Sends prompt to Veo3 API for video generation| Prompt for CCTV | Wait | |
| Wait | Wait | Pauses workflow awaiting video processing | Video Creation, Get the Status| Get the Status | |
| Get the Status | HTTP Request | Polls Veo3 API for video generation status | Wait | If | |
| If | Conditional | Checks if video generation succeeded | Get the Status | Tiktok Title and Hashtags, Wait| |
| Tiktok Title and Hashtags | LangChain Chain LLM | Generates TikTok title and hashtags | If | Insert row | |
| Json parser | LangChain Output Parser | Parses GPT title/hashtags JSON | Tiktok Title and Hashtags | Insert row | |
| Insert row | Data Table | Inserts video metadata & URL | Json parser | Upload media | |
| Upload media | Blotato Media Upload | Uploads video media to Blotato | Insert row | Create post | |
| Create post | Blotato TikTok Post | Posts video to TikTok | Upload media | Update row(s) | |
| Update row(s) | Data Table | Updates status to "posted" | Create post | Send a video | |
| Send a video | Telegram | Sends video to Telegram chat | Update row(s) | | |
| OpenAI Chat Model | LangChain OpenAI Model | Backend GPT model for title/hashtag generation| Internal to Tiktok Title and Hashtags | Tiktok Title and Hashtags | |
| Sticky Note7 | Sticky Note | Author contact and expertise info | | | ## Muhammad Farooq Iqbal - Automation Expert & n8n Creator ... |
| Sticky Note | Sticky Note | Workflow title header | | | ## Viral CCTV Camera Animals Videos |
---
### 4. Reproducing the Workflow from Scratch
1. **Create Schedule Trigger node**
- Type: Schedule Trigger
- Set interval to trigger every 4 hours.
2. **Add OpenAI GPT Chat node ("Prompt for CCTV")**
- Model: GPT-5-CHAT-LATEST
- Configure prompt:
- Task to generate CCTV-style viral animal footage prompts.
- Use JS expressions to select random animal, location, and action if not provided.
- Include detailed style and output format instructions.
- Enable JSON output parsing.
- Connect output of Schedule Trigger to this node.
3. **Add HTTP Request node ("Video Creation")**
- Method: POST
- URL: https://api.kie.ai/api/v1/veo/generate
- Body (JSON):
```json
{
"prompt": "{{ $json.message.content.video_prompt }}",
"model": "veo3_fast",
"aspectRatio": "9:16"
}
```
- Headers: Authorization Bearer with Veo API key credential.
- Connect output of "Prompt for CCTV" to this node.
4. **Add Wait node ("Wait")**
- Configure wait unit as minutes (customizable).
- Connect output of "Video Creation" to "Wait".
5. **Add HTTP Request node ("Get the Status")**
- Method: GET
- URL: https://api.kie.ai/api/v1/veo/record-info
- Query parameter: taskId from previous nodes JSON data.
- Headers: Authorization Bearer with Veo API key credential.
- Connect output of "Wait" to this node.
6. **Add If node ("If")**
- Condition: Check if `msg` field from "Get the Status" equals string "success".
- True branch: Proceed to "Tiktok Title and Hashtags" node.
- False branch: Loop back to "Wait" for another polling cycle.
7. **Add LangChain Chain LLM node ("Tiktok Title and Hashtags")**
- Model: GPT-4.1-mini
- Input text: Use `video_prompt` from "Prompt for CCTV".
- Provide detailed system instructions as persona of social media strategist.
- Configure output parser as JSON array with title and hashtags fields.
- Connect true branch output of "If" node here.
8. **Add LangChain Output Parser ("Json parser")**
- Use JSON schema example matching the expected title and hashtags output.
- Connect output of "Tiktok Title and Hashtags" to this node.
9. **Add Data Table node ("Insert row")**
- Configure columns: title, tags, status="created", video_url.
- Map values from parser and "If" node (video URL).
- Set Data Table and Project ID using credentials.
- Connect output of "Json parser" to this node.
10. **Add Blotato Media Upload node ("Upload media")**
- Media URL: video_url from "Insert row" output.
- Resource type: media.
- Connect output of "Insert row" to this node.
11. **Add Blotato TikTok Post node ("Create post")**
- Platform: TikTok
- Account ID: from Blotato credentials
- Post content text: concatenate title and hashtags from "Insert row".
- Media URLs: video URL from upload output.
- AI-generated flag enabled.
- Connect output of "Upload media" to this node.
12. **Add Data Table node ("Update row(s)")**
- Update status field to "posted".
- Match row by ID from "Insert row".
- Connect output of "Create post" to this node.
13. **Add Telegram node ("Send a video")**
- Operation: sendVideo
- Chat ID: from Telegram credentials
- File: video_url from "Update row(s)" output.
- Connect output of "Update row(s)" to this node.
14. **Add LangChain OpenAI Chat Model node ("OpenAI Chat Model")**
- Model: GPT-4.1-mini
- Used internally by "Tiktok Title and Hashtags" node; no direct connections needed.
15. **Add Sticky Notes** as visual annotations for workflow title and author contact.
---
### 5. General Notes & Resources
| Note Content | Context or Link |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
| Workflow designed by Muhammad Farooq Iqbal, recognized n8n Creator and automation expert specializing in AI automation and workflow optimization. Contact via email, phone, LinkedIn, or portfolio linked in sticky note. | Author contact info and expertise |
| Workflow title: "Viral CCTV Camera Animals Videos" shown in prominent sticky note for easy identification. | Workflow branding |
| Veo3 AI API documentation and credentials required for video generation: https://api.kie.ai/ | Veo API integration |
| Blotato API used for media upload and TikTok posting automation. Requires API accounts and tokens. | Blotato platform integration |
| OpenAI GPT models used: GPT-5-chat-latest for prompt generation and GPT-4.1-mini for TikTok metadata creation. Requires OpenAI API credentials with appropriate scopes. | OpenAI API integration |
| Telegram API configured for sending video notifications; requires valid Telegram Bot token and chat ID. | Telegram notification integration |
| Timestamp formatting and fallback random selection logic implemented in prompt with JavaScript expressions for dynamic and varied content generation. | Prompt dynamic content generation |
| The workflow includes looping logic to poll video generation status, allowing asynchronous processing with retry until success. | Error handling and retry mechanism |
---
**Disclaimer:** The text provided derives exclusively from an automated workflow created with n8n, a tool for integration and automation. The processing strictly adheres to applicable content policies and contains no illegal, offensive, or protected elements. All handled data are legal and public.