Simple v1 - AK

工作流概述

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

工作流源代码

下载
{
  "id": "2pMoIW58KP6ZeGir",
  "meta": {
    "instanceId": "ecc960f484e18b0e09045fd93acf0d47f4cfff25cc212ea348a08ac3aae81850",
    "templateCredsSetupCompleted": true
  },
  "name": "Luma AI Dream Machine - Simple v1 - AK",
  "tags": [
    {
      "id": "tUlWC9t8VhwpFaci",
      "name": "Alex - WIP",
      "createdAt": "2025-02-20T17:17:53.411Z",
      "updatedAt": "2025-02-20T17:17:53.411Z"
    }
  ],
  "nodes": [
    {
      "id": "dbe1dbcc-05a0-4439-869c-157e51a99dd1",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -440,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "603f7fdd-e590-4a51-b606-a9bb9396a0c0",
      "name": "Text 2 Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        0
      ],
      "parameters": {
        "url": "https://api.lumalabs.ai/dream-machine/v1/generations",
        "method": "POST",
        "options": {},
        "jsonBody": "={
  \"model\": \"ray-2\",
  \"prompt\": {{ JSON.stringify($('Global SETTINGS').first().json.video_prompt + \"; camera motion: \" + $json.action) }},
  \"aspect_ratio\": \"{{ $('Global SETTINGS').first().json.aspect_ratio }}\",
  \"duration\": \"{{ $('Global SETTINGS').item.json.duration }}\",
  \"loop\": {{ $('Global SETTINGS').first().json.loop }},
  \"callback_url\": \"{{ $('Global SETTINGS').first().json.callback_url }}\"
  
}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "zzIlODir90EUTwHh",
          "name": "Luma Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "494ac05e-e0c5-465e-b805-2749683ab789",
      "name": "RANDOM Camera Motion",
      "type": "n8n-nodes-base.code",
      "position": [
        0,
        0
      ],
      "parameters": {
        "jsCode": "const items = [
  \"Static\",
  \"Move Left\",
  \"Move Right\",
  \"Move Up\",
  \"Move Down\",
  \"Push In\",
  \"Pull Out\",
  \"Zoom In\",
  \"Zoom Out\",
  \"Pan Left\",
  \"Pan Right\",
  \"Orbit Left\",
  \"Orbit Right\",
  \"Crane Up\",
  \"Crane Down\"
];

const randomItem = items[Math.floor(Math.random() * items.length)];

return [{ json: { action: randomItem } }];
"
      },
      "typeVersion": 2
    },
    {
      "id": "30ba7cfc-d2c3-478f-ae01-0a3397ceb439",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -120
      ],
      "parameters": {
        "color": 3,
        "width": 180,
        "content": "## Define your SETTINGS here"
      },
      "typeVersion": 1
    },
    {
      "id": "12924397-b2a4-43a0-8ec5-1b13c0357e40",
      "name": "Global SETTINGS",
      "type": "n8n-nodes-base.set",
      "position": [
        -220,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7064f685-d91f-4049-9fcb-dd7018c1bc8d",
              "name": "aspect_ratio",
              "type": "string",
              "value": "9:16"
            },
            {
              "id": "3d6d3fe0-4e4a-4d1b-9f6a-08037a4e2785",
              "name": "video_prompt",
              "type": "string",
              "value": "a superhero flying through a volcano"
            },
            {
              "id": "7ae48bee-0be5-487f-8d6d-ea7fe98fdd36",
              "name": "loop",
              "type": "string",
              "value": "true"
            },
            {
              "id": "82930db0-971e-4de4-911d-ff5a7fab5d67",
              "name": "duration",
              "type": "string",
              "value": "5s"
            },
            {
              "id": "b51d9834-87c8-4358-a257-6a02ebe2576d",
              "name": "cluster_id",
              "type": "string",
              "value": "={{ Date.now() + '_' + Math.random().toString(36).slice(2, 10) }}"
            },
            {
              "id": "8756fe2d-df04-48d4-9cd4-d29b8d9a3ab1",
              "name": "airtable_base",
              "type": "string",
              "value": "appvk87mtcwRve5p5"
            },
            {
              "id": "a83707ef-3a1c-4b3c-939c-1376bc43cc76",
              "name": "airtable_table_generated_videos",
              "type": "string",
              "value": "tblOzRFWgcsfttRWK"
            },
            {
              "id": "694528cd-c51e-45ac-8dbe-1b33b347f590",
              "name": "callback_url",
              "type": "string",
              "value": "https://YOURURL.com/luma-ai"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9f4732b5-8e3e-4fb6-942f-32c72b3eb041",
      "name": "ADD Video Info",
      "type": "n8n-nodes-base.airtable",
      "position": [
        660,
        0
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global SETTINGS').first().json.airtable_base }}"
        },
        "table": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global SETTINGS').first().json.airtable_table_generated_videos }}"
        },
        "columns": {
          "value": {
            "Model": "={{ $json.model }}",
            "Aspect": "={{ $json.request.aspect_ratio }}",
            "Length": "={{ $json.request.duration }}",
            "Prompt": "={{ $('Global SETTINGS').first().json.video_prompt }}",
            "Status": "Done",
            "Cluster ID": "={{ $('Global SETTINGS').first().json.cluster_id }}",
            "Resolution": "={{ $json.request.resolution }}",
            "Generation ID": "={{ $json.id }}"
          },
          "schema": [
            {
              "id": "Generation ID",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Generation ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "Todo",
                  "value": "Todo"
                },
                {
                  "name": "In progress",
                  "value": "In progress"
                },
                {
                  "name": "Done",
                  "value": "Done"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Content Title",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Content Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Video URL",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Video URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Thumb URL",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Thumb URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "VO",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "VO",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Aspect",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Aspect",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Model",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Model",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Resolution",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Resolution",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Length",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Length",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "Created",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Cluster ID",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Cluster ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "create"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "yqBrLbgHXLcwqH0p",
          "name": "AlexK Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9923373d-d4ce-42bb-9f2d-34350f64ac5b",
      "name": "Execution Data",
      "type": "n8n-nodes-base.executionData",
      "position": [
        440,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5044e1f2-c985-4c3a-9386-f4fe4f85f37b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -120
      ],
      "parameters": {
        "color": 5,
        "width": 840,
        "content": "## This is where the magic happens... "
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e756199d-31fc-4e2f-8937-3625295a147c",
  "connections": {
    "Text 2 Video": {
      "main": [
        [
          {
            "node": "Execution Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ADD Video Info": {
      "main": [
        []
      ]
    },
    "Execution Data": {
      "main": [
        [
          {
            "node": "ADD Video Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Global SETTINGS": {
      "main": [
        [
          {
            "node": "RANDOM Camera Motion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RANDOM Camera Motion": {
      "main": [
        [
          {
            "node": "Text 2 Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Global SETTINGS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

功能特点

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

技术分析

节点类型及作用

  • Manualtrigger
  • Httprequest
  • Code
  • Stickynote
  • Set

复杂度评估

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

实施指南

前置条件

  • 有效的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错误记录和告警
  • 处理失败邮件的隔离机制
  • 异常情况下的回滚操作