{
  "nodes": [
    {
      "id": "97dcf679-2312-4f61-aff2-ca1fe05ed94b",
      "name": "HeyGen",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        -440,
        -260
      ],
      "parameters": {
        "url": "https://api.heygen.com/v2/video/generate",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "jsonBody": "={\n  \"video_inputs\": [\n    {\n      \"character\": {\n        \"type\": \"avatar\",\n        \"avatar_id\": \"{{ $json.AvatarId ?? \"Amy_standing_outdoor_side\"}}\",\n        \"avatar_style\": \"normal\"\n      },\n      \"voice\": {\n        \"type\": \"text\",\n        \"input_text\": \"{{ $json.full_script }}\",\n        \"voice_id\": \"{{ $json.HeygenVoiceId ?? '26b2064088674c80b1e5fc5ab1a068eb' }}\"\n      },\n      \"background\": {\n        \"type\": \"color\",\n        \"value\": \"#000000\"\n      }\n    }\n],\n  \"dimension\": {\"width\": \"340\",\"height\": \"340\"}\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "660db08f-5b5c-4fd0-aa3b-660619108a1a",
      "name": "Wait4",
      "type": "n8n-nodes-base.wait",
      "position": [
        -140,
        -280
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "32126f57-2d00-465a-a642-3fbecd96943d",
      "name": "HeyGen : Check Video",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        80,
        -280
      ],
      "parameters": {
        "url": "https://api.heygen.com/v1/video_status.get",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "video_id",
              "value": "={{ $('HeyGen').first().json.data.video_id }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "157b890c-9684-4695-b110-5a94cc044ccd",
      "name": "heygen_response",
      "type": "n8n-nodes-base.switch",
      "position": [
        380,
        -300
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "completed",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "completed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "processing",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "46dfa599-fe04-4b32-8d15-09e963099737",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.data.status == 'processing' || $json.data.status == 'pending' || $json.data.status == 'waiting' }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "failed",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "22c93926-40a2-49ef-b8f0-aa718da00792",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "failed"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "a4fe631d-58df-4760-9d25-22199f3a6530",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -40
      ],
      "parameters": {
        "width": 390,
        "height": 80,
        "content": "## HeyGen APi generate Video"
      },
      "typeVersion": 1
    },
    {
      "id": "7867d3bd-d03c-41b3-909b-b1a6540023a7",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -840,
        -740
      ],
      "parameters": {
        "width": 500,
        "height": 380,
        "content": "# AdamCrafts\n\nHey there! I'm Adam. \ud83d\ude80 I specialize in helping people master n8n, land their first client, and scale their automation business efficiently. Let's automate your success!\n\n## Need Help? \ud83d\udcde\n Detailed documentation included in the workflow package covers advanced configuration options and optimization techniques.\n\n\n\u2764\ufe0f Buy more workflows at: [adamcrafts](https://adamcrafts.cloudysoftwares.com)\n\ud83e\uddbe Custom workflows at: [adamcrafts@cloudysoftwares.com](mailto:adamcrafts@cloudysoftwares.com)\n[adamaicrafts@gmail.com](mailto:adamaicrafts@gmail.com)"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait4": {
      "main": [
        [
          {
            "node": "HeyGen : Check Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HeyGen": {
      "main": [
        [
          {
            "node": "Wait4",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "heygen_response": {
      "main": [
        [],
        [
          {
            "node": "Wait4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HeyGen : Check Video": {
      "main": [
        [
          {
            "node": "heygen_response",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  }
}