8
n8n 中文网amn8n.com

从PDF起草摘要工作流

中级

这是一个Document Extraction, AI Summarization领域的自动化工作流,包含 14 个节点。主要使用 Set, Code, Gmail, GoogleDocs, GoogleDrive 等节点。 使用Google Drive、GPT-4和邮件通知从PDF生成专业文档草稿

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Drive API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "64CHobveljzJ6yLy",
  "meta": {
    "instanceId": "6304e8877aa0fde3913b14034debe07006963fb497d63f280a91bbd75c6c24e1",
    "templateCredsSetupCompleted": true
  },
  "name": "从 PDF 起草摘要工作流",
  "tags": [
    {
      "id": "jn7ddn1yzNyOdoUL",
      "name": "Google Drive",
      "createdAt": "2025-06-28T19:24:08.794Z",
      "updatedAt": "2025-06-28T19:24:08.794Z"
    },
    {
      "id": "wZ14hcyo2pYAOVlF",
      "name": "OpenAI",
      "createdAt": "2025-06-28T18:46:13.462Z",
      "updatedAt": "2025-06-28T18:46:13.462Z"
    },
    {
      "id": "aSK69HfkFtgcLEqN",
      "name": "PDF",
      "createdAt": "2025-06-28T19:24:31.376Z",
      "updatedAt": "2025-06-28T19:24:31.376Z"
    },
    {
      "id": "FSPdk64o7xvj2PAR",
      "name": "Document Automation",
      "createdAt": "2025-06-28T19:24:42.665Z",
      "updatedAt": "2025-06-28T19:24:42.665Z"
    },
    {
      "id": "pD2RVg49fBlIR8pA",
      "name": "Gmail",
      "createdAt": "2025-06-28T19:24:47.979Z",
      "updatedAt": "2025-06-28T19:24:47.979Z"
    }
  ],
  "nodes": [
    {
      "id": "0828fc42-59fb-40e3-b8d2-c7c00ce873a5",
      "name": "Google Drive 触发器",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        40,
        160
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1etyS5ZZLmzmocuemFs7v012CRkUoxm8s",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1etyS5ZZLmzmocuemFs7v012CRkUoxm8s",
          "cachedResultName": "AI_Folder"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "0Fpa71OWKyUgnl7d",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9e9ef858-3a08-4c0a-b230-792c77a32ade",
      "name": "从文件中提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        480,
        160
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "c82d3fee-ab06-49a1-acc5-770f3462d804",
      "name": "信息提取器",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        920,
        160
      ],
      "parameters": {
        "text": "=You are an intelligent information extractor.\n\nYour task is to analyze the following PDF content and extract all relevant information, such as:\n\n- Names of people, organizations, or entities involved  \n- Dates, times, and locations  \n- Document numbers, reference IDs, or case/file numbers  \n- Financial amounts (e.g., totals, balances, payments)  \n- Descriptions of events, actions taken, or decisions made  \n- Responsibilities, obligations, or instructions  \n- References to laws, policies, contracts, or agreements  \n- Any technical, legal, business, or procedural terms  \n- Outcomes, conclusions, or next steps (if applicable)\n\nPresent your output in **organized paragraphs or bullet points** grouped by category.  \nAvoid summarizing — your goal is to **accurately extract and present the original information** as clearly and completely as possible.\n\n---\n\nPDF Content:  \n{{ $json.combined_text }}\n",
        "options": {
          "systemPromptTemplate": "You are an expert extraction algorithm.\n\nOnly extract relevant information from the text.\n\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value."
        },
        "attributes": {
          "attributes": [
            {
              "name": "Date ",
              "type": "date",
              "description": "Extract the Date "
            },
            {
              "name": "Letter Head Name",
              "description": "Extract the Name"
            },
            {
              "name": "Address",
              "description": "Extract the address it was sent"
            },
            {
              "name": "Date of Loss ",
              "type": "date",
              "description": "Extract the Date of Loss"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "254616b5-5270-47b7-9abd-e8fc19ec0ea3",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        940,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4",
          "cachedResultName": "gpt-4"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Yks1Eic3YR07Cpm6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cd5312ee-6680-4c43-a35a-de0088363cc3",
      "name": "创建 Google 文档",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1640,
        160
      ],
      "parameters": {
        "title": "=Draft Document",
        "folderId": "1etyS5ZZLmzmocuemFs7v012CRkUoxm8s"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "dSGiWWxQdhY5ywpg",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "caee797a-3c11-4f71-9afd-4ecc8163a68d",
      "name": "聚合提取文本",
      "type": "n8n-nodes-base.code",
      "position": [
        700,
        160
      ],
      "parameters": {
        "jsCode": "let combinedText = '';\n\nfor (const item of items) {\n  const text = item.json.extracted_text || item.json.text || '';\n  if (typeof text === 'string' && text.trim()) {\n    combinedText += text.trim() + '\\n---\\n'; // Delimit between PDFs\n  }\n}\n\nif (combinedText === '') {\n  return [{\n    json: {\n      data: 'No substantial text could be extracted from the provided PDFs.'\n    }\n  }];\n}\n\nreturn [{\n  json: {\n    combined_text: combinedText\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7d3b7269-b1d0-4c32-b094-fef84a8d9b90",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 1220,
        "height": 480,
        "content": "此步骤从指定的 Google Drive 文件夹中检索 PDF,并使用 OpenAI 代理从中提取关键信息。提取过程可以定制,以针对 PDF 二进制内容中的特定数据,确保最终草稿中包含正确的信息。目前,它会捕获所有看起来与生成完整草稿相关的详细信息。"
      },
      "typeVersion": 1
    },
    {
      "id": "f78cfa9f-dddb-4154-a18c-2a07cfe49e56",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 1640,
        "height": 480,
        "content": "工作流的这一部分使用 OpenAI 代理基于从 PDF 提取的二进制数据生成草稿。然后,它在同一 Google Drive 文件夹内创建一个 Google 文档,并用生成的内容更新它。最后,工作流捕获文档的 URL 并发送一封包含已完成草稿链接的摘要邮件。"
      },
      "typeVersion": 1
    },
    {
      "id": "f957fb25-a35d-43fd-8641-5d3ba1a1fb5a",
      "name": "邮件摘要代理",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2080,
        160
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a professional assistant writing a concise email summary. Your task is to extract **3–5 key points** from the following extracted text. These points should be:\n- Clearly written and easy to scan\n- Highly relevant to claims, coverage, losses, or responsible parties\n- Based on facts from the text — do not guess\n\nStart the response with: **“Summary of Drafted Document:”**, then list each bullet point using dashes.\n\nAvoid repeating any of the text verbatim unless it's a proper name or ID number.\n\n---\nText to summarize:\n{{ $('Aggregate Extract Text').item.json.combined_text }}\n"
            }
          ]
        },
        "simplify": false
      },
      "credentials": {
        "openAiApi": {
          "id": "Yks1Eic3YR07Cpm6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "8955dc77-672b-4fbc-943f-472f5120a03a",
      "name": "起草代理",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1280,
        160
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini-2025-04-14",
          "cachedResultName": "GPT-4.1-MINI-2025-04-14"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "You are a professional assistant that summarizes PDF documents into well-written, structured summaries. Use a formal tone, clear organization, and complete sentences. Include all relevant names, dates, references, and outcomes. Do not copy the text verbatim—rephrase and summarize it."
            },
            {
              "content": "={\n  \"values\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a highly skilled assistant specializing in drafting professional documents. Your expertise spans legal, business, technical, and general formats. Your job is to summarize extracted information from PDFs into well-written, formal drafts suitable for professional use.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Here is the extracted information:\\n\\n{{ $('Aggregate Extract Text').item.json.combined_text }}\\n\\nPlease write a clear, structured summary of the PDF using this information. Use complete sentences and logical flow. Do not copy the input text—rephrase and synthesize it.\"\n    }\n  ]\n}\n\n\n"
            }
          ]
        },
        "simplify": false
      },
      "credentials": {
        "openAiApi": {
          "id": "Yks1Eic3YR07Cpm6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "457dae81-f2b1-4719-a573-efe5e755e7be",
      "name": "下载 Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        260,
        160
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "0Fpa71OWKyUgnl7d",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "940c2be4-ea9b-4851-aa87-3a8677133723",
      "name": "更新 Google 文档",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1880,
        160
      ],
      "parameters": {
        "simple": false,
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $('Drafting Agent').item.json.choices[0].message.content }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "={{ $node[\"CREATE GOOGLE DOC\"].json.id }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "dSGiWWxQdhY5ywpg",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "6dea5a05-adac-41e8-adbb-4eb352dcc20b",
      "name": "编辑邮件消息",
      "type": "n8n-nodes-base.set",
      "position": [
        2440,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a221e0c5-4dcb-459a-8147-abbabbf34170",
              "name": "DraftURL",
              "type": "string",
              "value": "=https://docs.google.com/document/d/{{ $('CREATE GOOGLE DOC').first().json.id }}/edit"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0ff51fb9-f2f1-4684-aef0-93f96eb7f758",
      "name": "发送邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2680,
        160
      ],
      "webhookId": "87feb027-5ab7-4084-a184-f456f42c5596",
      "parameters": {
        "sendTo": "mgullo24@gmail.com",
        "message": "=Hello,\n\nYour PDF extraction and draft generation process has completed successfully.\n\n\n{{ $node[\"Email Summary Agent\"].json.choices[0].message.content }}\n\nYou can view and edit the full draft here:\n{{ $node[\"Edit Email Message\"].json.DraftURL }}\n\nIf you have any questions or need further processing, please reply to this email.\n\n—  \nThis is an automated message from the Draft Agent Bot.\n",
        "options": {},
        "subject": "=Draft Agent",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "B0oVer8pX52LHrvw",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0f0bd4cd-e871-4a16-868f-4a650be1c198",
  "connections": {
    "Drafting Agent": {
      "main": [
        [
          {
            "node": "CREATE GOOGLE DOC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CREATE GOOGLE DOC": {
      "main": [
        [
          {
            "node": "UPDATE Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Aggregate Extract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Edit Email Message": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UPDATE Google Docs": {
      "main": [
        [
          {
            "node": "Email Summary Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Summary Agent": {
      "main": [
        [
          {
            "node": "Edit Email Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Google Drive": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Drafting Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Extract Text": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 文档提取, AI 摘要总结

需要付费吗?

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

工作流信息
难度等级
中级
节点数量14
分类2
节点类型11
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Michael Gullo

Michael Gullo

@drdoom

I’m passionate about using n8n to create realistic workflows that help working class people simplify their daily tasks. My workflows aim to make life easier by eliminating mundane, repetitive responsibilities that take up valuable time. I love turning automation into a tool that lets people focus on what matters most to them.

外部链接
在 n8n.io 查看

分享此工作流