PDFから契約詳細を抽出し、Slack、GPT-4o、Google Sheetsに整理する

上級

これはDocument Extraction, AI Summarization, Multimodal AI分野の自動化ワークフローで、19個のノードを含みます。主にSlack, Switch, HttpRequest, GoogleSheets, SlackTriggerなどのノードを使用。 PDFから契約詳細を抽出し、Slack、GPT-4o、Google Sheetsに整理する

前提条件
  • Slack Bot Token または Webhook URL
  • ターゲットAPIの認証情報が必要な場合あり
  • Google Sheets API認証情報
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "e04cc86c30b0cecda8e6bbc7cc41459d9bf4d76816638a14d42d636b91913ebc",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "af0cd5b9-3301-4668-93ec-71e1033d3778",
      "name": "構造化出力",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        544,
        160
      ],
      "parameters": {
        "jsonSchemaExample": "[{\n\t\"Client\": \"XYZ Inc\",\n\t\"Service Provider\": \"ABC Inc\",\n  \"Effective Date\": \"2025/04/29\",\n  \"Expiration Date\" : \"2025/05/29\",\n  \"Signature Date\" : \"2025/05/29\",\n  \"Contract Value\": \"11,000\"\n}]"
      },
      "typeVersion": 1.3
    },
    {
      "id": "c02b6fd7-70d6-47ae-8ea5-2c1ead2e17da",
      "name": "AIモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        400,
        160
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "vWYprn1xB4TGPXdo",
          "name": "OpenAi account 2"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c506d41b-aec6-48ad-a33e-15b02e256bb1",
      "name": "契約ファイル受信",
      "type": "n8n-nodes-base.slackTrigger",
      "position": [
        -640,
        32
      ],
      "webhookId": "0c333af6-a04b-489e-b267-e60cb4664128",
      "parameters": {
        "options": {},
        "trigger": [
          "message"
        ],
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09EG2EN9AA",
          "cachedResultName": "contract"
        }
      },
      "credentials": {
        "slackApi": {
          "id": "VLK4L2mMCF7UFZXF",
          "name": "Slack account 4"
        }
      },
      "notesInFlow": false,
      "typeVersion": 1
    },
    {
      "id": "df8d6f3e-4f5c-4c58-8967-87180c27c8b5",
      "name": "ファイル形式確認",
      "type": "n8n-nodes-base.switch",
      "position": [
        -400,
        16
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "PDF",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3540ad45-eb8f-47c8-9942-c1670ec8acc0",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.files[0].filetype }}",
                    "rightValue": "pdf"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "WORD",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "659d35f5-0ae3-4a75-9744-8a776a6b0391",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.files[0].filetype }}",
                    "rightValue": "docx"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Others",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1d14871d-5607-4315-b9c8-01eeacf2f916",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "6a259139-f6be-42f0-9018-8e3466a28742",
      "name": "PDFダウンロード",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -48,
        -160
      ],
      "parameters": {
        "url": "={{ $json.files[0].url_private_download }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        },
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "slackApi"
      },
      "credentials": {
        "slackApi": {
          "id": "gLK2woy6bUlX7kdV",
          "name": "Slack account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0407b590-908d-4d11-8fbb-6ff8a8e93a30",
      "name": "PDFからのテキスト抽出",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        176,
        -160
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "71b2b5e9-ea55-4985-8c56-561b14fb02df",
      "name": "WordからPDFへ変換",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -48,
        32
      ],
      "parameters": {
        "url": "={{ $json.files[0].converted_pdf }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        },
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "slackApi"
      },
      "credentials": {
        "slackApi": {
          "id": "gLK2woy6bUlX7kdV",
          "name": "Slack account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ab96f6e9-eb93-4b16-ae44-85eb8f3e0c77",
      "name": "PDFからのテキスト抽出1",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        176,
        32
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "0050c560-3da1-4ad1-ae77-933bf857c780",
      "name": "エラーメッセージ送信",
      "type": "n8n-nodes-base.slack",
      "position": [
        -48,
        176
      ],
      "webhookId": "97cb885e-d1af-4a93-8e27-a4bf6000ca99",
      "parameters": {
        "text": "=Only PDF or Word format contracts can be uploaded.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09EG2EN9AA",
          "cachedResultName": "contract"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "VLK4L2mMCF7UFZXF",
          "name": "Slack account 4"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ca620d80-1959-4d72-95a1-2df99125b248",
      "name": "契約内容分析",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        400,
        -64
      ],
      "parameters": {
        "text": "=please read and understand the input data({{ $json.text }}). I would like you to extract Client, Service Provider, Effective Date, Expiration Date, Signature Date and Contract Value. ",
        "options": {
          "systemMessage": ""
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "ff81dc90-bc72-4b4f-9751-432399ddfedf",
      "name": "Google Sheetsへ保存",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        752,
        -64
      ],
      "parameters": {
        "columns": {
          "value": {
            "Client": "={{ $json.output[0].Client }}",
            "Contract Value": "={{ $json.output[0]['Contract Value'] }}",
            "Effective Date": "={{ $json.output[0]['Effective Date'] }}",
            "Signature Date": "={{ $json.output[0]['Signature Date'] }}",
            "Expiration Date": "={{ $json.output[0]['Expiration Date'] }}",
            "Service Provider": "={{ $json.output[0]['Service Provider'] }}"
          },
          "schema": [
            {
              "id": "Client",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Client",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Service Provider",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Service Provider",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Effective Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Effective Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Expiration Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Expiration Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Signature Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Signature Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Contract Value",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Contract Value",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ggkr6gOWmzcIbqBVuh-HVkKVvBaFj-WuYsprlMPMfOk/edit#gid=0",
          "cachedResultName": "sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ggkr6gOWmzcIbqBVuh-HVkKVvBaFj-WuYsprlMPMfOk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ggkr6gOWmzcIbqBVuh-HVkKVvBaFj-WuYsprlMPMfOk/edit?usp=drivesdk",
          "cachedResultName": "contract_management_sheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "OADOUEa3B96W0iqk",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "1b8f9d44-5c0a-4eb9-aace-509fec6337fc",
      "name": "Slackで通知",
      "type": "n8n-nodes-base.slack",
      "position": [
        976,
        -64
      ],
      "webhookId": "d443ab23-594e-48f7-bf05-b85e81c967f7",
      "parameters": {
        "text": "=---\nClient: {{ $json.Client }}\nService Provider: {{ $json['Service Provider'] }}\nExpiration Date: {{ $json['Expiration Date'] }}\nEffective Date: {{ $json['Effective Date'] }}\nSignature Date: {{ $json['Signature Date'] }}\nContract Value: {{ $json['Contract Value'] }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09EG2EN9AA",
          "cachedResultName": "contract"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "VLK4L2mMCF7UFZXF",
          "name": "Slack account 4"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1c065db0-d6b2-40ae-a2e3-5c5581be0db6",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -240
      ],
      "parameters": {
        "width": 288,
        "height": 480,
        "content": "## 2. Check file format\n\n- PDF → Go to Download PDF\n- Word → Go to Convert Word to PDF\n- Others → Send Error Message\n\n\n**Note**: Contracts are generally created in PDF or Word format, so only these two formats are supported."
      },
      "typeVersion": 1
    },
    {
      "id": "d3422fd9-df2d-48bb-bada-b631843758b4",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        -240
      ],
      "parameters": {
        "width": 288,
        "height": 480,
        "content": "## 1. Receive Contract File\n\n📃This node receives a contract file uploaded via Slack.\n📃The file is then passed to the workflow for format checking and further processing."
      },
      "typeVersion": 1
    },
    {
      "id": "3f441264-8120-43ea-ad29-4e8de52b9b39",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -240
      ],
      "parameters": {
        "width": 416,
        "height": 576,
        "content": "## 3. Transform file into text\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f14068f8-e327-4bcd-8c72-d684faba5dd4",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -240
      ],
      "parameters": {
        "width": 304,
        "height": 576,
        "content": "## 4. Analyze Contract Content\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b38f1853-a844-43ae-92fb-c4169a495541",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -240
      ],
      "parameters": {
        "width": 224,
        "height": 368,
        "content": "## 5. Save to Google Sheets\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d55089f4-7887-4875-852c-e740db02344c",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        -240
      ],
      "parameters": {
        "width": 256,
        "height": 368,
        "content": "## 6. Notify on Slack"
      },
      "typeVersion": 1
    },
    {
      "id": "013d03b1-ebc7-41cf-973b-49fb6968f7eb",
      "name": "付箋6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        -496
      ],
      "parameters": {
        "width": 576,
        "height": 1392,
        "content": "## Extract and Manage Contracts with Slack, GPT-4o, and Google Sheets.\n\nManaging contracts manually is time-consuming and prone to human error, especially when documents need to be shared, tracked, and stored across different tools. This workflow automates the entire process by capturing contract PDFs and Words uploaded to Slack, extracting key information with GPT, and organizing the data into a structured format inside Google Sheets. Essential fields such as client, service provider, contract value, and important dates are automatically parsed and logged, eliminating repetitive manual entry. Once the data is saved, a confirmation message is posted back to Slack so your team can quickly verify that everything has been recorded accurately.\n\n## Who’s it for\nThis workflow is ideal for operations teams, legal departments, or growing businesses that manage multiple contracts and want to maintain accuracy without spending hours on administration. By integrating Slack, GPT, and Google Sheets, you gain a simple but powerful contract management system that reduces risk, improves visibility, and keeps everyone aligned. Instead of scattered files and manual spreadsheets, you have a single automated pipeline that ensures your contract data is always up to date and accessible.\n\n## How it works\n- The workflow is triggered when a contract in PDF or Word format is shared in the designated Slack channel.\n- The uploaded file is automatically retrieved for processing.\n- Its content is extracted and converted into plain text.\n- If the file is not in PDF or Word format, an error message is sent.\n- GPT interprets the extracted text and structures the essential fields (e.g., Client, Service Provider, Effective Date, Expiration Date, Signature Date, Contract Value).\n- The structured contract information is appended as a new row in the contract tracker spreadsheet on Google Sheets.\n- A summary of the saved data is posted back to Slack for quick validation.\n\n## How to set up\n- You need to import this workflow into your n8n instance.\n- You must authenticate your Slack account and select the target channel for contract submissions.\n- You should link your Google account and specify the spreadsheet where the contract data will be stored. In this template, the required columns are Client, Service Provider, Effective Date, Expiration Date, Signature Date, and Contract Value.\n- You can adjust the GPT parsing prompt to match the specific fields that your organization requires.\n- You upload a sample contract in PDF or Word format to Slack and verify that the extracted data is correctly recorded in Google Sheets.\n\n## Requirements\n- You must have an active n8n instance in the cloud.\n- You need a Slack account with permission to upload files and send messages.\n- You must use a Google Sheets account with edit access to the target spreadsheet.\n- You need a GPT integration (e.g., OpenAI) to enable AI-powered text parsing.\n\n## How to customize the workflow\nYou can modify this workflow to fit your organization’s unique contract needs. For example, you may update the GPT parsing prompt to capture additional fields, change the target Google Sheets structure, or integrate notifications into other tools. You have full flexibility to expand or simplify the steps so the workflow matches your team’s processes and compliance requirements.\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "c02b6fd7-70d6-47ae-8ea5-2c1ead2e17da": {
      "ai_languageModel": [
        [
          {
            "node": "ca620d80-1959-4d72-95a1-2df99125b248",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "6a259139-f6be-42f0-9018-8e3466a28742": {
      "main": [
        [
          {
            "node": "0407b590-908d-4d11-8fbb-6ff8a8e93a30",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1b8f9d44-5c0a-4eb9-aace-509fec6337fc": {
      "main": [
        []
      ]
    },
    "af0cd5b9-3301-4668-93ec-71e1033d3778": {
      "ai_outputParser": [
        [
          {
            "node": "ca620d80-1959-4d72-95a1-2df99125b248",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "df8d6f3e-4f5c-4c58-8967-87180c27c8b5": {
      "main": [
        [
          {
            "node": "6a259139-f6be-42f0-9018-8e3466a28742",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "71b2b5e9-ea55-4985-8c56-561b14fb02df",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "0050c560-3da1-4ad1-ae77-933bf857c780",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0050c560-3da1-4ad1-ae77-933bf857c780": {
      "main": [
        []
      ]
    },
    "71b2b5e9-ea55-4985-8c56-561b14fb02df": {
      "main": [
        [
          {
            "node": "ab96f6e9-eb93-4b16-ae44-85eb8f3e0c77",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0407b590-908d-4d11-8fbb-6ff8a8e93a30": {
      "main": [
        [
          {
            "node": "ca620d80-1959-4d72-95a1-2df99125b248",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c506d41b-aec6-48ad-a33e-15b02e256bb1": {
      "main": [
        [
          {
            "node": "df8d6f3e-4f5c-4c58-8967-87180c27c8b5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ff81dc90-bc72-4b4f-9751-432399ddfedf": {
      "main": [
        [
          {
            "node": "1b8f9d44-5c0a-4eb9-aace-509fec6337fc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ab96f6e9-eb93-4b16-ae44-85eb8f3e0c77": {
      "main": [
        [
          {
            "node": "ca620d80-1959-4d72-95a1-2df99125b248",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ca620d80-1959-4d72-95a1-2df99125b248": {
      "main": [
        [
          {
            "node": "ff81dc90-bc72-4b4f-9751-432399ddfedf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - 文書抽出, AI要約, マルチモーダルAI

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数19
カテゴリー3
ノードタイプ10
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
Toshiki Hirao

Toshiki Hirao

@hirao

dTosh Inc., CEO Nara Institute of Science and Technology, Assistant Professor

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34