{
  "name": "HeyGen AI Clone - Video Generator",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        -160,
        0
      ],
      "id": "b736abde-a578-4429-b67c-ad0b03080e42",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        -380,
        0
      ],
      "id": "6fd746df-4d2e-44c8-bdfb-edca0ca632a1",
      "name": "When chat message received",
      "webhookId": "cc6dd752-7c76-4432-a720-ec10bfd94f39"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -200,
        220
      ],
      "id": "e53a0bd6-4c4d-4dab-9134-bb0984e320c1",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "zYg0KgMMXrOhQrfL",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        440,
        0
      ],
      "id": "bccb34bd-25ac-4f7a-a707-fb2f656e11b3",
      "name": "Wait",
      "webhookId": "9ec7b881-551a-4d3c-bf75-e2b4fcb9b650"
    },
    {
      "parameters": {
        "url": "https://api.heygen.com/v1/video_status.get",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "video_id",
              "value": "={{ $('Generate video').item.json.data.video_id }}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "YjU2ZDFlNmZkYzdjNDUyYmI4NTVmNTNkZmQ2YTIwZDItMTc0MjU5MjA3Mw=="
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ],
      "id": "992c8cae-bd0b-4e19-859c-1a80eb3b7d1c",
      "name": "Check video status"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.heygen.com/v2/video/generate",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "YjU2ZDFlNmZkYzdjNDUyYmI4NTVmNTNkZmQ2YTIwZDItMTc0MjU5MjA3Mw=="
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"video_inputs\": [\n    {\n      \"character\": {\n        \"type\": \"avatar\",\n        \"avatar_id\": \"c9b8cf8ebc9c46a6bd83a253edff0418\",\n        \"avatar_style\": \"normal\"\n      },\n      \"voice\": {\n        \"type\": \"text\",\n        \"input_text\": \"{{ $json.chatInput }}\",\n        \"voice_id\": \"eacb845712934bc5b72d70e1bc58e84f\",\n        \"speed\": 1.1\n      }\n    }\n  ],\n  \"dimension\": {\n    \"width\": 1280,\n    \"height\": 720\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ],
      "id": "da5a9380-50ce-4954-ac5b-cd83df24681b",
      "name": "Generate video"
    },
    {
      "parameters": {
        "url": "={{ $json.data.video_url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        0
      ],
      "id": "599ee30d-2f52-4ce4-a3cb-75fd76389e81",
      "name": "Download video"
    }
  ],
  "pinData": {},
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Generate video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Check video status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check video status": {
      "main": [
        [
          {
            "node": "Download video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate video": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download video": {
      "main": [
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6a304d7d-c5b9-4d22-91f4-09a394bf1548",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "1ea7c159eb092e964233f8c9f4291a4e36acd924ecd847fc9d1838730336a33f"
  },
  "id": "mrIPpQgA4uKPsweG",
  "tags": []
}