8
n8n 中文网amn8n.com

开发完成 - FAX 内容提取

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 Set, Code, FormTrigger, GoogleDrive, HttpRequest 等节点。 传真和 PDF 数据提取工作流:使用 Google Gemini 和 Google Sheets

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "CACB2vgfyxBJE30X",
  "meta": {
    "instanceId": "{YOUR_INSTANCE_ID}",
    "templateCredsSetupCompleted": true
  },
  "name": "开发完成 - FAX 内容提取",
  "tags": [
    {
      "id": "m1paRrANi4GrQXxX",
      "name": "AI Internal",
      "createdAt": "2025-09-18T04:05:25.667Z",
      "updatedAt": "2025-09-18T04:05:25.667Z"
    }
  ],
  "nodes": [
    {
      "id": "5be36f47-e7ed-464a-bf73-6573abed5fc6",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -336,
        160
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "4e9b17d5-0ded-4edb-baa5-b7eae5d0ecfa",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -528,
        160
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Upload file').item.json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "{YOUR_GOOGLE_DRIVE_CREDENTIAL_ID}",
          "name": "Google Drive Account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "579a0a77-34bd-4f38-a22a-dfc68421b0b9",
      "name": "调用具有 PDF 功能的 Gemini 2.0 Flash",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -96,
        160
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"inline_data\": {\n            \"mime_type\": \"application/pdf\",\n            \"data\": \"{{ $json.data }}\"\n          }\n        },\n        {\n          \"text\": \"{{ $('Define Prompt').item.json.prompt }}\"\n        }\n      ]\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "{YOUR_GEMINI_CREDENTIAL_ID}",
          "name": "Gemini API Account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "07953a5f-115a-4697-9961-f5d7046ec6db",
      "name": "定义提示",
      "type": "n8n-nodes-base.set",
      "position": [
        -768,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "dba23ef5-95df-496a-8e24-c7c1544533d2",
              "name": "prompt",
              "type": "string",
              "value": "You are an expert document analyzer.   Your task is to read a fax document that may contain a medical or administrative form with multiple fields, tables, and notes. The document may contain both filled and unfilled fields.    Instructions:   1. Extract only the filled or relevant fields from the form.   2. Ignore empty fields, irrelevant boilerplate text, transmission details, or formatting artifacts.   3. Present the extracted information in a clean structured format.   4. Capture key details such as:    - Patient Information (ID, Name, DOB, Sex, Address, Diagnosis, Allergies, Functional Limitations, Mental Status, etc.)      - Provider Information (Provider Name, Address, Physician Name, Certification Dates, Provider No.)      - Medical Data (Diagnosis codes, Medications, Procedures, Treatments, Orders, Prognosis, Safety Measures, Activities Permitted, Goals)      - Certification / Signatures (Physician signature, Date signed, Certification statement)      - Any explicit instructions, precautions, or urgent notes.   5. If the document contains critical health conditions, precautions, or deadlines, highlight them separately.   6. Do not alter or interpret the medical data—extract it exactly as written. "
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e570291a-6ca2-49f4-be02-a837be4444f6",
      "name": "上传文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1072,
        160
      ],
      "parameters": {
        "name": "Fax test",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "{YOUR_GOOGLE_DRIVE_FOLDER_ID}",
          "cachedResultUrl": "https://drive.google.com/drive/folders/{YOUR_GOOGLE_DRIVE_FOLDER_ID}",
          "cachedResultName": "FAX Test"
        },
        "inputDataFieldName": "Upload_File"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "{YOUR_GOOGLE_DRIVE_CREDENTIAL_ID}",
          "name": "Google Drive Account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "37801239-6daf-4445-9004-01523094018a",
      "name": "在表格中追加行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        848,
        160
      ],
      "parameters": {
        "columns": {
          "value": {
            "Gender": "={{ $json.output.Gender }}",
            "SOC Date": "={{ $json.output.SOCDate }}",
            "Allergies": "={{ $json.output.Allergies }}",
            "Prognosis": "={{ $json.output.Prognosis }}",
            "Patient ID": "={{ $json.output.PatientID }}",
            "Date Signed": "={{ $json.output.DateSigned }}",
            "Patient Name": "={{ $json.output.PatientName }}",
            "Provider No.": "={{ $json.output.ProviderNo }}",
            "Date of Birth": "={{ $json.output.DateOfBirth }}",
            "Mental Status": "={{ $json.output['Mental Status'] }}",
            "Medical Record": "={{ $json.output.MedicalRecord }}",
            "Patient Address": "={{ $json.output.PatientAddress }}",
            "Safety Measures": "={{ $json.output.SafetyMeasures }}"
          },
          "schema": [
            {
              "id": "Patient ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Patient ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "SOC Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "SOC Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Medical Record",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Medical Record",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Provider No.",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Provider No.",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Patient Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Patient Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Patient Address",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Patient Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date of Birth",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date of Birth",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Safety Measures",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Safety Measures",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Allergies",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Allergies",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Gender",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Gender",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Mental Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Mental Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Prognosis",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Prognosis",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date Signed",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date Signed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Information"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{YOUR_GOOGLE_SHEET_ID}/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "{YOUR_GOOGLE_SHEET_ID}",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/{YOUR_GOOGLE_SHEET_ID}/edit?usp=drivesdk",
          "cachedResultName": "Fax Test Extracted"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "{YOUR_GOOGLE_SHEETS_CREDENTIAL_ID}",
          "name": "Google Sheets Account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ca632b40-621b-4359-9e80-31706f374831",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        384,
        160
      ],
      "parameters": {
        "text": "==You are a strict JSON parser.\nReturn ONLY valid JSON that matches this schema. \nNo markdown, no comments, no extra text.\n\nSchema:\n{\n  \"PatientID\": \"string or null\",\n  \"SOCDate\": \"string or null\",\n  \"MedicalRecord\": \"string or null\",\n  \"ProviderNo\": \"string or null\",\n  \"PatientName\": \"string or null\",\n  \"PatientAddress\": \"string or null\",\n  \"DateOfBirth\": \"string or null\",\n  \"SafetyMeasures\": \"string or null\",\n  \"Allergies\": \"string or null\",\n  \"Gender\": \"string or null\",\n  \"Mental Status\": \"string or null\",\n  \"Prognosis\": \"string or null\",\n  \"DateSigned\": \"string or null\"\n}\n\nRules:\n- Include **all** keys, even if null.\n- Do not add markdown (like ```json).\n- Do not add extra text.\n\nExtracted Fax Text:\n\"\"\"\n{{ $json.extractedText }}\n\"\"\"\n",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "retryOnFail": true,
      "typeVersion": 1.7
    },
    {
      "id": "0330fa20-6915-42c5-8769-0f2658f5b035",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        368,
        336
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "{YOUR_GEMINI_CREDENTIAL_ID}",
          "name": "Gemini API Account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d022685e-fe91-4980-b257-0ec2e7989491",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        544,
        336
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"PatientID\": \"ID - 123\",\n  \"SOCDate\": \"10/12/2026\",\n  \"MedicalRecord\": \"No\",\n  \"ProviderNo\": \"MR - 000\",\n  \"PatientName\": \"Tom Cruise\",\n  \"PatientAddress\": \"F-19 Lamine Street, Barcelona, Spain\",\n  \"DateOfBirth\": \"09/11/2020\",\n  \"SafetyMeasures\": \"Precaution\",\n  \"Allergies\": \"Nose Allergy\",\n  \"Gender\": \"F\",\n  \"Mental Status\": \"Agitated\",\n  \"Prognosis\": \"Fair\",\n  \"DateSigned\": \"25/09/2025\"\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "bea9b647-0e25-47ee-9eab-c952f512b03f",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1376,
        160
      ],
      "webhookId": "{YOUR_WEBHOOK_ID}",
      "parameters": {
        "options": {},
        "formTitle": "Fax File",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Upload File",
              "multipleFiles": false,
              "requiredField": true
            }
          ]
        },
        "formDescription": "User can Upload the Fax PDF directly here!"
      },
      "typeVersion": 2.2
    },
    {
      "id": "a452a474-38ee-426b-b225-fd8f65bbd878",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        176,
        160
      ],
      "parameters": {
        "jsCode": "// Function to clean and extract plain text\nreturn $input.all().map(item => {\n  const candidates = item.json.candidates || [];\n  const firstCandidate = candidates[0] || {};\n  const parts = firstCandidate.content?.parts || [];\n  let extractedText = parts[0]?.text || \"\";\n\n  // Clean markdown-like artifacts\n  extractedText = extractedText\n    .replace(/\\*\\*/g, \"\")   // remove bold markers\n    .replace(/\\*/g, \"\")     // remove list markers\n    .trim();\n\n  return {\n    json: {\n      extractedText\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "26f7cfb0-39bb-47f8-8f6c-4d5e87dd999c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 272,
        "height": 320,
        "content": "## 1. 从此开始:表单触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "43885ab6-67d3-4d46-8202-83e3228d68b2",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 288,
        "height": 336,
        "content": "## 2. 配置:上传到 Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "c0e958e2-f39b-4463-8ef1-a46ae0a129d7",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        -16
      ],
      "parameters": {
        "color": 6,
        "width": 224,
        "height": 320,
        "content": "## 3. 自定义 AI 大脑(第 1 部分)"
      },
      "typeVersion": 1
    },
    {
      "id": "8c973931-b16b-4c81-888d-5869b52544e8",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -16
      ],
      "parameters": {
        "color": 2,
        "width": 272,
        "height": 320,
        "content": "## 4. 首次 AI 调用:PDF 提取"
      },
      "typeVersion": 1
    },
    {
      "id": "1bc9982f-4880-4552-88c6-b5f2f296d1d7",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -48
      ],
      "parameters": {
        "color": 3,
        "width": 352,
        "height": 320,
        "content": "## 5. 自定义 AI 大脑(第 2 部分)"
      },
      "typeVersion": 1
    },
    {
      "id": "c4e2b238-0152-46f2-8195-d25ad26d5882",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -48
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 352,
        "content": "## 最后一步:保存到 Google Sheets"
      },
      "typeVersion": 1
    },
    {
      "id": "5e10a3b1-73f2-4263-8ebd-2f9e0b7db9bf",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -416
      ],
      "parameters": {
        "color": 5,
        "width": 480,
        "height": 336,
        "content": "## 提取值"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7c15e905-123e-4655-bc9f-b712a70ddda2",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Define Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define Prompt": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Call Gemini 2.0 Flash with PDF Capabilities",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Call Gemini 2.0 Flash with PDF Capabilities": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

作者
Intuz

Intuz

@intuz

Workflow automation can help automate your routine activities and help saves $$$, as well as hours of time. As a boutique tech consulting company, Intuz help businesses with custom AI/ML, AI Workflow Automations, and software development. Automate your business workflow for: Sales Marketing Accounting Finance Operations E-Commerce Customer Support Admin & Backoffice Logistics & Supply Chain

外部链接
在 n8n.io 查看

分享此工作流