{
  "name": "AI Shorts Automation PRO",
  "nodes": [
    {
      "parameters": {
        "triggerTimes": [
          {
            "hour": 2,
            "minute": 0
          },
          {
            "hour": 10,
            "minute": 0
          },
          {
            "hour": 18,
            "minute": 0
          }
        ]
      },
      "id": "cron",
      "name": "Trigger 3x Daily",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://www.producthunt.com/feed"
      },
      "id": "rss",
      "name": "Fetch AI Tools",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [
        400,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 3
      },
      "id": "split",
      "name": "Process Multiple Tools",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        600,
        300
      ]
    },
    {
      "parameters": {
        "operation": "lookup",
        "sheetId": "YOUR_SHEET_ID",
        "range": "A:A",
        "lookupColumn": "tool_name",
        "lookupValue": "={{$json[\"title\"]}}"
      },
      "id": "check-duplicate",
      "name": "Check Duplicate",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        800,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$json[\"rowIndex\"]}}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "id": "if-not-duplicate",
      "name": "If Not Duplicate",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1000,
        300
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "prompt": "Extract tool name. Then:\n1. Give viral score (1-10)\n2. If score >7 create a 30-sec viral script with strong hook\n\nContent:\n{{$json[\"title\"]}} {{$json[\"contentSnippet\"]}}"
      },
      "id": "script+score",
      "name": "Script + Viral Score",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        1200,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"choices\"][0][\"text\"].match(/\\d+/)[0]}}",
              "operation": "larger",
              "value2": 7
            }
          ]
        }
      },
      "id": "viral-filter",
      "name": "Only Viral (>7)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1400,
        300
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "prompt": "Create a viral YouTube Shorts title, description with emojis, and 10 hashtags.\n\nIMPORTANT: Output strictly a raw JSON object with two keys: \"title\" (max 80 chars) and \"description\" (which includes the description and hashtags). Do NOT wrap the JSON in markdown code blocks.\n\nScript:\n{{$json[\"choices\"][0][\"text\"]}}"
      },
      "id": "meta",
      "name": "Generate SEO + Emojis",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        1600,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://api.heygen.com/v2/video/generate",
        "jsonParameters": true,
        "bodyParametersJson": "{\n\"script\": \"{{$node[\"Script + Viral Score\"].json[\"choices\"][0][\"text\"]}}\",\n\"captions\": true,\n\"avatar_id\": \"YOUR_AVATAR_ID\"\n}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "YOUR_HEYGEN_API_KEY"
            }
          ]
        }
      },
      "id": "video",
      "name": "Generate Video (Captions ON)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1800,
        300
      ]
    },
    {
      "parameters": {
        "operation": "upload",
        "title": "={{JSON.parse($node[\"Generate SEO + Emojis\"].json[\"choices\"][0][\"text\"]).title}}",
        "additionalFields": {
          "description": "={{JSON.parse($node[\"Generate SEO + Emojis\"].json[\"choices\"][0][\"text\"]).description}}",
          "tags": [
            "ai",
            "automation",
            "shorts"
          ]
        }
      },
      "id": "youtube",
      "name": "Upload to YouTube",
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [
        2800,
        200
      ],
      "credentials": {
        "youtubeOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "YOUR_SHEET_ID",
        "range": "A:A",
        "options": {},
        "valueInputMode": "RAW",
        "data": [
          {
            "tool_name": "={{$json[\"title\"]}}"
          }
        ]
      },
      "id": "save-tool",
      "name": "Save to Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        3000,
        200
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "minutes"
      },
      "id": "wait-heygen",
      "name": "Wait for Rendering",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        2000,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://api.heygen.com/v1/video_status.get",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "video_id",
              "value": "={{$node[\"Generate Video (Captions ON)\"].json[\"data\"][\"video_id\"]}}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "YOUR_HEYGEN_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "id": "check-status",
      "name": "Check Video Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        2200,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"data\"][\"status\"]}}",
              "operation": "equal",
              "value2": "completed"
            }
          ]
        }
      },
      "id": "if-video-completed",
      "name": "If Video Completed",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        2400,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{$json[\"data\"][\"video_url\"]}}",
        "responseFormat": "file",
        "options": {}
      },
      "id": "download-video",
      "name": "Download Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        2600,
        200
      ]
    }
  ],
  "connections": {
    "Trigger 3x Daily": {
      "main": [
        [
          {
            "node": "Fetch AI Tools",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch AI Tools": {
      "main": [
        [
          {
            "node": "Process Multiple Tools",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Multiple Tools": {
      "main": [
        [
          {
            "node": "Check Duplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Duplicate": {
      "main": [
        [
          {
            "node": "If Not Duplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Not Duplicate": {
      "main": [
        [
          {
            "node": "Script + Viral Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Script + Viral Score": {
      "main": [
        [
          {
            "node": "Only Viral (>7)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only Viral (>7)": {
      "main": [
        [
          {
            "node": "Generate SEO + Emojis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate SEO + Emojis": {
      "main": [
        [
          {
            "node": "Generate Video (Captions ON)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Video (Captions ON)": {
      "main": [
        [
          {
            "node": "Wait for Rendering",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to YouTube": {
      "main": [
        [
          {
            "node": "Save to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Rendering": {
      "main": [
        [
          {
            "node": "Check Video Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Video Status": {
      "main": [
        [
          {
            "node": "If Video Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Video Completed": {
      "main": [
        [
          {
            "node": "Download Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Rendering",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video": {
      "main": [
        [
          {
            "node": "Upload to YouTube",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}