8
n8n 中文网amn8n.com

使用OpenAI和n8n从URL、文本和PDF进行AI内容摘要

高级

这是一个Miscellaneous, AI Summarization, Multimodal AI领域的自动化工作流,包含 47 个节点。主要使用 If, Set, Switch, Webhook, Function 等节点。 使用OpenAI GPT-4.1-mini从URL、文本和PDF汇总内容

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "MGxb1ugenLCp7pGW",
  "meta": {
    "instanceId": "506e1eb999b7a8cf86103921b3e1b94e371534d9bae39d44754933678dc6697d",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 OpenAI 和 n8n 从 URL、文本和 PDF 进行 AI 内容摘要",
  "tags": [
    {
      "id": "XnTVyrQY30pP85Ic",
      "name": "Personal",
      "createdAt": "2025-07-07T12:25:22.847Z",
      "updatedAt": "2025-07-07T12:25:22.847Z"
    }
  ],
  "nodes": [
    {
      "id": "41fb7559-5588-4af7-a843-69f3a6ced08e",
      "name": "初始触发器",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1344,
        1040
      ],
      "webhookId": "7bd77710-f268-4b33-9101-8de427badd49",
      "parameters": {
        "path": "webhook-url",
        "options": {
          "rawBody": true
        },
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "bb2f4efb-accc-4e3d-9a1e-6fc4a8175a8f",
      "name": "输入类型切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        -944,
        1024
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "url",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f2e4855a-2828-4ade-94ac-f06a9e795d54",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.input_type }}",
                    "rightValue": "={{ \"url\" }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "3a855f49-b559-4ef4-a94e-e7b2dfab3057",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.input_type }}",
                    "rightValue": "={{ \"text\" }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "file",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "0be44b08-67ca-4b5c-9ec1-24ca112fbd53",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.input_type }}",
                    "rightValue": "={{ \"file\" }}"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "executeOnce": false,
      "typeVersion": 3,
      "alwaysOutputData": false
    },
    {
      "id": "b38cc7cd-66f7-4d86-8de3-d3088679092c",
      "name": "获取 URL 内容",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -288,
        960
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "9455fbe7-a019-4f5d-8fe7-90f4e4aa19a2",
      "name": "获取 PDF 文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -608,
        1296
      ],
      "parameters": {
        "url": "={{ $json.file_content }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "fc9e62a8-1eb2-4ba3-8a6e-9f49e9de1693",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -464,
        1296
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "0b01f016-3673-4401-83f5-aa2e31d2b80b",
      "name": "检查提取的文本是否为空",
      "type": "n8n-nodes-base.if",
      "position": [
        -320,
        1296
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "88a7fc31-aac6-4e2f-899e-c250feef5f10",
              "operator": {
                "type": "string",
                "operation": "empty"
              },
              "leftValue": "={{ $json.text }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2c5321a0-4040-4ce1-8719-71098eb1f946",
      "name": "映射语言代码",
      "type": "n8n-nodes-base.function",
      "position": [
        16,
        1344
      ],
      "parameters": {
        "functionCode": "const lang = $json.language?.toLowerCase() || 'english';\nlet code = 'eng';\nif (lang.includes('spanish')) code = 'spa';\nelse if (lang.includes('french')) code = 'fra';\nelse if (lang.includes('german')) code = 'ger';\nreturn { json: { language_code: code } };"
      },
      "typeVersion": 1
    },
    {
      "id": "7727da47-5782-4887-9397-2dbd8c1b8e0e",
      "name": "OCR.Space",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        176,
        1344
      ],
      "parameters": {
        "url": "https://api.ocr.space/parse/image",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "language",
              "value": "={{ $json.language_code }}"
            },
            {
              "name": "isOverlayRequired",
              "value": "false"
            },
            {
              "name": "file",
              "parameterType": "formBinaryData"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "YOUR_OCR_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "71c47757-c891-4e29-b10e-55503c634bd6",
      "name": "摘要-URL",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1328,
        1664
      ],
      "webhookId": "7e7f989c-cbf9-4d21-87e3-d85f1bff6649",
      "parameters": {
        "path": "7e7f989c-cbf9-4d21-87e3-d85f1bff6649",
        "options": {
          "rawBody": true
        },
        "responseMode": "responseNode",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "Pqm05Oeq2YGSzRKN",
          "name": "bearer auth for bubble test pages"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "fb8c898f-a11b-4d10-a6ab-777e80cdf802",
      "name": "摘要-文本",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1312,
        2192
      ],
      "webhookId": "7fd2e79d-a18a-4b4f-a161-ca2bf060c891",
      "parameters": {
        "path": "7fd2e79d-a18a-4b4f-a161-ca2bf060c891",
        "options": {
          "rawBody": true
        },
        "responseMode": "responseNode",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "Pqm05Oeq2YGSzRKN",
          "name": "bearer auth for bubble test pages"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "5e56e512-7e58-4074-b984-7ea13ae48013",
      "name": "摘要-文件",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1312,
        2800
      ],
      "webhookId": "6e8000d4-56cb-457a-9dfe-5961a75b342f",
      "parameters": {
        "path": "6e8000d4-56cb-457a-9dfe-5961a75b342f",
        "options": {
          "rawBody": true
        },
        "responseMode": "responseNode",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "Pqm05Oeq2YGSzRKN",
          "name": "bearer auth for bubble test pages"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "3652a5dd-7273-42a7-a953-baadc53cde25",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1824,
        2800
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 96,
        "content": "# 摘要 PDF 文件"
      },
      "typeVersion": 1
    },
    {
      "id": "445ffe95-2006-4e44-82e9-912c6bd7cb4c",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1824,
        2224
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 80,
        "content": "# 摘要文本"
      },
      "typeVersion": 1
    },
    {
      "id": "62fe1311-19dd-4307-b740-b8534461f93e",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1808,
        1680
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 80,
        "content": "# 摘要 URL"
      },
      "typeVersion": 1
    },
    {
      "id": "b59d5d2d-4610-4f46-ac77-156ff8bf93f6",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1824,
        1024
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 80,
        "content": "# 一体化摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "063a6c64-8fa5-4a3e-9695-44c2ea5cd894",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2752,
        1008
      ],
      "parameters": {
        "width": 608,
        "height": 1008,
        "content": "# AI 内容摘要套件"
      },
      "typeVersion": 1
    },
    {
      "id": "598ed657-da21-44c1-bd1f-1b4a2739636f",
      "name": "解析输入参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1120,
        1040
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "input_type",
              "type": "string",
              "value": "={{ $json.query.input_type || $json.body.input_type || 'url' }}"
            },
            {
              "name": "url",
              "type": "string",
              "value": "={{ $json.query.url || $json.body.url || '' }}"
            },
            {
              "name": "text_content",
              "type": "string",
              "value": "={{ $json.query.text_content || $json.body.text_content || '' }}"
            },
            {
              "name": "summary_length",
              "type": "string",
              "value": "={{ $json.query.summary_length || $json.body.summary_length || 'standard' }}"
            },
            {
              "name": "focus",
              "type": "string",
              "value": "={{ $json.query.focus || $json.body.focus || 'key_points' }}"
            },
            {
              "name": "language",
              "type": "string",
              "value": "={{ $json.query.language || $json.body.language || 'english' }}"
            },
            {
              "name": "file_content",
              "type": "string",
              "value": "={{ $json.query.file_content || $json.body.file_content || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8125ba61-90c6-4b36-baf3-94683db88ce8",
      "name": "生成 AI 摘要(统一)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        672,
        1040
      ],
      "parameters": {
        "text": "=Summarize: {{ $json.raw_content }}",
        "options": {
          "systemMessage": "=Current date and time {{ $now }}\n\nYou are an expert content summarizer. \nCreate a {{ $('Parse Input Parameters').item.json.summary_length === 'brief' ? '**brief** (2-3 sentences)' : $('Parse Input Parameters').item.json.summary_length === 'detailed' ? '**detailed** (2-3 paragraphs)' : '**standard** (1 paragraph)' }} summary in markdown format.\n\n**Focus**: \n{{ $('Parse Input Parameters').item.json.focus === 'numbers_data' \n    ? 'Extract key **numbers**, **percentages**, and quantitative data' \n    : $('Parse Input Parameters').item.json.focus === 'conclusions' \n    ? 'Highlight main **conclusions** and findings' \n    : $('Parse Input Parameters').item.json.focus === 'action_items' \n    ? 'List concrete **action items** and recommendations' \n    : 'Capture essential **key points** and main themes' }}\n\n**Formatting Guidelines:**\n- Use **bold** for key terms and important information\n- Use *italics* for emphasis\n- Use bullet points (- ) for lists\n- Use ## for section headers when appropriate\n- Lead with the most important information\n- Include specific details that support main points\n- Ensure the summary is complete and stands alone\n\n**Language**: \n{{ $('Parse Input Parameters').item.json.language === 'spanish' \n    ? 'Spanish' \n    : $('Parse Input Parameters').item.json.language === 'french' \n    ? 'French' \n    : $('Parse Input Parameters').item.json.language === 'german' \n    ? 'German' \n    : 'English' }}\n\nContent: {{ $json.raw_content }}\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "0b02b948-24c2-495b-bef7-99901fdd50b6",
      "name": "OpenAI GPT-4.1(统一)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        752,
        1264
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "mvWns3smwtPV0N7O",
          "name": "Dummy OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0da9c053-faaf-4b2c-b089-30d23daab44f",
      "name": "清理和格式化内容",
      "type": "n8n-nodes-base.set",
      "position": [
        448,
        1040
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "80a0f7dc-ee66-4499-ac84-1e21fca8e6c7",
              "name": "raw_content",
              "type": "string",
              "value": "={{ $json.raw_content || $json.data || $json.text || $json.text_content || $json.ParsedResults?.[0]?.ParsedText || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4992bf8e-fb2a-4ef6-b7cc-c6943a256993",
      "name": "构建最终输出",
      "type": "n8n-nodes-base.set",
      "position": [
        1024,
        1040
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "content",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dfd24b35-f6ee-4471-93d9-a1f202a85cce",
      "name": "返回摘要响应",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1248,
        1040
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.content }}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "9d6d737e-4fe9-4fd4-a8d6-15b566de57f3",
      "name": "提取 URL 参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1104,
        1664
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "input_type",
              "type": "string",
              "value": "={{ $json.query.input_type || $json.body.input_type || 'url' }}"
            },
            {
              "name": "url",
              "type": "string",
              "value": "={{ $json.query.url || $json.body.url || '' }}"
            },
            {
              "name": "text_content",
              "type": "string",
              "value": "={{ $json.query.text_content || $json.body.text_content || '' }}"
            },
            {
              "name": "summary_length",
              "type": "string",
              "value": "={{ $json.query.summary_length || $json.body.summary_length || 'standard' }}"
            },
            {
              "name": "focus",
              "type": "string",
              "value": "={{ $json.query.focus || $json.body.focus || 'key_points' }}"
            },
            {
              "name": "language",
              "type": "string",
              "value": "={{ $json.query.language || $json.body.language || 'english' }}"
            },
            {
              "name": "file_content",
              "type": "string",
              "value": "={{ $json.query.file_content || $json.body.file_content || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7852e220-e77c-4b4a-a74b-110e0c733364",
      "name": "抓取网页内容",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -880,
        1664
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "3f933b84-8a3f-441b-8a17-412c63563d2d",
      "name": "清理抓取的内容",
      "type": "n8n-nodes-base.set",
      "position": [
        -656,
        1664
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "80a0f7dc-ee66-4499-ac84-1e21fca8e6c7",
              "name": "raw_content",
              "type": "string",
              "value": "={{ $json.raw_content || $json.data || $json.text || $json.text_content || $json.ParsedResults?.[0]?.ParsedText || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "282c6c04-0ba1-47b8-a900-1c3416440710",
      "name": "摘要 URL 内容",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -432,
        1664
      ],
      "parameters": {
        "text": "=Summarize: {{ $json.raw_content }}",
        "options": {
          "systemMessage": "=Current date and time {{ $now }}\n\nYou are an expert content summarizer. \nCreate a {{ $('Extract URL Parameters').item.json.summary_length === 'brief' ? '**brief** (2-3 sentences)' : $('Extract URL Parameters').item.json.summary_length === 'detailed' ? '**detailed** (2-3 paragraphs)' : '**standard** (1 paragraph)' }} summary in markdown format.\n\n**Focus**: \n{{ $('Extract URL Parameters').item.json.focus === 'numbers_data' \n    ? 'Extract key **numbers**, **percentages**, and quantitative data' \n    : $('Extract URL Parameters').item.json.focus === 'conclusions' \n    ? 'Highlight main **conclusions** and findings' \n    : $('Extract URL Parameters').item.json.focus === 'action_items' \n    ? 'List concrete **action items** and recommendations' \n    : 'Capture essential **key points** and main themes' }}\n\n**Formatting Guidelines:**\n- Use **bold** for key terms and important information\n- Use *italics* for emphasis\n- Use bullet points (- ) for lists\n- Use ## for section headers when appropriate\n- Lead with the most important information\n- Include specific details that support main points\n- Ensure the summary is complete and stands alone\n\n**Language**: \n{{ $('Extract URL Parameters').item.json.language === 'spanish' \n    ? 'Spanish' \n    : $('Extract URL Parameters').item.json.language === 'french' \n    ? 'French' \n    : $('Extract URL Parameters').item.json.language === 'german' \n    ? 'German' \n    : 'English' }}\n\nContent: {{ $json.raw_content }}\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "dcf23318-5a25-43d9-9ccd-a896cc89798e",
      "name": "OpenAI GPT-4.1(URL)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -368,
        1888
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "mvWns3smwtPV0N7O",
          "name": "Dummy OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "98fa70c1-9594-4d83-bb91-52148d80a450",
      "name": "格式化 URL 摘要",
      "type": "n8n-nodes-base.set",
      "position": [
        -80,
        1664
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "content",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0d20d017-d4bd-48c4-b931-e30d5ecde720",
      "name": "返回 URL 摘要",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        144,
        1664
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.content }}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "2f0e7464-f607-4333-b34a-398ad045cf25",
      "name": "提取文本参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1088,
        2192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "input_type",
              "type": "string",
              "value": "={{ $json.query.input_type || $json.body.input_type || 'url' }}"
            },
            {
              "name": "url",
              "type": "string",
              "value": "={{ $json.query.url || $json.body.url || '' }}"
            },
            {
              "name": "text_content",
              "type": "string",
              "value": "={{ $json.query.text_content || $json.body.text_content || '' }}"
            },
            {
              "name": "summary_length",
              "type": "string",
              "value": "={{ $json.query.summary_length || $json.body.summary_length || 'standard' }}"
            },
            {
              "name": "focus",
              "type": "string",
              "value": "={{ $json.query.focus || $json.body.focus || 'key_points' }}"
            },
            {
              "name": "language",
              "type": "string",
              "value": "={{ $json.query.language || $json.body.language || 'english' }}"
            },
            {
              "name": "file_content",
              "type": "string",
              "value": "={{ $json.query.file_content || $json.body.file_content || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ec5daf86-5837-4489-b967-ca01fd53259b",
      "name": "处理原始文本输入",
      "type": "n8n-nodes-base.set",
      "position": [
        -864,
        2192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "80a0f7dc-ee66-4499-ac84-1e21fca8e6c7",
              "name": "raw_content",
              "type": "string",
              "value": "={{ $json.raw_content || $json.data || $json.text || $json.text_content || $json.ParsedResults?.[0]?.ParsedText || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4bb0543c-9611-47fa-9e88-46ab3a5e46d4",
      "name": "摘要文本输入",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -640,
        2192
      ],
      "parameters": {
        "text": "=Summarize: {{ $json.raw_content }}",
        "options": {
          "systemMessage": "=Current date and time {{ $now }}\n\nYou are an expert content summarizer. \nCreate a {{ $('Extract Text Parameters').item.json.summary_length === 'brief' ? '**brief** (2-3 sentences)' : $('Extract Text Parameters').item.json.summary_length === 'detailed' ? '**detailed** (2-3 paragraphs)' : '**standard** (1 paragraph)' }} summary in markdown format.\n\n**Focus**: \n{{ $('Extract Text Parameters').item.json.focus === 'numbers_data' \n    ? 'Extract key **numbers**, **percentages**, and quantitative data' \n    : $('Extract Text Parameters').item.json.focus === 'conclusions' \n    ? 'Highlight main **conclusions** and findings' \n    : $('Extract Text Parameters').item.json.focus === 'action_items' \n    ? 'List concrete **action items** and recommendations' \n    : 'Capture essential **key points** and main themes' }}\n\n**Formatting Guidelines:**\n- Use **bold** for key terms and important information\n- Use *italics* for emphasis\n- Use bullet points (- ) for lists\n- Use ## for section headers when appropriate\n- Lead with the most important information\n- Include specific details that support main points\n- Ensure the summary is complete and stands alone\n\n**Language**: \n{{ $('Extract Text Parameters').item.json.language === 'spanish' \n    ? 'Spanish' \n    : $('Extract Text Parameters').item.json.language === 'french' \n    ? 'French' \n    : $('Extract Text Parameters').item.json.language === 'german' \n    ? 'German' \n    : 'English' }}\n\nContent: {{ $json.raw_content }}\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "144b8cd0-318a-4cd8-9d4c-e3416e59338f",
      "name": "OpenAI GPT-4.1(文本)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -640,
        2400
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "mvWns3smwtPV0N7O",
          "name": "Dummy OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2072b47a-130d-417f-8bdf-77ee04f0c39b",
      "name": "格式化文本摘要",
      "type": "n8n-nodes-base.set",
      "position": [
        -288,
        2192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "content",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9024a142-c034-428e-92b6-3de102474dac",
      "name": "返回文本摘要",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -64,
        2192
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.content }}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "37c4c9a2-04e6-49e1-a763-86a9cb5f19d2",
      "name": "提取文件参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -1088,
        2800
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "input_type",
              "type": "string",
              "value": "={{ $json.query.input_type || $json.body.input_type || 'url' }}"
            },
            {
              "name": "url",
              "type": "string",
              "value": "={{ $json.query.url || $json.body.url || '' }}"
            },
            {
              "name": "text_content",
              "type": "string",
              "value": "={{ $json.query.text_content || $json.body.text_content || '' }}"
            },
            {
              "name": "summary_length",
              "type": "string",
              "value": "={{ $json.query.summary_length || $json.body.summary_length || 'standard' }}"
            },
            {
              "name": "focus",
              "type": "string",
              "value": "={{ $json.query.focus || $json.body.focus || 'key_points' }}"
            },
            {
              "name": "language",
              "type": "string",
              "value": "={{ $json.query.language || $json.body.language || 'english' }}"
            },
            {
              "name": "file_content",
              "type": "string",
              "value": "={{ $json.query.file_content || $json.body.file_content || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6ebe835e-2ef9-45ae-b984-bb21a873ab24",
      "name": "下载 PDF 文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -864,
        2800
      ],
      "parameters": {
        "url": "={{ $json.file_content }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "49568f41-51f7-4006-84e6-e154ca1e35d4",
      "name": "从 PDF 提取文本",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -640,
        2800
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "db8f0fb5-f524-4489-8bb8-70677bbaa03b",
      "name": "检查 PDF 文本提取",
      "type": "n8n-nodes-base.if",
      "position": [
        -416,
        2800
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "88a7fc31-aac6-4e2f-899e-c250feef5f10",
              "operator": {
                "type": "string",
                "operation": "empty"
              },
              "leftValue": "={{ $json.text }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "714729b2-4a02-4685-b7db-4b0346928940",
      "name": "映射 OCR 语言代码",
      "type": "n8n-nodes-base.function",
      "position": [
        -192,
        2624
      ],
      "parameters": {
        "functionCode": "const lang = $json.language?.toLowerCase() || 'english';\nlet code = 'eng';\nif (lang.includes('spanish')) code = 'spa';\nelse if (lang.includes('french')) code = 'fra';\nelse if (lang.includes('german')) code = 'ger';\nreturn { json: { language_code: code } };"
      },
      "typeVersion": 1
    },
    {
      "id": "ffd527f9-3c97-4eef-9693-be431f79187c",
      "name": "OCR 回退处理",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -32,
        2624
      ],
      "parameters": {
        "url": "https://api.ocr.space/parse/image",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "language",
              "value": "={{ $json.language_code }}"
            },
            {
              "name": "isOverlayRequired",
              "value": "false"
            },
            {
              "name": "file",
              "parameterType": "formBinaryData"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "YOUR_OCR_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d0ebcb03-9151-4217-8ede-dfcf5d47ff22",
      "name": "处理提取的文本",
      "type": "n8n-nodes-base.set",
      "position": [
        160,
        2816
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "80a0f7dc-ee66-4499-ac84-1e21fca8e6c7",
              "name": "raw_content",
              "type": "string",
              "value": "={{ $json.raw_content || $json.data || $json.text || $json.text_content || $json.ParsedResults?.[0]?.ParsedText || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0818caf5-6479-4776-bd9f-d73962a09e29",
      "name": "摘要 PDF 内容",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        2800
      ],
      "parameters": {
        "text": "=Summarize: {{ $json.raw_content }}",
        "options": {
          "systemMessage": "=Current date and time {{ $now }}\n\nYou are an expert content summarizer. \nCreate a {{ $('Extract File Parameters').item.json.summary_length === 'brief' ? '**brief** (2-3 sentences)' : $('Extract File Parameters').item.json.summary_length === 'detailed' ? '**detailed** (2-3 paragraphs)' : '**standard** (1 paragraph)' }} summary in markdown format.\n\n**Focus**: \n{{ $('Extract File Parameters').item.json.focus === 'numbers_data' \n    ? 'Extract key **numbers**, **percentages**, and quantitative data' \n    : $('Extract File Parameters').item.json.focus === 'conclusions' \n    ? 'Highlight main **conclusions** and findings' \n    : $('Extract File Parameters').item.json.focus === 'action_items' \n    ? 'List concrete **action items** and recommendations' \n    : 'Capture essential **key points** and main themes' }}\n\n**Formatting Guidelines:**\n- Use **bold** for key terms and important information\n- Use *italics* for emphasis\n- Use bullet points (- ) for lists\n- Use ## for section headers when appropriate\n- Lead with the most important information\n- Include specific details that support main points\n- Ensure the summary is complete and stands alone\n\n**Language**: \n{{ $('Extract File Parameters').item.json.language === 'spanish' \n    ? 'Spanish' \n    : $('Extract File Parameters').item.json.language === 'french' \n    ? 'French' \n    : $('Extract File Parameters').item.json.language === 'german' \n    ? 'German' \n    : 'English' }}\n\nContent: {{ $json.raw_content }}\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "7120dedb-ac90-4aa3-9f3c-ba65aeb698ff",
      "name": "OpenAI GPT-4.1(PDF)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        560,
        3024
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "mvWns3smwtPV0N7O",
          "name": "Dummy OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c3463333-53ed-4a1e-9f57-363a8723409b",
      "name": "格式化 PDF 摘要",
      "type": "n8n-nodes-base.set",
      "position": [
        832,
        2800
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "content",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6b02e945-6b55-4648-b3b3-7cde2d6d6724",
      "name": "返回 PDF 摘要",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1056,
        2800
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.content }}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "a0bfcac9-cfd6-4822-b8a7-5bc0b50b1483",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2752,
        2048
      ],
      "parameters": {
        "color": 3,
        "width": 528,
        "height": 80,
        "content": "## 重要"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "tKU8rgsN4cH2Mv9F",
    "executionOrder": "v1"
  },
  "versionId": "783b71e8-de94-4085-9588-cfdbd63cd25c",
  "connections": {
    "OCR.Space": {
      "main": [
        [
          {
            "node": "Clean & Format Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "summarize-url": {
      "main": [
        [
          {
            "node": "Extract URL Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch PDF File": {
      "main": [
        [
          {
            "node": "Extract From File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "summarize-file": {
      "main": [
        [
          {
            "node": "Extract File Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "summarize-text": {
      "main": [
        [
          {
            "node": "Extract Text Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initial Trigger": {
      "main": [
        [
          {
            "node": "Parse Input Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download PDF File": {
      "main": [
        [
          {
            "node": "Extract Text from PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract From File": {
      "main": [
        [
          {
            "node": "Check If Extracted Text Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch URL Content": {
      "main": [
        [
          {
            "node": "Clean & Format Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Type Switch": {
      "main": [
        [
          {
            "node": "Fetch URL Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Clean & Format Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch PDF File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Language Code": {
      "main": [
        [
          {
            "node": "OCR.Space",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format PDF Summary": {
      "main": [
        [
          {
            "node": "Return PDF Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format URL Summary": {
      "main": [
        [
          {
            "node": "Return URL Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Text Summary": {
      "main": [
        [
          {
            "node": "Return Text Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4.1 (PDF)": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize PDF Content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4.1 (URL)": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize URL Content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Text Input": {
      "main": [
        [
          {
            "node": "Format Text Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Scraped Content": {
      "main": [
        [
          {
            "node": "Summarize URL Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from PDF": {
      "main": [
        [
          {
            "node": "Check PDF Text Extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map OCR Language Code": {
      "main": [
        [
          {
            "node": "OCR Fallback Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4.1 (Text)": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize Text Input",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Summarize PDF Content": {
      "main": [
        [
          {
            "node": "Format PDF Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize URL Content": {
      "main": [
        [
          {
            "node": "Format URL Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Format Content": {
      "main": [
        [
          {
            "node": "Generate AI Summary (Unified)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract URL Parameters": {
      "main": [
        [
          {
            "node": "Scrape Web Page Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Input Parameters": {
      "main": [
        [
          {
            "node": "Input Type Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Extracted Text": {
      "main": [
        [
          {
            "node": "Summarize PDF Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Raw Text Input": {
      "main": [
        [
          {
            "node": "Summarize Text Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structure Final Output": {
      "main": [
        [
          {
            "node": "Return Summary Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract File Parameters": {
      "main": [
        [
          {
            "node": "Download PDF File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text Parameters": {
      "main": [
        [
          {
            "node": "Process Raw Text Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OCR Fallback Processing": {
      "main": [
        [
          {
            "node": "Process Extracted Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Web Page Content": {
      "main": [
        [
          {
            "node": "Clean Scraped Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4.1 (Unified)": {
      "ai_languageModel": [
        [
          {
            "node": "Generate AI Summary (Unified)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check PDF Text Extraction": {
      "main": [
        [
          {
            "node": "Map OCR Language Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Process Extracted Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Extracted Text Empty": {
      "main": [
        [
          {
            "node": "Map Language Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Clean & Format Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Summary (Unified)": {
      "main": [
        [
          {
            "node": "Structure Final Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 杂项, AI 摘要总结, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量47
分类3
节点类型11
难度说明

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

外部链接
在 n8n.io 查看

分享此工作流