AutomationFlowsAI & RAG › Extract and Organize Contract Details From Pdfs with Slack, Gpt-4o, and…

Extract and Organize Contract Details From Pdfs with Slack, Gpt-4o, and…

Original n8n title: Extract and Organize Contract Details From Pdfs with Slack, Gpt-4o, and Google Sheets

ByToshiki Hirao @hirao on n8n.io

Managing 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…

Event trigger★★★★☆ complexityAI-powered19 nodesOutput Parser StructuredOpenAI ChatSlack TriggerHTTP RequestSlackAgentGoogle Sheets
AI & RAG Trigger: Event Nodes: 19 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #8440 — we link there as the canonical source.

This workflow follows the Agent → Google Sheets recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "af0cd5b9-3301-4668-93ec-71e1033d3778",
      "name": "Structure Output",
      "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 model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        400,
        160
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c506d41b-aec6-48ad-a33e-15b02e256bb1",
      "name": "Receive Contract File",
      "type": "n8n-nodes-base.slackTrigger",
      "position": [
        -640,
        32
      ],
      "parameters": {
        "options": {},
        "trigger": [
          "message"
        ],
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09EG2EN9AA",
          "cachedResultName": "contract"
        }
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": false,
      "typeVersion": 1
    },
    {
      "id": "df8d6f3e-4f5c-4c58-8967-87180c27c8b5",
      "name": "Check File Format",
      "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": "Download 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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0407b590-908d-4d11-8fbb-6ff8a8e93a30",
      "name": "Extract Text from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        176,
        -160
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "71b2b5e9-ea55-4985-8c56-561b14fb02df",
      "name": "Convert Word to 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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ab96f6e9-eb93-4b16-ae44-85eb8f3e0c77",
      "name": "Extract Text from PDF1",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        176,
        32
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "0050c560-3da1-4ad1-ae77-933bf857c780",
      "name": "Send Error Message",
      "type": "n8n-nodes-base.slack",
      "position": [
        -48,
        176
      ],
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ca620d80-1959-4d72-95a1-2df99125b248",
      "name": "Analyze Contract Content",
      "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": "Save to 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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "1b8f9d44-5c0a-4eb9-aace-509fec6337fc",
      "name": "Notify on Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        976,
        -64
      ],
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1c065db0-d6b2-40ae-a2e3-5c5581be0db6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -240
      ],
      "parameters": {
        "width": 288,
        "height": 480,
        "content": "## 2. Check file format\n\n- PDF \u2192 Go to Download PDF\n- Word \u2192 Go to Convert Word to PDF\n- Others \u2192 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": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        -240
      ],
      "parameters": {
        "width": 288,
        "height": 480,
        "content": "## 1. Receive Contract File\n\n\ud83d\udcc3This node receives a contract file uploaded via Slack.\n\ud83d\udcc3The file is then passed to the workflow for format checking and further processing."
      },
      "typeVersion": 1
    },
    {
      "id": "3f441264-8120-43ea-ad29-4e8de52b9b39",
      "name": "Sticky Note2",
      "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": "Sticky Note3",
      "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": "Sticky Note4",
      "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": "Sticky Note5",
      "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": "Sticky Note6",
      "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\u2019s 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\u2019s 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\u2019s processes and compliance requirements.\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Contract Content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Download PDF": {
      "main": [
        [
          {
            "node": "Extract Text from PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify on Slack": {
      "main": [
        []
      ]
    },
    "Structure Output": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze Contract Content",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Check File Format": {
      "main": [
        [
          {
            "node": "Download PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert Word to PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Error Message": {
      "main": [
        []
      ]
    },
    "Convert Word to PDF": {
      "main": [
        [
          {
            "node": "Extract Text from PDF1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from PDF": {
      "main": [
        [
          {
            "node": "Analyze Contract Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Contract File": {
      "main": [
        [
          {
            "node": "Check File Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Google Sheets": {
      "main": [
        [
          {
            "node": "Notify on Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from PDF1": {
      "main": [
        [
          {
            "node": "Analyze Contract Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Contract Content": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Managing 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…

Source: https://n8n.io/workflows/8440/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow streamlines academic assessment through a multi-agent AI system that interprets rubrics, grades submissions, checks for plagiarism, performs quality moderation, generates feedback, and e

HTTP Request, Agent, OpenAI Chat +3
AI & RAG

This workflow automates invoice processing directly from your email inbox.

Gmail Trigger, HTTP Request, Agent +5
AI & RAG

This workflow automates athlete performance monitoring through two parallel pipelines: real-time session analysis triggered by training form submissions, and scheduled weekly performance summaries. De

Form Trigger, Google Sheets, Agent +4
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Form Trigger, HTTP Request, Agent +6
AI & RAG

Streamline your HR recruitment process with this intelligent automation that reads candidate emails and resumes, analyzes them using GPT-4, and automatically shortlists or rejects applicants based on

Gmail, Gmail Trigger, HTTP Request +7