General 3D Presentation

工作流概述

这是一个包含15个节点的复杂工作流,主要用于自动化处理各种任务。

工作流源代码

下载
{
  "id": "vpZ1wpsniCvKYjCF",
  "meta": {
    "instanceId": "1e003a7ea4715b6b35e9947791386a7d07edf3b5bf8d4c9b7ee4fdcbec0447d7"
  },
  "name": "General 3D Presentation",
  "tags": [],
  "nodes": [
    {
      "id": "629ef84e-ffb7-4143-b0af-764bcb86a7fa",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        360,
        40
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d2751dcb-fd03-4a87-a501-43f701d2704a",
      "name": "Prompt",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        580,
        40
      ],
      "parameters": {
        "url": "https://api.piapi.ai/api/v1/task",
        "method": "POST",
        "options": {},
        "jsonBody": "{
  \"model\": \"midjourney\",
  \"task_type\": \"imagine\",
  \"input\": {
    \"prompt\": \"A blind box character design, in the chibi style, a super cute little girl wearing a white long-sleeved dress and pearl earrings with her head bowed in a prayer pose, facing upwards, wearing an oversized off-white dress with large round pearls on the shoulders, minimalist simple dress with Ruffles, against a beige background, a full-body shot in a three-quarter profile view, with a black, blue, and gray color scheme, soft lighting, 3D rendering, clay material, high detail, in the Pixar style. Clean white skin, brown renaissance braided bun. --ar 1:1 --niji 6\",
    \"aspect_ratio\": \"2:3\",
    \"process_mode\": \"turbo\",
    \"skip_prompt_check\": false
  }
}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f3f4b801-4b2b-49bf-a9be-1f38e62720ac",
      "name": "Midjourney Generator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        400,
        280
      ],
      "parameters": {
        "url": "=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a7ecf5f5-73fd-4d5b-b851-568dde2e797a",
      "name": "GPT-4o Image Generator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1060,
        80
      ],
      "parameters": {
        "url": "https://api.piapi.ai/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={
    \"model\": \"gpt-4o-image-preview\",
    \"messages\": [
        {
            \"role\": \"user\",
            \"content\": [
                {
                    \"type\": \"image_url\",
                    \"image_url\": {
                        \"url\": \"{{ $json.random_temp_url }}\"
                    }
                },
                {
                    \"type\": \"text\",
                    \"text\": \"Convert this image into a 3D figurine image, with front view, with full details, profile. \"
                }
            ]
        }
    ],
    \"stream\": true
}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "fsJeCNd9BkJ1CIrt",
          "name": "Header Auth account 2"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "25de6846-9a45-4cb8-8328-b5cb4e36889d",
      "name": "Generate Kling Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1600,
        200
      ],
      "parameters": {
        "url": "https://api.piapi.ai/api/v1/task",
        "method": "POST",
        "options": {},
        "jsonBody": "={
    \"model\": \"kling\",
    \"task_type\": \"video_generation\",
    \"input\": {
        \"version\": \"1.6\",
        \"aspect_ratio\": \"9:16\",
        \"image_url\":\"{{ $json.image_url }}\",

        \"prompt\": \"An anime character anchored mid-frame, gradually rotating to showcase 3D details\"
       
    }
} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "410c252e-4901-4159-b8c2-d9a2fe04371d",
      "name": "Get Video URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1820,
        200
      ],
      "parameters": {
        "url": "=https://api.piapi.ai/api/v1/task/{{ $json.data.task_id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "72858adea87ad16865d5b0a24c3d9b9f58a6e7b1a8a8a8a0d6b81a9f3a9812f3"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9a2188d8-8520-485e-99e4-0ff07e4b86e7",
      "name": "Wait for Image Generation",
      "type": "n8n-nodes-base.wait",
      "position": [
        620,
        520
      ],
      "webhookId": "f3bcf634-8c4b-4bf9-a7f2-d4ee369f5349",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "7f64087a-1567-4c62-a36d-d3b69d933d48",
      "name": "Check Generation Status",
      "type": "n8n-nodes-base.if",
      "position": [
        600,
        280
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a0f8758e-d6fd-44f8-bd79-bc3c4dceddcf",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "completed"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "838999b7-99f5-4f14-bfe2-4886bd565464",
      "name": "Get Image URL of Midjourney",
      "type": "n8n-nodes-base.code",
      "position": [
        840,
        80
      ],
      "parameters": {
        "jsCode": "// JavaScript Code for Function Node
return {
  random_temp_url: $input.all()[0].json.data.output.temporary_image_urls[
    Math.floor(Math.random() * $input.all()[0].json.data.output.temporary_image_urls.length)
  ]
};"
      },
      "typeVersion": 2
    },
    {
      "id": "09824819-7a6c-4416-ba40-811e9d785678",
      "name": "Get Image URL of GPT-4o-image",
      "type": "n8n-nodes-base.code",
      "position": [
        1280,
        80
      ],
      "parameters": {
        "jsCode": "const chunks = $input.first().json.data.split('\n\n');

let imageUrl = null;

for (let i = chunks.length - 1; i >= 0; i--) {
    const chunk = chunks[i];
    
    if (!chunk.startsWith('data: ')) continue;
    
    try {
        const jsonStr = chunk.substring(6); 
        if (jsonStr.trim() === '[DONE]') continue;
        
        const data = JSON.parse(jsonStr);
        
    
        if (data.choices && data.choices[0].delta.content) {
            const content = data.choices[0].delta.content;
            const urlMatch = content.match(/!\[.*?\]\((https?:\/\/[^\s]+)\)/);
            
            if (urlMatch && urlMatch[1]) {
                imageUrl = urlMatch[1];
                break;
            }
        }
    } catch (e) {
        continue;
    }
}

return {
    image_url: imageUrl,
    finish_reason: imageUrl ? \"success\" : \"not_found\"
};"
      },
      "typeVersion": 2
    },
    {
      "id": "22c8f566-6a27-4773-b4ab-45be2fbad8de",
      "name": "Check Generation Status of GPT-4o",
      "type": "n8n-nodes-base.if",
      "position": [
        1260,
        320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "08a2ebe6-dc95-4b8a-ada1-1173645cc3f4",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.finish_reason }}",
              "rightValue": "not_found"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "00ce5488-e96c-4ff1-8727-ed2d787ae0f5",
      "name": "Check Video Generation Status",
      "type": "n8n-nodes-base.if",
      "position": [
        2000,
        200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f36fa981-22e0-46db-af8c-c2ac55242c27",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "completed"
            },
            {
              "id": "637ea756-1ad9-434c-b6b2-b100ee4c3cad",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6d53cac4-b35b-41b1-b60a-6faba78b4439",
      "name": "Wait for Video Generation",
      "type": "n8n-nodes-base.wait",
      "position": [
        1960,
        420
      ],
      "webhookId": "c7b2590d-96a3-4c7c-8821-3023fead254b",
      "parameters": {
        "amount": 20
      },
      "typeVersion": 1.1
    },
    {
      "id": "4cd00e7b-bfbd-45bc-b775-401055921b45",
      "name": "Fetch Final Video URL",
      "type": "n8n-nodes-base.code",
      "position": [
        2300,
        300
      ],
      "parameters": {
        "jsCode": "// Process the entire response
return {
  video_url: $input.all()[0].json.data.output.video_url,
  watermark_free_url: $input.all()[0].json.data.output.works[0].video.resource_without_watermark
};"
      },
      "typeVersion": 2
    },
    {
      "id": "617d6647-4c49-4e7f-91f3-5fd6d5e95fe7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        -220
      ],
      "parameters": {
        "width": 460,
        "height": 220,
        "content": "## General 3D Presentation
This workflow creates 360° or 180° spinning videos of high-quality 3D models with [PiAPI](https://piapi.ai) API. 🙋
### Required Instruction: 
1. Fill in params of Prompt node.
2. Fill in x-api-key in Mijdourney Generator node and Generate Kling Video node, fill in Header Parameters of GPT-4o Image Generator (e.g., Bearer + your X-API-Key)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c6a9b53c-8d6c-4ffa-b95c-e7cf88734cc9",
  "connections": {
    "Prompt": {
      "main": [
        [
          {
            "node": "Midjourney Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video URL": {
      "main": [
        [
          {
            "node": "Check Video Generation Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Kling Video": {
      "main": [
        [
          {
            "node": "Get Video URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Midjourney Generator": {
      "main": [
        [
          {
            "node": "Check Generation Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4o Image Generator": {
      "main": [
        [
          {
            "node": "Get Image URL of GPT-4o-image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Generation Status": {
      "main": [
        [
          {
            "node": "Get Image URL of Midjourney",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Image Generation": {
      "main": [
        [
          {
            "node": "Midjourney Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Video Generation": {
      "main": [
        [
          {
            "node": "Get Video URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image URL of Midjourney": {
      "main": [
        [
          {
            "node": "GPT-4o Image Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Video Generation Status": {
      "main": [
        [
          {
            "node": "Fetch Final Video URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Video Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image URL of GPT-4o-image": {
      "main": [
        [
          {
            "node": "Check Generation Status of GPT-4o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Generation Status of GPT-4o": {
      "main": [
        [
          {
            "node": "GPT-4o Image Generator",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Kling Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

功能特点

  • 自动检测新邮件
  • AI智能内容分析
  • 自定义分类规则
  • 批量处理能力
  • 详细的处理日志

技术分析

节点类型及作用

  • Manualtrigger
  • Httprequest
  • Wait
  • If
  • Code

复杂度评估

配置难度:
★★★★☆
维护难度:
★★☆☆☆
扩展性:
★★★★☆

实施指南

前置条件

  • 有效的Gmail账户
  • n8n平台访问权限
  • Google API凭证
  • AI分类服务订阅

配置步骤

  1. 在n8n中导入工作流JSON文件
  2. 配置Gmail节点的认证信息
  3. 设置AI分类器的API密钥
  4. 自定义分类规则和标签映射
  5. 测试工作流执行
  6. 配置定时触发器(可选)

关键参数

参数名称 默认值 说明
maxEmails 50 单次处理的最大邮件数量
confidenceThreshold 0.8 分类置信度阈值
autoLabel true 是否自动添加标签

最佳实践

优化建议

  • 定期更新AI分类模型以提高准确性
  • 根据邮件量调整处理批次大小
  • 设置合理的分类置信度阈值
  • 定期清理过期的分类规则

安全注意事项

  • 妥善保管API密钥和认证信息
  • 限制工作流的访问权限
  • 定期审查处理日志
  • 启用双因素认证保护Gmail账户

性能优化

  • 使用增量处理减少重复工作
  • 缓存频繁访问的数据
  • 并行处理多个邮件分类任务
  • 监控系统资源使用情况

故障排除

常见问题

邮件未被正确分类

检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。

Gmail认证失败

确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。

调试技巧

  • 启用详细日志记录查看每个步骤的执行情况
  • 使用测试邮件验证分类逻辑
  • 检查网络连接和API服务状态
  • 逐步执行工作流定位问题节点

错误处理

工作流包含以下错误处理机制:

  • 网络超时自动重试(最多3次)
  • API错误记录和告警
  • 处理失败邮件的隔离机制
  • 异常情况下的回滚操作