n8n 实操攻略 11:如何搭建 AI 解压视频工作流

10 months ago

最近经常刷到 ai 生成的解压视频,就是那种 用刀子切苹果的视频,今天用 n8n 实操演练一下如何搭建。

https://appstore.lazycat.cloud/#/shop/detail/cloud.lazycat.app.n8n

先简单看下流程图:

image.png

快速搭建节点

新建一个 ai 解压的工作流

image.png

新建一个手动触发的节点

image.png

接下来,让 ai 生成视频的内容,要给它 prompt,所以要新建一个 ai agent

image.png

image.png

它默认会生成一个chat message 节点,我们不需要,把它删掉即可

image.png

删掉之后:

image.png

新建 http 请求视频的生成

image.png

生成视频比较慢,所以加一个等待 wait

image.png

比如等待 10s 之后,再添加一个 http,去查询是否生成成功

image.png

所以要加一个 if 判断节点

image.png

如果还没生成,就继续等待,如果生成成功,才进行下一步,所以把 false 流程拖到 wait 前面

image.png

如果生成成功,我们记录一下当前时间

image.png

选第 4 个

image.png

最后一步是将记录保存到 GoogleSheets 里面

image.png

以上就是完整的流程。接下来详细讲解每一步的配置。

ai agent

在左下角的+ 是选择大模型,

image.png

我用 DeepSeek 演示 image.png

配置上你的 DeepSeek 的 APIkey 就可以了

image.png

image.png

双击进入节点,我们是自己输入 prompt,所以选第 2 个

image.png

发送的 prompt 填写:

Generate a new "Oddly Satisfying" slicing video concept.

增加一个系统身份 prompt,参考提示词:

You are a viral content strategist specializing in Oddly Satisfying 3D animation ASMR. Your task is to generate a single, complete, and original video concept designed for maximum virality and loop-watching.

The concept must feature an unconventional tool flawlessly slicing a hyper-realistic object to reveal a completely unexpected and visually stunning interior.

You must invent and concisely describe these three core elements:
1.  **The Object:** A familiar item with a unique, impossible quality.
2.  **The Tool:** A visually interesting cutting instrument, not a simple knife.
3.  **The Surprise Interior:** The key to virality—a mesmerizing material or miniature scene.

Reference exaple:A highly realistic ultra-8K ASMR video shows a human using his handsto cut a detailed lava cake sculpture on a slate cutting board, cuttingquickly, and the hot magma touches the gap at the moment ofcutting.The cake resembles volcanic rock - obsidian, slightly burntwith cracks clearly visible inside and emitting light. The camera uses ashallow depth of field close-up to capture the cinematic light anddetailed glass texture. Each cut is precise and lifelike. The sound ofmetal rubbing against rock, the sound of magma erupting, and thesound of cutting

This paragraph must be written as a direct, usable prompt. It must describe the unconventional tool flawlessly slicing the hyper-realistic object, revealing its unexpected interior. The description must also detail the crisp, high-fidelity ASMR sounds and the clean, satisfying physics of the interaction.

Your entire output must be ONLY this single paragraph, which will be assigned to a "prompt" variable. Do not add any extra words, formatting, labels, or explanations.

效果如图,把 output 验证开关打开

image.png

我们希望它输出 json 的结果

{
        "prompt": "ASMR idea"
}

image.png

执行步骤,如果 output 能看到内容,说明成功了。点击右上角 pin 一下,方便调试

image.png

http request

这个节点是生成视频的节点。这里我用的 API 是这个https://kie.ai/ Veo3 Fast 20积分/次,大概是 7 毛钱,充值之后就能用它的 API 了

这里可以看到 apikey

image.png

获取方法为参考API文档,复制网址进去,下为API文档地址 https://docs.kie.ai/veo3-api/generate-veo-3-video

image.png 选择 post 方法,地址粘贴到这里

image.png

授权方式,选择通用授权,hearder auth 的方式

image.png

创建密钥,看官方文档

image.png

所以这里这样填

image.png

打开 send body 开关

image.png

根据官方文档要求,要配置这么几个参数

image.png

name 填 prompt,value 直接把左侧的 prompt 拖过来

image.png

再添加一个参数,model,vao3_fast

image.png

执行一下,如果输出 200,说明配置成功了

image.png

将右上角 pin 住,不然又生成一遍的话,又要花钱

image.png

wait

wait 节点设置成 10 秒就行,不用特殊配置

image.png

查询视频结果

这个节点是查询视频结果,根据文档,是这个接口:

image.png

它需要传一个 taskid 获取数据

刚才生成的视频,我们是 post 请求,send body,而这里我们是 get 请求,所以是 send query

image.png

执行一下,右侧可以看到结果了

image.png

根据文档说明,如果这个 successFlag=1,就说明视频成功了

image.png

image.png

我们 pin 一下,继续下一步if 节点 这里默认是字符串,要改成 number,是否=1

image.png

最后一步是把结果存储到 Google 表格里,可参考我之前的攻略,有详细的讲解 我在 Google sheet 里新建了一个空白表格

image.png

表头可以参考:

Data	Idea	Status	Video Url

其实就去把你想要的字段保存下来

image.png

然后在 n8n 里,把对应的字段,拖动相应的列的位置

image.png

点击执行,可以看到结果了

image.png

在 Google sheets 里,可以看到插入了一条数据:

image.png

点击链接,可以看到视频:

https://lzc-playground-1301583638.cos.ap-chengdu.myqcloud.com/guidelines/496/c5fb91bf-6098-4d41-94d3-6ec06ab90642.mp4

整个工作流就完成了。

最难的点,在于 API 文档发送 post 和 get 请求的配置,如果一点没有配好,就可能有莫名其妙的问题。

完整 json 如下,同理改成你的相关配置就可以了:

      
{
  "name": "n8n航海-案例1",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
      "typeVersion": 1,
      "position": [
        -464,
        192
      ],
      "id": "2a4bfaeb-02ca-41c9-b428-0bb0965908a8",
      "name": "DeepSeek Chat Model",
      "credentials": {
        "deepSeekApi": {
          "id": "r8dE74Igj9x0N0Zo",
          "name": "Deepseek API key"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n\t\"prompt\": \"ASMR idea\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -336,
        192
      ],
      "id": "8746f7d9-84a9-42d9-80be-7c52367c6ce7",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        800,
        -48
      ],
      "id": "b522d1ba-23d2-4b6f-b352-3a18b7aac3fe",
      "name": "Date & Time"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -720,
        -48
      ],
      "id": "9433411a-6f87-4fb4-a3d0-8e61e7b06bbc",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "Generate a new \"Oddly Satisfying\" slicing video concept.",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=You are a viral content strategist specializing in Oddly Satisfying 3D animation ASMR. Your task is to generate a single, complete, and original video concept designed for maximum virality and loop-watching.\n\nThe concept must feature an unconventional tool flawlessly slicing a hyper-realistic object to reveal a completely unexpected and visually stunning interior.\n\nYou must invent and concisely describe these three core elements:\n1.  **The Object:** A familiar item with a unique, impossible quality.\n2.  **The Tool:** A visually interesting cutting instrument, not a simple knife.\n3.  **The Surprise Interior:** The key to virality—a mesmerizing material or miniature scene.\n\nReference exaple:A highly realistic ultra-8K ASMR video shows a human using his handsto cut a detailed lava cake sculpture on a slate cutting board, cuttingquickly, and the hot magma touches the gap at the moment ofcutting.The cake resembles volcanic rock - obsidian, slightly burntwith cracks clearly visible inside and emitting light. The camera uses ashallow depth of field close-up to capture the cinematic light anddetailed glass texture. Each cut is precise and lifelike. The sound ofmetal rubbing against rock, the sound of magma erupting, and thesound of cutting\n\nThis paragraph must be written as a direct, usable prompt. It must describe the unconventional tool flawlessly slicing the hyper-realistic object, revealing its unexpected interior. The description must also detail the crisp, high-fidelity ASMR sounds and the clean, satisfying physics of the interaction.\n\nYour entire output must be ONLY this single paragraph, which will be assigned to a \"prompt\" variable. Do not add any extra words, formatting, labels, or explanations."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.1,
      "position": [
        -496,
        -48
      ],
      "id": "c7b7ca25-165d-4550-a136-e6d51855c4a9",
      "name": "AI agent"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1GcD1GI8kNpqmSUd1Fp_0i-RWovoN-L56hmEDouYmqEM",
          "mode": "list",
          "cachedResultName": "0817演示",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GcD1GI8kNpqmSUd1Fp_0i-RWovoN-L56hmEDouYmqEM/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "案例1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GcD1GI8kNpqmSUd1Fp_0i-RWovoN-L56hmEDouYmqEM/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $json.currentDate }}",
            "Idea": "={{ $('AI agent').item.json.output.prompt }}",
            "Status": "done",
            "Video Url": "={{ $('Video Request 2').item.json.data.response.resultUrls[0] }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Idea",
              "displayName": "Idea",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Video Url",
              "displayName": "Video Url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        1024,
        -48
      ],
      "id": "7c1171db-7699-4b0a-b73a-046877bf0621",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "drez7unFeg8epr1r",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.kie.ai/api/v1/veo/generate",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.output.prompt }}"
            },
            {
              "name": "model",
              "value": "veo3_fast"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -96,
        -48
      ],
      "id": "974cb631-51e8-448e-8106-0a7414535ffb",
      "name": "Video Request 1",
      "credentials": {
        "httpHeaderAuth": {
          "id": "dQQIMrAGnD98HwUq",
          "name": "Kie API Key"
        }
      }
    },
    {
      "parameters": {
        "url": "https://api.kie.ai/api/v1/veo/record-info",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "taskId",
              "value": "={{ $json.data.taskId }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        352,
        -112
      ],
      "id": "5e6e773e-79cf-4b55-9af0-589fa1d52372",
      "name": "Video Request 2",
      "credentials": {
        "httpHeaderAuth": {
          "id": "dQQIMrAGnD98HwUq",
          "name": "Kie API Key"
        }
      }
    },
    {
      "parameters": {
        "amount": 10
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        128,
        -48
      ],
      "id": "1be05b24-8725-499e-befc-5be0fd7e698a",
      "name": "Wait",
      "webhookId": "4bff9f7b-f87d-4481-ab1d-437ae7d45f2b"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "1e03bbe0-00b3-4cec-a8c7-e582e4b0af6f",
              "leftValue": "={{ $json.data.successFlag }}",
              "rightValue": "=1",
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        576,
        -48
      ],
      "id": "80be1450-bd5d-4bd9-86c3-20ce5173bb1a",
      "name": "If1"
    }
  ],
  "pinData": {},
  "connections": {
    "DeepSeek Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "AI agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI agent": {
      "main": [
        [
          {
            "node": "Video Request 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video Request 1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video Request 2": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Video Request 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "19bc5f15-0a03-4444-b98b-57d3373cb8e2",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "14d1b60adc749fc2cf1cd98b4578d0a33025456b1da4b4d0870fea8f29b05222"
  },
  "id": "yIWRjigHw5ut2NoW",
  "tags": []
}

    
作者
天天