8
n8n 中文网amn8n.com

使用LlamaParse解析PDF并保存至Airtable

高级

这是一个AI领域的自动化工作流,包含 18 个节点。主要使用 Set, Code, Webhook, Airtable, GoogleDrive 等节点,结合人工智能技术实现智能自动化。 使用LlamaParse解析PDF并保存至Airtable

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • Airtable API Key
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "nodes": [
    {
      "id": "9df72ef9-3b9d-40e4-9cb5-a5ada153c0bb",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        120,
        -180
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "wpiZXesxk9S8fkVG",
          "name": "Google Drive account 2"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e21bb906-658c-4a52-9c7b-b77d6e0e7ea5",
      "name": "上传文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        360,
        -180
      ],
      "parameters": {
        "url": "https://api.cloud.llamaindex.ai/api/parsing/upload",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "webhook_url",
              "value": "https://n8n.lowcoding.dev/webhook/0f7f5ebb-8b66-453b-a818-20cc3647c783"
            },
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            },
            {
              "name": "disable_ocr",
              "value": "true"
            },
            {
              "name": "disable_image_extraction",
              "value": "True"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "Bearer "
            },
            {
              "name": "parsing_instruction",
              "value": "Please extract invoice line items: Name, Quantity, Unit Price, Amount "
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2a0c2331-4612-4b92-a0cc-b316bc663907",
      "name": "Google Drive 触发器",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -80,
        -180
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1IC39VXU8rewBU85offxYlBd9QlYzf8S7",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1IC39VXU8rewBU85offxYlBd9QlYzf8S7",
          "cachedResultName": "Invoices"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "wpiZXesxk9S8fkVG",
          "name": "Google Drive account 2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4ad70b03-54f1-4715-9848-56fa6ba18278",
      "name": "创建发票",
      "type": "n8n-nodes-base.airtable",
      "position": [
        400,
        340
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appndgSF4faN4jPXi",
          "cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi",
          "cachedResultName": "Philipp's Base"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tbloPc7Eay4Cvwysq",
          "cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi/tbloPc7Eay4Cvwysq",
          "cachedResultName": "Invoices"
        },
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Line Items",
              "type": "array",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Line Items",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "create"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "XT7hvl1w201jtBhx",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a408eeb4-2dc2-45ff-a989-92676356f596",
      "name": "创建行项目",
      "type": "n8n-nodes-base.airtable",
      "position": [
        800,
        340
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appndgSF4faN4jPXi",
          "cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi",
          "cachedResultName": "Philipp's Base"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblIuVR9ocAomznzK",
          "cachedResultUrl": "https://airtable.com/appndgSF4faN4jPXi/tblIuVR9ocAomznzK",
          "cachedResultName": "Line Items"
        },
        "columns": {
          "value": {
            "Qty": "={{ $json.qty }}",
            "Amount": "={{ parseFloat($json.amount.replace('$', '').trim()) }}",
            "Invoices": "=[\"{{ $('Create Invoice').item.json.id }}\"]",
            "Unit price": "={{ parseFloat($json.unit_price.replace('$', '').trim()) }}",
            "Description": "={{ $json.description }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Qty",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Qty",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Unit price",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Unit price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoices",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Invoices",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "create"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "XT7hvl1w201jtBhx",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "7ee324e8-6df3-48d6-b1b8-6fdb610b1ec7",
      "name": "OpenAI - 提取行项目",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        180,
        340
      ],
      "parameters": {
        "url": "=https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"model\": \"gpt-4o-mini\",\n    \"messages\": [\n      {\n        \"role\": \"system\",\n        \"content\": {{ JSON.stringify($('Set Fields').item.json.prompt) }}\n      },\n      {\n        \"role\": \"user\",\n        \"content\": {{ JSON.stringify( JSON.stringify($('Webhook').item.json.body.json[0].items) ) }}\n      }\n    ],\n  \"response_format\":{ \"type\": \"json_schema\", \"json_schema\":  {{ $('Set Fields').item.json.schema }}\n\n }\n  }",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "9RivS2BmSh1DDBFm",
          "name": "OpenAi account 3"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "eda31919-9091-4d45-bd73-4609b71f93a9",
      "name": "设置字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -40,
        340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "dc09a5b4-ff6a-4cee-b87e-35de7336ac05",
              "name": "prompt",
              "type": "string",
              "value": "Please, process parsed data and return only needed."
            },
            {
              "id": "4e0f9af6-517f-42af-9ced-df0e8a7118b0",
              "name": "schema",
              "type": "string",
              "value": "={\n  \"name\": \"generate_schema\",\n  \"description\": \"Generate schema for an array of objects representing items with their descriptions, quantities, unit prices, and amounts.\",\n  \"strict\": true,\n  \"schema\": {\n    \"type\": \"object\",\n    \"required\": [\n      \"items\"\n    ],\n    \"properties\": {\n      \"items\": {\n        \"type\": \"array\",\n        \"description\": \"Array of item objects\",\n        \"items\": {\n          \"type\": \"object\",\n          \"required\": [\n            \"description\",\n            \"qty\",\n            \"unit_price\",\n            \"amount\"\n          ],\n          \"properties\": {\n            \"description\": {\n              \"type\": \"string\",\n              \"description\": \"Description of the item\"\n            },\n            \"qty\": {\n              \"type\": \"string\",\n              \"description\": \"Quantity of the item\"\n            },\n            \"unit_price\": {\n              \"type\": \"string\",\n              \"description\": \"Unit price of the item formatted as a string\"\n            },\n            \"amount\": {\n              \"type\": \"string\",\n              \"description\": \"Total amount for the item formatted as a string\"\n            }\n          },\n          \"additionalProperties\": false\n        }\n      }\n    },\n    \"additionalProperties\": false\n  }\n}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cc0d97d8-fb62-43eb-b484-4dd39f8db4b4",
      "name": "处理行项目",
      "type": "n8n-nodes-base.code",
      "position": [
        600,
        340
      ],
      "parameters": {
        "jsCode": "// Get the input from the \"OpenAI - Extract Line Items\" node\nconst input = $(\"OpenAI - Extract Line Items\").first().json;\n\n// Initialize an array for the output\nconst outputItems = [];\n\n// Navigate to the 'content' field in the choices array\nconst content = input.choices[0]?.message?.content;\n\nif (content) {\n  try {\n    // Parse the stringified JSON in the 'content' field\n    const parsedContent = JSON.parse(content);\n\n    // Extract 'items' and add them to the output array\n    if (Array.isArray(parsedContent.items)) {\n      outputItems.push(...parsedContent.items.map(i => ({ json: i })));\n    }\n  } catch (error) {\n    // Handle any parsing errors\n    console.error('Error parsing content:', error);\n  }\n}\n\n// Return the extracted items\nreturn outputItems;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "741dc44e-6d47-4a77-80c2-5e18b291da33",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -220,
        340
      ],
      "webhookId": "0f7f5ebb-8b66-453b-a818-20cc3647c783",
      "parameters": {
        "path": "0f7f5ebb-8b66-453b-a818-20cc3647c783",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "fbc196c8-7518-4deb-ac47-f37f1b8150eb",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -300
      ],
      "parameters": {
        "width": 920,
        "height": 400,
        "content": "## 场景 1"
      },
      "typeVersion": 1
    },
    {
      "id": "96368d41-7886-487f-a8a7-e4dac3b01f45",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        240
      ],
      "parameters": {
        "width": 1340,
        "height": 460,
        "content": "## 场景 2"
      },
      "typeVersion": 1
    },
    {
      "id": "6b7c94d7-c844-4246-ba1a-cea5937792db",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 270,
        "height": 80,
        "content": "### 替换 Google Drive 连接"
      },
      "typeVersion": 1
    },
    {
      "id": "9c8141d0-428a-44e5-b900-b07fa64db4f5",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 170,
        "height": 80,
        "content": "### 替换请求头中的 API 密钥"
      },
      "typeVersion": 1
    },
    {
      "id": "48243fe4-4ed1-43dc-b508-8b3f9472bb67",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        540
      ],
      "parameters": {
        "color": 3,
        "width": 170,
        "height": 80,
        "content": "### 替换 OpenAI 连接"
      },
      "typeVersion": 1
    },
    {
      "id": "ffc6b530-69ab-4ccb-945d-94f8fdc1e3ab",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        540
      ],
      "parameters": {
        "color": 3,
        "width": 530,
        "height": 80,
        "content": "### 替换 Airtable 连接"
      },
      "typeVersion": 1
    },
    {
      "id": "15047f43-5f7e-4c70-a754-fffb41c04611",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -760,
        380
      ],
      "parameters": {
        "color": 7,
        "width": 330.5152611046425,
        "height": 239.5888196628349,
        "content": "### ... 或观看设置视频 [7 分钟]"
      },
      "typeVersion": 1
    },
    {
      "id": "812f6cc7-a093-41d0-9750-48253d9f04a8",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1060,
        -300
      ],
      "parameters": {
        "color": 7,
        "width": 636,
        "height": 657,
        "content": "![5min Logo](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/banner.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "a80e6528-cf79-4229-8c58-6856fd86b6e7",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1060,
        380
      ],
      "parameters": {
        "color": 7,
        "width": 280,
        "height": 626,
        "content": "### 设置步骤"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Set Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Fields": {
      "main": [
        [
          {
            "node": "OpenAI - Extract Line Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Upload File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Invoice": {
      "main": [
        [
          {
            "node": "Process Line Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Line Items": {
      "main": [
        [
          {
            "node": "Create Line Item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Extract Line Items": {
      "main": [
        [
          {
            "node": "Create Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 人工智能

需要付费吗?

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

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

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

作者
Mark Shcherbakov

Mark Shcherbakov

@lowcodingdev

I am a business analyst with a development background, dedicated to helping small businesses and entrepreneurs leverage cloud services for increased efficiency. My expertise lies in automating manual workflows, integrating data from multiple cloud service providers, creating insightful dashboards, and building custom CRM systems.

外部链接
在 n8n.io 查看

分享此工作流