8
n8n 中文网amn8n.com

使用Blockify IdeaBlocks优化RAG与智能体的技术手册

高级

这是一个自动化工作流,包含 29 个节点。主要使用 If, Set, Code, Wait, AwsS3 等节点。 通过Blockify IdeaBlocks技术优化面向RAG和智能体的技术手册

前置要求
  • AWS Access Key 和 Secret
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "6ee5d038b3d9fc2c09da6a02264d9559941160ab8b9dd73e6ca57abf9fcd1d8b"
  },
  "nodes": [
    {
      "id": "a58752a1-e536-4ba4-8cf6-77e5462a6887",
      "name": "计划触发器2",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -3504,
        448
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a00fa7b7-bacc-47da-9dd2-798d0d079c4d",
      "name": "启动 PDF 提取",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2096,
        304
      ],
      "parameters": {
        "url": "url-for-google-gemini-pdf-processing",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "signed_s3_url",
              "value": "={{ $json.url }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "XXXXXXXXX"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "16c2a856-ef46-4894-a054-273d743ed989",
      "name": "PDF 状态轮询",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1872,
        304
      ],
      "parameters": {
        "url": "=polling_url_for_pdf_parsing",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "xxxxxx"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9a1810ad-1d8a-4904-ae0f-271bbc78c269",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1648,
        208
      ],
      "webhookId": "e3c285ba-1289-4c44-a641-453463f20d73",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "043faeff-13d9-4c94-a42d-488a2cce3f63",
      "name": "从 API 响应中提取 IdeaBlocks",
      "type": "n8n-nodes-base.set",
      "position": [
        656,
        384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8133796e-0114-432b-83e6-fb3a2c5ca4be",
              "name": "manual-section",
              "type": "string",
              "value": "={{ $json.choices[0].message.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d077e83b-b65e-4f01-97a8-c8fb8c91150f",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1376,
        208
      ],
      "parameters": {
        "options": {
          "encoding": "utf8",
          "fileName": "={{\n  (() => {\n    const raw = $json.output || '';\n    // Remove leading \"# \" or \"#\"\n    const sanitized = raw.replace(/^#\\s*/, '');\n    // Split into lines, take the first non-empty one\n    const lines = sanitized.split('\\n').map(s => s.trim()).filter(Boolean);\n    const headline = lines[0] || '';\n    // Remove unwanted punctuation for filename (last char, if any)\n    return headline.replace(/[!.?\\\\]$/, '');\n  })()\n}}.txt"
        },
        "operation": "toText",
        "sourceProperty": "output"
      },
      "typeVersion": 1.1
    },
    {
      "id": "eab33a5c-f147-4a6c-95be-b2cb34be3996",
      "name": "技术手册提示有效载荷组装",
      "type": "n8n-nodes-base.code",
      "position": [
        -272,
        384
      ],
      "parameters": {
        "jsCode": "/**\n * n8n Code node\n * Input:  items where each item.json = { chunk: string, order: string }\n * Output: array of payload objects with primary, proceeding, and following sections\n */\n\nconst inputItems = $input.all();\n\n// If a single item contains the whole array under a property (e.g. { data: [...] }),\n// you can adapt the next line accordingly.\n// Example: const chunks = inputItems[0]?.json?.data ?? inputItems.map(item => item.json);\nconst chunks = inputItems.map(item => item.json);\n\n// Sort by numeric order to ensure correct sequence\nchunks.sort((a, b) => Number(a.order) - Number(b.order));\n\nconst results = chunks.map((primaryChunk, index) => {\n  const prevChunk = chunks[index - 1] ?? null;\n  const nextChunk = chunks[index + 1] ?? null;\n\n  const payload = [\n    '### Primary ###',\n    '---',\n    primaryChunk.chunk ?? '',\n    '---',\n    '### Proceeding ###',\n    '---',\n    prevChunk ? prevChunk.chunk ?? '' : '',\n    '---',\n    '### Following ###',\n    '---',\n    nextChunk ? nextChunk.chunk ?? '' : '',\n  ].join('\\n');\n\n  return {\n    json: {\n      payload,\n      'primary-order': primaryChunk.order ?? '',\n      'proceeding-order': prevChunk?.order ?? '',\n      'following-order': nextChunk?.order ?? '',\n      'payload-order': String(index + 1),\n    },\n  };\n});\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "1a07e7f5-8ea1-4cdc-bb90-301eb2f0a037",
      "name": "技术手册分割块",
      "type": "n8n-nodes-base.code",
      "position": [
        -720,
        304
      ],
      "parameters": {
        "jsCode": "// n8n Function node code\nconst H1_LIMIT = 4000;\nconst H2_LIMIT = 5000;\n\nfunction splitByHeading(text, level) {\n  const src = String(text ?? '');\n  if (!src.trim()) return [];\n\n  const lines = src.split(/\\r?\\n/);\n  const headingIdxs = [];\n  let inFence = null;\n\n  const fenceRe = /^\\s*(`{3,}|~{3,})/;\n  const headingRe = /^[ \\t]{0,3}(#{1,6})[ \\t]+(.+?)\\s*#*\\s*$/;\n\n  for (let i = 0; i < lines.length; i++) {\n    const line = lines[i];\n\n    const fm = line.match(fenceRe);\n    if (fm) {\n      const fenceChar = fm[1][0];\n      if (!inFence) inFence = fenceChar;\n      else if (inFence === fenceChar) inFence = null;\n      continue;\n    }\n\n    if (!inFence) {\n      const hm = line.match(headingRe);\n      if (hm && hm[1].length === level) {\n        headingIdxs.push(i);\n      }\n    }\n  }\n\n  if (headingIdxs.length === 0) {\n    const only = lines.join('\\n').trim();\n    return only ? [only] : [];\n  }\n\n  const sections = [];\n  for (let k = 0; k < headingIdxs.length; k++) {\n    const start = headingIdxs[k];\n    const end = (k + 1 < headingIdxs.length) ? headingIdxs[k + 1] : lines.length;\n\n    let sectionLines = lines.slice(start, end);\n\n    if (k === 0 && start > 0) {\n      sectionLines = lines.slice(0, start).concat(sectionLines);\n    }\n\n    const section = sectionLines.join('\\n').trim();\n    if (section) sections.push(section);\n  }\n\n  return sections;\n}\n\nconst rawInput = $json.output ?? '';\nconst text = typeof rawInput === 'string' ? rawInput : String(rawInput);\n\nconst finalChunks = [];\nconst h1Sections = splitByHeading(text, 1);\nconst topLevelSections = h1Sections.length ? h1Sections : [text.trim()].filter(Boolean);\n\nfor (const h1 of topLevelSections) {\n  if (h1.length <= H1_LIMIT) {\n    finalChunks.push(h1);\n    continue;\n  }\n\n  const h2Sections = splitByHeading(h1, 2);\n  const secondLevelSections = h2Sections.length ? h2Sections : [h1];\n\n  for (const h2 of secondLevelSections) {\n    if (h2.length <= H2_LIMIT) {\n      finalChunks.push(h2);\n      continue;\n    }\n\n    const h3Sections = splitByHeading(h2, 3);\n    if (h3Sections.length) {\n      finalChunks.push(...h3Sections);\n    } else {\n      finalChunks.push(h2);\n    }\n  }\n}\n\nreturn finalChunks.map((chunk, idx) => ({\n  json: {\n    chunk,\n    order: String(idx + 1),\n  },\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "4bc5a0b3-c468-4428-ac01-7479f974f5a8",
      "name": "剥离并清理为聚合 XML",
      "type": "n8n-nodes-base.set",
      "position": [
        1184,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "10b6a1df-b189-4ebb-9fa8-2fcedb14509f",
              "name": "output",
              "type": "string",
              "value": "={{ String($items()\n  .flatMap(i => i.json['manual-sections'] || [])\n  .flatMap(sec => [].concat(sec?.['manual-section'] || []))\n  .map(c => c?.choices?.[0]?.message?.content\n        ?? c?.choices?.[0]?.delta?.content\n        ?? (typeof c === 'string' ? c : c?.content ?? ''))\n  .join(''))\n  .replace(/```[\\w#+.-]*\\s*\\r?\\n?|```/g, '') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "71e3e38e-b653-47d5-9924-3dd9d28cb401",
      "name": "上传块化手册",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1664,
        416
      ],
      "parameters": {
        "name": "=blockified-manual.txt",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1yVqBHUS7RZqNY1cj6IYUOQ_eLVDjA7y5",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1yVqBHUS7RZqNY1cj6IYUOQ_eLVDjA7y5",
          "cachedResultName": "n8n-blockify-manual-extraction"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "rvBAumtq4Uwnq9sJ",
          "name": "Google Drive account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 3,
      "waitBetweenTries": 5000
    },
    {
      "id": "34ec291b-5bb4-42c8-9faf-73a3a6d9c16f",
      "name": "Blockify 技术摄取 API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        432,
        384
      ],
      "parameters": {
        "url": "https://api.blockify.ai/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": {{ JSON.stringify($json.payload) }}\n    }\n  ],\n  \"max_tokens\": 8000,\n  \"temperature\": 0.5,\n  \"model\": \"technical-ingest\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "tipDu5kIivBygKXB",
          "name": "Blockify API Production"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3315311a-dcd8-4be6-8124-c6832c493cf2",
      "name": "完成轮询器",
      "type": "n8n-nodes-base.if",
      "position": [
        -1424,
        304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "325e71a3-a124-48ff-865e-ea6cafd74f28",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "37674ca5-10fd-4176-a863-479588fb389e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2160,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 1120,
        "height": 672,
        "content": "## 从 PDF 提取数据到 Markdown"
      },
      "typeVersion": 1
    },
    {
      "id": "8069420b-ec08-4703-8908-835855fd24ae",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3280,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 1088,
        "height": 672,
        "content": "## 收集源文档并上传到 S3 获取用于处理的签名 URL"
      },
      "typeVersion": 1
    },
    {
      "id": "f1b3ca3d-2a74-46de-a376-bf4643d0cd0d",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 448,
        "height": 672,
        "content": "## 解析 Markdown 并在标题分隔处分割为特定块"
      },
      "typeVersion": 1
    },
    {
      "id": "a18b87e5-821d-47b4-85d7-01b39e54a32e",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 672,
        "content": "## 按照特定文档指南组装 Blockify API 的有效载荷"
      },
      "typeVersion": 1
    },
    {
      "id": "69b9a108-12e1-4859-a976-95bc26ef8bd3",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 752,
        "height": 672,
        "content": "## 对所有块运行 API 并提取 XML Blockify 结果"
      },
      "typeVersion": 1
    },
    {
      "id": "b6570d29-5609-4aff-abe1-7cba1353df33",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 944,
        "height": 672,
        "content": "## 输出收集方法示例"
      },
      "typeVersion": 1
    },
    {
      "id": "47219d7f-6675-458f-adad-29f5fae73998",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3616,
        -304
      ],
      "parameters": {
        "color": 5,
        "width": 5632,
        "height": 1200,
        "content": "# 步骤1:Blockify 技术手册摄取"
      },
      "typeVersion": 1
    },
    {
      "id": "088cc03a-29fd-4c72-94c7-9418d527b27c",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4240,
        -304
      ],
      "parameters": {
        "color": 6,
        "width": 592,
        "height": 1200,
        "content": "# Blockify® 数据优化工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "88d04eda-7ba3-4f32-a943-019622e513f2",
      "name": "搜索文件和文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -3216,
        448
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "root",
            "cachedResultUrl": "https://drive.google.com/drive",
            "cachedResultName": "/ (Root folder)"
          }
        },
        "options": {},
        "resource": "fileFolder",
        "returnAll": true,
        "searchMethod": "query"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "rvBAumtq4Uwnq9sJ",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "dbd37184-e2f1-4204-9262-cc1a582c5f71",
      "name": "循环处理要 Blockify 的文档",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -2992,
        448
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "5591235c-65fe-4b78-9f60-df81e4c8ddc5",
      "name": "下载要 Blockify 的文档",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -2768,
        304
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "rvBAumtq4Uwnq9sJ",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "dc0bc4db-3b43-4f2f-8ac5-5ad400fc23dc",
      "name": "上传文档到 S3",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        -2560,
        304
      ],
      "parameters": {
        "fileName": "={{ $json.name }}",
        "operation": "upload",
        "bucketName": "n8n-AWS-Bucket-Name-Here",
        "additionalFields": {
          "parentFolderKey": "folder/path/here"
        }
      },
      "credentials": {
        "aws": {
          "id": "xk6TbbAlmWZJN2Dg",
          "name": "AWS account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "46e95293-eb82-4c12-a1a5-109c91834453",
      "name": "获取 AWS 签名 URL",
      "type": "n8n-nodes-base.code",
      "position": [
        -2352,
        304
      ],
      "parameters": {
        "jsCode": "const crypto = require('crypto');\n\nfunction encodeRfc3986(str) {\n  return encodeURIComponent(str).replace(/[!'()*]/g, c =>\n    '%' + c.charCodeAt(0).toString(16).toUpperCase()\n  );\n}\n\nfunction encodePath(key) {\n  return key.split('/').map(encodeRfc3986).join('/');\n}\n\nfunction awsS3PresignDownload({\n  accessKeyId,\n  secretAccessKey,\n  bucket,\n  region,\n  key,\n  expires = 900,\n  endpointHost,\n}) {\n  if (!key || /^https?:\\/\\//i.test(key)) {\n    throw new Error('key must be the S3 object key (e.g., \"folder/file.txt\"), not a full URL.');\n  }\n\n  const host = endpointHost\n    ? endpointHost\n    : (region === 'us-east-1'\n        ? `${bucket}.s3.amazonaws.com`\n        : `${bucket}.s3.${region}.amazonaws.com`);\n\n  const now = new Date();\n  const pad = n => n.toString().padStart(2, '0');\n  const date = `${now.getUTCFullYear()}${pad(now.getUTCMonth() + 1)}${pad(now.getUTCDate())}`;\n  const amzDate = `${date}T${pad(now.getUTCHours())}${pad(now.getUTCMinutes())}${pad(now.getUTCSeconds())}Z`;\n\n  const algorithm = 'AWS4-HMAC-SHA256';\n  const scope = `${date}/${region}/s3/aws4_request`;\n  const signedHeaders = 'host';\n\n  const canonicalUri = `/${encodePath(key)}`;\n  const xAmzParams = {\n    'X-Amz-Algorithm': algorithm,\n    'X-Amz-Credential': `${accessKeyId}/${scope}`,\n    'X-Amz-Date': amzDate,\n    'X-Amz-Expires': String(expires),\n    'X-Amz-SignedHeaders': signedHeaders,\n  };\n\n  const canonicalQuery = Object.keys(xAmzParams)\n    .sort()\n    .map(k => `${encodeRfc3986(k)}=${encodeRfc3986(xAmzParams[k])}`)\n    .join('&');\n\n  const canonicalHeaders = `host:${host}\\n`;\n  const canonicalRequest = [\n    'GET',\n    canonicalUri,\n    canonicalQuery,\n    canonicalHeaders,\n    signedHeaders,\n    'UNSIGNED-PAYLOAD',\n  ].join('\\n');\n\n  const hashedRequest = crypto.createHash('sha256').update(canonicalRequest, 'utf8').digest('hex');\n  const stringToSign = `${algorithm}\\n${amzDate}\\n${scope}\\n${hashedRequest}`;\n\n  const hmac = (key, data) => crypto.createHmac('sha256', key).update(data, 'utf8').digest();\n  const kDate = hmac(`AWS4${secretAccessKey}`, date);\n  const kRegion = hmac(kDate, region);\n  const kService = hmac(kRegion, 's3');\n  const kSigning = hmac(kService, 'aws4_request');\n\n  const signature = crypto.createHmac('sha256', kSigning).update(stringToSign, 'utf8').digest('hex');\n\n  return `https://${host}${canonicalUri}?${canonicalQuery}&X-Amz-Signature=${signature}`;\n}\n\n// Configuration\nconst api_key = 'XXXXXX';      \nconst secret_key = 'YYYYYYYYYYYYYYYYY';        \nconst bucket_name = 'n8n-AWS-Bucket-Name-Here';\nconst region = 'us-west-2';\n\n// Get data from the Download file1 node (which has the binary data with fileName)\nconst downloadedFiles = $('Download Document to Blockify').all();\n\n// Process each item\nconst results = [];\n\nfor (const item of downloadedFiles) {\n  let fileName = null;\n  \n  // Get filename from binary data\n  if (item.binary && item.binary.data && item.binary.data.fileName) {\n    fileName = item.binary.data.fileName;\n  } else if (item.binary) {\n    // Try to find it in any binary property\n    const binaryKeys = Object.keys(item.binary);\n    for (const key of binaryKeys) {\n      if (item.binary[key] && item.binary[key].fileName) {\n        fileName = item.binary[key].fileName;\n        break;\n      }\n    }\n  }\n  \n  // Fallback to json.name if binary fileName not found\n  if (!fileName && item.json && item.json.name) {\n    fileName = item.json.name;\n  }\n  \n  if (!fileName) {\n    throw new Error(`Cannot find fileName. Binary keys: ${item.binary ? JSON.stringify(Object.keys(item.binary)) : 'no binary'}, JSON keys: ${JSON.stringify(Object.keys(item.json))}`);\n  }\n  \n  // Clean the filename (remove leading slashes if any)\n  const cleanFileName = fileName.replace(/^\\/+/, '');\n  \n  // Construct the S3 key (matches the upload configuration with inputs folder)\n  const s3Key = `inputs/${cleanFileName}`;\n  \n  const url = awsS3PresignDownload({\n    accessKeyId: api_key,\n    secretAccessKey: secret_key,\n    bucket: bucket_name,\n    region: region,\n    key: s3Key,\n    expires: 8400,\n  });\n  \n  results.push({\n    json: {\n      url: url,\n      fileName: cleanFileName,\n      s3Key: s3Key\n    }\n  });\n}\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "f2a19262-32bd-44d1-ae9f-9461def0abc7",
      "name": "下载最终 PDF 提取文本输出",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1200,
        304
      ],
      "parameters": {
        "url": "=url-for-google-gemini-pdf-processing/{{ $json.job_id }}",
        "options": {
          "redirect": {}
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "xxxxx"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "00458b88-9b89-4d01-ae14-b51acfc4963d",
      "name": "从 PDF 文本提取原始 Markdown",
      "type": "n8n-nodes-base.set",
      "position": [
        -944,
        304
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "10b6a1df-b189-4ebb-9fa8-2fcedb14509f",
              "name": "output",
              "type": "string",
              "value": "={{ $json.data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "eb137817-7a79-4f2a-962c-a661996a5117",
      "name": "为 Blockify 循环处理块",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        208,
        304
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "03befca6-bbc3-4301-a5c1-7f0fa919f54f",
      "name": "聚合所有手册部分",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        976,
        208
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "manual-sections"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "If Completed Poller",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Upload Blockified Manual",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger2": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get AWS Signed URL": {
      "main": [
        [
          {
            "node": "Initiate PDF Extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Status Polling": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Completed Poller": {
      "main": [
        [
          {
            "node": "Download Final PDF Extracted Text Output",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "PDF Status Polling",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initiate PDF Extraction": {
      "main": [
        [
          {
            "node": "PDF Status Polling",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload a Document to S3": {
      "main": [
        [
          {
            "node": "Get AWS Signed URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Loop over Documents to Blockify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Blockified Manual": {
      "main": [
        [
          {
            "node": "Loop over Documents to Blockify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate all Manual Sections": {
      "main": [
        [
          {
            "node": "Strip and Clean to Aggregate XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Blockify Technical Ingest API": {
      "main": [
        [
          {
            "node": "Extract IdeaBlocks from API Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Document to Blockify": {
      "main": [
        [
          {
            "node": "Upload a Document to S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Chunks for Blockify": {
      "main": [
        [
          {
            "node": "Aggregate all Manual Sections",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Blockify Technical Ingest API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Technical Manual Split Chunks": {
      "main": [
        [
          {
            "node": "Technical Manual Prompt Payload Assembly",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop over Documents to Blockify": {
      "main": [
        [],
        [
          {
            "node": "Download Document to Blockify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Strip and Clean to Aggregate XML": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Raw Markdown from PDF Text": {
      "main": [
        [
          {
            "node": "Technical Manual Split Chunks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract IdeaBlocks from API Response": {
      "main": [
        [
          {
            "node": "Loop Over Chunks for Blockify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Final PDF Extracted Text Output": {
      "main": [
        [
          {
            "node": "Extract Raw Markdown from PDF Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Technical Manual Prompt Payload Assembly": {
      "main": [
        [
          {
            "node": "Loop Over Chunks for Blockify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量29
分类-
节点类型12
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
外部链接
在 n8n.io 查看

分享此工作流