解析PDF、DOCX和图像 - 通过Google Drive使用Mistral OCR含Slack告警

高级

这是一个Content Creation、Multimodal AI领域的自动化工作流,包含 42 个节点。主要使用 Set、Code、Merge、Slack、Switch 等节点。 解析PDF、DOCX和图像 - 通过Google Drive使用Mistral OCR含Slack告警

前置要求
  • Slack Bot Token 或 Webhook URL
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "R82cCEu45d5np7SQ",
  "meta": {
    "instanceId": "387143f3437214efa36d378126c48f0e9f1f4a29675a99d88a37edd8b872d0b0",
    "templateCredsSetupCompleted": true
  },
  "tags": [],
  "nodes": [
    {
      "id": "beeb0f7f-e489-4955-b87a-702ca909628a",
      "name": "文件已创建",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -1792,
        -272
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {
          "fileType": "all"
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 5
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "id",
          "value": ""
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "70baab34-54e4-4933-8093-b28d34090c3e",
      "name": "文件已更新",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -1792,
        -80
      ],
      "parameters": {
        "event": "fileUpdated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 5
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "id",
          "value": ""
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "59f4249a-2445-488e-9a5c-78718506d9f9",
      "name": "设置文件 ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -1296,
        -160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "500b4c9d-617a-4d88-9d74-9beb5922a00a",
              "name": "file_id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "d5779b2e-12fd-4a73-9181-da4b9eec5b67",
              "name": "file_name",
              "type": "string",
              "value": "={{ $json.name }}"
            },
            {
              "id": "3349c2ff-89a4-4b95-93b3-52c4d5316127",
              "name": "dest_folder",
              "type": "string",
              "value": "={{ $json.name.split('.').slice(0, -1).join('.'); }}"
            },
            {
              "id": "f79e2578-3375-4e1d-88e0-748e2daac35b",
              "name": "file_name_no_ext",
              "type": "string",
              "value": "={{ $json.name.split('.').slice(0, -1).join('.'); }}"
            },
            {
              "id": "45b4ffe8-1ebc-48f8-8234-c497c4081f39",
              "name": "mime_type",
              "type": "string",
              "value": "={{ $json.mimeType }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9d4db769-a867-4938-b513-c5402f007e4d",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        2208,
        208
      ],
      "parameters": {
        "options": {
          "fileName": "={{ $json.id }}",
          "mimeType": "={{ $json.image_base64.split(';')[0].split(':').pop() }}"
        },
        "operation": "toBinary",
        "sourceProperty": "stripped_image_base64",
        "binaryPropertyName": "=image"
      },
      "typeVersion": 1.1
    },
    {
      "id": "4521d9c9-2040-4181-b298-2ad0640d0002",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        2640,
        -16
      ],
      "parameters": {
        "mode": "chooseBranch",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "9ed3238e-d415-43f7-b452-9806479b7de9",
      "name": "保存图像",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2400,
        208
      ],
      "parameters": {
        "name": "={{ $binary.data.fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Folder').item.json.id }}"
        },
        "inputDataFieldName": "=image"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "fc0c520a-6650-4952-a161-5fe389ff9dfa",
      "name": "拆分图片",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1808,
        208
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "images"
      },
      "typeVersion": 1
    },
    {
      "id": "c5851dc0-b183-46a6-82b9-b8cbf3907248",
      "name": "拆分页面",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1472,
        0
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "body.pages"
      },
      "typeVersion": 1
    },
    {
      "id": "2976c696-75ba-4876-b378-f4db44782da6",
      "name": "OCR 文档",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1216,
        -208
      ],
      "parameters": {
        "url": "https://api.mistral.ai/v1/ocr",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"{{ $('Use Url').item.json.document_type }}\",\n    \"{{ $('Use Url').item.json.document_type }}\": \"data:{{ $('Set File ID').item.json.mime_type }};base64,{{ $('Download File').item.binary.binary_file_data.data }}\"\n  },\n  \"include_image_base64\": true\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi"
      },
      "credentials": {
        "mistralCloudApi": {
          "id": "bya9JfkojsyvQTP1",
          "name": "Mistral Cloud account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "82a0d06b-50e1-4427-a459-45a59ed0ff1c",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1024,
        -208
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Copy file').item.json.id }}"
        },
        "options": {
          "binaryPropertyName": "binary_file_data"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "d6d25c96-67a3-4ae3-873f-2cd54fabb366",
      "name": "创建文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -576,
        -176
      ],
      "parameters": {
        "name": "={{ $('Set File ID').item.json.dest_folder }}_{{ $now.format('yyyyMMdd-hhmmss') }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').item.json.dest_folder_id }}"
        },
        "resource": "folder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c2119a4c-7b3b-465e-9437-12ff585f6bd6",
      "name": "复制文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -208,
        -176
      ],
      "parameters": {
        "name": "={{ $('Set File ID').item.json.file_name }}",
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set File ID').item.json.file_id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Folder').item.json.id }}"
        },
        "operation": "copy",
        "sameFolder": false
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1f4180a9-333a-421c-aea6-0f9666ce55ed",
      "name": "保存页面 MD 文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1808,
        0
      ],
      "parameters": {
        "name": "={{ $('Set File ID').item.json.file_name_no_ext }}_page_{{ String($json.index + 1).padStart($('OCR Document').item.json.body.pages.length.toString().length, '0') }}.md",
        "content": "={{ $json.markdown }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Folder').item.json.id }}"
        },
        "operation": "createFromText"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "45fe0471-0558-49a4-afd9-a63e42ca198f",
      "name": "JavaScript 代码",
      "type": "n8n-nodes-base.code",
      "position": [
        2000,
        -176
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "return { markdown: $json.full_markdown.join('\\n\\n') };"
      },
      "typeVersion": 2
    },
    {
      "id": "0dac4cc0-5506-4690-bd13-c0e4d4bfb91f",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1808,
        -176
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "renameField": true,
              "outputFieldName": "full_markdown",
              "fieldToAggregate": "markdown"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "856f5947-55d6-42c7-91bf-d98f82440094",
      "name": "保存 MD 文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2208,
        -176
      ],
      "parameters": {
        "name": "={{ $('Set File ID').item.json.file_name_no_ext }}.md",
        "content": "={{ $json.markdown }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Folder').item.json.id }}"
        },
        "operation": "createFromText"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c52e230e-1185-4461-a6f5-26204ec481be",
      "name": "保存原始 OCR 文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1472,
        -320
      ],
      "parameters": {
        "name": "={{ $('Set File ID').item.json.file_name_no_ext }}.json",
        "content": "={{ JSON.stringify($json.body, null, 2) }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Folder').item.json.id }}"
        },
        "operation": "createFromText"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "htidcOV6hR8kh9tB",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1cda08ff-f68a-40e6-b0cd-89d7d9f60847",
      "name": "合并1",
      "type": "n8n-nodes-base.merge",
      "position": [
        2864,
        -160
      ],
      "parameters": {
        "mode": "chooseBranch",
        "output": "empty"
      },
      "typeVersion": 3.2
    },
    {
      "id": "2dc3cd63-1430-42ca-a475-caf7e2138b23",
      "name": "在表格中添加 MD 文件",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2400,
        -176
      ],
      "parameters": {
        "columns": {
          "value": {
            "MD File": "=https://drive.google.com/file/d/{{ $json.id }}",
            "Directory": "=https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}"
          },
          "schema": [
            {
              "id": "File Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Directory",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Directory",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "JSON file",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "JSON file",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MD File",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "MD File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Started",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Started",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Completed",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Directory"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mN6Pszfd3D0Vora4Kl8JHJQxuaZ7rD_Zbs0p2wyfnZw/edit#gid=0",
          "cachedResultName": "Files"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').item.json.google_sheet_id }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HTAGRgrsWTF0cfU2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "aee9f683-30ea-4817-a51a-1d6884a630d4",
      "name": "在表格中添加 json 文件",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2640,
        -320
      ],
      "parameters": {
        "columns": {
          "value": {
            "Directory": "=https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}",
            "JSON file": "=https://drive.google.com/file/d/{{ $json.id }}"
          },
          "schema": [
            {
              "id": "File Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Directory",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Directory",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "JSON file",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "JSON file",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MD File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "MD File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Started",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Started",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Completed",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Directory"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mN6Pszfd3D0Vora4Kl8JHJQxuaZ7rD_Zbs0p2wyfnZw/edit#gid=0",
          "cachedResultName": "Files"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').item.json.google_sheet_id }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HTAGRgrsWTF0cfU2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "28756c24-c8ca-4a91-8d98-e4c3bc30a8b3",
      "name": "在表格中创建条目",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -384,
        -176
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Started",
            "Started": "={{ $now.format('yyyy-MM-dd hh:mm:ss') }}",
            "Directory": "=https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}",
            "File Name": "={{ $('Set File ID').item.json.file_name }}"
          },
          "schema": [
            {
              "id": "File Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "File Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Directory",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Directory",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "JSON file",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "JSON file",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MD File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "MD File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Started",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Started",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Completed",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Directory"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mN6Pszfd3D0Vora4Kl8JHJQxuaZ7rD_Zbs0p2wyfnZw/edit#gid=0",
          "cachedResultName": "Files"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').item.json.google_sheet_id }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HTAGRgrsWTF0cfU2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "cb5b2286-ab97-4021-a674-b3ee1289b7f4",
      "name": "在表格中完成任务",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3072,
        -160
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Done",
            "Completed": "={{ $now.format('yyyy-MM-dd hh:mm:ss') }}",
            "Directory": "=https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}"
          },
          "schema": [
            {
              "id": "File Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Directory",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Directory",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "JSON file",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "JSON file",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MD File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "MD File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Started",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Started",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Completed",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Directory"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mN6Pszfd3D0Vora4Kl8JHJQxuaZ7rD_Zbs0p2wyfnZw/edit#gid=0",
          "cachedResultName": "Files"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').item.json.google_sheet_id }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HTAGRgrsWTF0cfU2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e2696f2f-5442-444e-873e-fc40e7b742bb",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 2112,
        "height": 1020,
        "content": "## 4. 上传到 Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "ac3a9ab0-4a5f-4f4d-a882-3c2fdeac3b72",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 1168,
        "height": 1020,
        "content": "## 3. 使用 Mistral Document 执行 OCR"
      },
      "typeVersion": 1
    },
    {
      "id": "440b897e-5a82-45a5-888b-051616e617cc",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 728,
        "height": 1020,
        "content": "## 2. 将文件复制到目标目录"
      },
      "typeVersion": 1
    },
    {
      "id": "a05f0d84-d6dd-4826-b887-919edb13d1c6",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1888,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 728,
        "height": 1020,
        "content": "## 1. 监控 Google Drive 文件夹中的新文件和更新文件"
      },
      "typeVersion": 1
    },
    {
      "id": "41536036-583f-4823-bafe-67d1bac4715a",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1088,
        -528
      ],
      "parameters": {
        "color": 4,
        "width": 432,
        "height": 464,
        "content": "## ⚙️ 更新工作流配置节点"
      },
      "typeVersion": 1
    },
    {
      "id": "a8ed6e6e-6cc7-420a-8be9-f22d1309f55d",
      "name": "工作流配置",
      "type": "n8n-nodes-base.set",
      "position": [
        -928,
        -272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c16e829e-d2f6-49e0-9ffe-ee0c4fca0487",
              "name": "google_sheet_id",
              "type": "string",
              "value": ""
            },
            {
              "id": "4c4d3dc8-d102-40dc-9943-7de13cb2324a",
              "name": "dest_folder_id",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fa6c28ed-ddf0-4616-879d-7ec9bf420a5a",
      "name": "提取 Base64 值",
      "type": "n8n-nodes-base.set",
      "position": [
        2016,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6a29a531-c96a-4c0e-b867-343ab08e884e",
              "name": "stripped_image_base64",
              "type": "string",
              "value": "={{ $json.image_base64.split(',').pop() }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "b1481ea4-501f-492a-9937-ed686d1ac0b1",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1088,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 432,
        "height": 512,
        "content": "## 🔒 设置凭据"
      },
      "typeVersion": 1
    },
    {
      "id": "db701dbb-6259-4b8c-9d6d-ddb556dbebd8",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -16
      ],
      "parameters": {
        "color": 6,
        "width": 528,
        "height": 496,
        "content": "## 📊 Google Sheets 配置"
      },
      "typeVersion": 1
    },
    {
      "id": "ee6c21e6-f369-4575-88dc-7513b6531e4a",
      "name": "使用文档 URL",
      "type": "n8n-nodes-base.set",
      "position": [
        480,
        -208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f229d051-0ac2-4aed-9e6f-6315270a9dad",
              "name": "document_type",
              "type": "string",
              "value": "document_url"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "d019b653-d7e8-4795-9741-a350c98068d4",
      "name": "使用图像 URL",
      "type": "n8n-nodes-base.set",
      "position": [
        480,
        -48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f229d051-0ac2-4aed-9e6f-6315270a9dad",
              "name": "document_type",
              "type": "string",
              "value": "image_url"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "bb211334-f05d-4d96-ac23-33c5fead8c57",
      "name": "确定文档类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        208,
        -192
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6bba9a77-2985-44f3-a746-2431ec9ed3d6",
                    "operator": {
                      "type": "string",
                      "operation": "regex"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.mime_type }}",
                    "rightValue": "^(application\\/pdf|application\\/vnd\\.openxmlformats\\-officedocument\\.wordprocessingml\\.document)$"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3fbb7b81-6b50-4ba9-8c73-0def8f8d4ab6",
                    "operator": {
                      "type": "string",
                      "operation": "regex"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.mime_type }}",
                    "rightValue": "^image\\/(png|jpeg|jpg)$"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "a59769d9-b68b-4492-93b0-453db7e717b1",
      "name": "在表格中添加源文件",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -32,
        -176
      ],
      "parameters": {
        "columns": {
          "value": {
            "File": "=https://drive.google.com/file/d/{{ $json.id }}",
            "Directory": "=https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}"
          },
          "schema": [
            {
              "id": "File Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Directory",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Directory",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "JSON file",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "JSON file",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MD File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "MD File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Started",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Started",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Completed",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Directory"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mN6Pszfd3D0Vora4Kl8JHJQxuaZ7rD_Zbs0p2wyfnZw/edit#gid=0",
          "cachedResultName": "Files"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').item.json.google_sheet_id }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HTAGRgrsWTF0cfU2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e34491fc-b2e2-4356-a37f-aac18d0a7ff6",
      "name": "在表格中设置错误",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        480,
        112
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Unsupported Type",
            "Completed": "={{ $now.format('yyyy-MM-dd hh:mm:ss') }}",
            "Directory": "=https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}"
          },
          "schema": [
            {
              "id": "File Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Directory",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Directory",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "JSON file",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "JSON file",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MD File",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "MD File",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Started",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Started",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Completed",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Directory"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mN6Pszfd3D0Vora4Kl8JHJQxuaZ7rD_Zbs0p2wyfnZw/edit#gid=0",
          "cachedResultName": "Files"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').item.json.google_sheet_id }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "HTAGRgrsWTF0cfU2",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "7c803662-2051-414c-8bc4-9495b4d8034f",
      "name": "发送成功消息",
      "type": "n8n-nodes-base.slack",
      "position": [
        3280,
        288
      ],
      "webhookId": "9d858783-f876-4caa-a3c9-23fbf1e2fb1a",
      "parameters": {
        "text": "=✅ File <https://drive.google.com/file/d/{{ $('Copy file').item.json.id }}|{{ $('Set File ID').item.json.file_name }}> processed.\n📂 Results are available <https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}|here>.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C0462450N",
          "cachedResultName": "general"
        },
        "otherOptions": {
          "mrkdwn": true
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "rTjIbBnywEvLzOof",
          "name": "Slack account"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "53c9dbc7-1b0f-4fc5-8cec-032b79393413",
      "name": "发送错误消息",
      "type": "n8n-nodes-base.slack",
      "position": [
        720,
        288
      ],
      "webhookId": "b7dad5c1-f215-4ca9-baaa-a871c90589cf",
      "parameters": {
        "text": "=⛔ File <https://drive.google.com/file/d/{{ $('Copy file').item.json.id }}|{{ $('Set File ID').item.json.file_name }}> not processed.\nReason: File type is not supported.\n📂 Results are available <https://drive.google.com/drive/folders/{{ $('Create Folder').item.json.id }}|here>.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C0462450N",
          "cachedResultName": "general"
        },
        "otherOptions": {
          "mrkdwn": true
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "rTjIbBnywEvLzOof",
          "name": "Slack account"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "b37f2994-8114-4776-a9ad-c9a48ead4397",
      "name": "使用 URL",
      "type": "n8n-nodes-base.set",
      "position": [
        784,
        -208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e5f7685c-237a-4338-b19a-354d53125129",
              "name": "document_type",
              "type": "string",
              "value": "={{ $json.document_type }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4ee78018-6234-428f-a353-1f3c4ee2ab04",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2976,
        -640
      ],
      "parameters": {
        "width": 1036,
        "height": 1216,
        "content": "## 通过 Google Drive 和 Mistral 自动对 PDF、DOCX 和图像进行 OCR"
      },
      "typeVersion": 1
    },
    {
      "id": "e1fa4d46-e61b-48ac-8fea-dda6daadba9e",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        80
      ],
      "parameters": {
        "color": 4,
        "width": 656,
        "height": 384,
        "content": "## ⚙️ 配置"
      },
      "typeVersion": 1
    },
    {
      "id": "f751279b-aaaf-4237-a7dd-4f767ba04811",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1568,
        -176
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    }
  ],
  "active": false,
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1",
    "timeSavedPerExecution": 5
  },
  "versionId": "9bcb21b1-2f19-4cee-b3c5-9bc580a3e72f",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Complete job in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Use Url": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Copy file": {
      "main": [
        [
          {
            "node": "Add Source File in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Image": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Set File ID": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Pages": {
      "main": [
        [
          {
            "node": "Split Images",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save Page MD File",
            "type": "main",
            "index": 0
          },
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Created": {
      "main": [
        [
          {
            "node": "Loop over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Updated": {
      "main": [
        [
          {
            "node": "Loop over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OCR Document": {
      "main": [
        [
          {
            "node": "Save raw OCR file",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save MD File": {
      "main": [
        [
          {
            "node": "Add MD file in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Images": {
      "main": [
        [
          {
            "node": "Extract Base64 value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Folder": {
      "main": [
        [
          {
            "node": "Create Entry in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "OCR Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Use Image Url": {
      "main": [
        [
          {
            "node": "Use Url",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Save Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop over Items": {
      "main": [
        [],
        [
          {
            "node": "Set File ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Use Document Url": {
      "main": [
        [
          {
            "node": "Use Url",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Page MD File": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Save raw OCR file": {
      "main": [
        [
          {
            "node": "Add json file in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Save MD File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Error Message": {
      "main": [
        [
          {
            "node": "Loop over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Error in Sheet": {
      "main": [
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add MD file in sheet": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Base64 value": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Complete job in sheet": {
      "main": [
        [
          {
            "node": "Send Success  Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Entry in sheet": {
      "main": [
        [
          {
            "node": "Copy file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Success  Message": {
      "main": [
        [
          {
            "node": "Loop over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add json file in sheet": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Create Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Determine Document Type": {
      "main": [
        [
          {
            "node": "Use Document Url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Use Image Url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Error in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Source File in Sheet": {
      "main": [
        [
          {
            "node": "Determine Document Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个高级难度的工作流,适用于Content Creation、Multimodal AI等场景。适合高级用户,包含 16+ 个节点的复杂工作流

需要付费吗?

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

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

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

外部链接
在 n8n.io 上查看 →

分享此工作流