AutomationFlowsAI & RAG › Generate Document Drafts From Pdfs Using Google Drive, Gpt-4 & Notifications

Generate Document Drafts From Pdfs Using Google Drive, Gpt-4 & Notifications

ByMichael Gullo @mgullo on n8n.io

This workflow automates the end-to-end process of extracting and summarizing information from PDFs stored in a specific Google Drive folder. When a new PDF or any binary data is added, the workflow is triggered and begins by downloading and processing the PDF to extract all…

Event trigger★★★★☆ complexityAI-powered14 nodesGoogle Drive TriggerInformation ExtractorOpenAI ChatGoogle DocsOpenAIGoogle DriveGmail
AI & RAG Trigger: Event Nodes: 14 Complexity: ★★★★☆ AI nodes: yes Added:

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

This workflow follows the Gmail → Google Docs 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
{
  "id": "64CHobveljzJ6yLy",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Draft Summary Workflow From PDF",
  "tags": [
    {
      "id": "jn7ddn1yzNyOdoUL",
      "name": "Google Drive",
      "createdAt": "2025-06-28T19:24:08.794Z",
      "updatedAt": "2025-06-28T19:24:08.794Z"
    },
    {
      "id": "wZ14hcyo2pYAOVlF",
      "name": "OpenAI",
      "createdAt": "2025-06-28T18:46:13.462Z",
      "updatedAt": "2025-06-28T18:46:13.462Z"
    },
    {
      "id": "aSK69HfkFtgcLEqN",
      "name": "PDF",
      "createdAt": "2025-06-28T19:24:31.376Z",
      "updatedAt": "2025-06-28T19:24:31.376Z"
    },
    {
      "id": "FSPdk64o7xvj2PAR",
      "name": "Document Automation",
      "createdAt": "2025-06-28T19:24:42.665Z",
      "updatedAt": "2025-06-28T19:24:42.665Z"
    },
    {
      "id": "pD2RVg49fBlIR8pA",
      "name": "Gmail",
      "createdAt": "2025-06-28T19:24:47.979Z",
      "updatedAt": "2025-06-28T19:24:47.979Z"
    }
  ],
  "nodes": [
    {
      "id": "0828fc42-59fb-40e3-b8d2-c7c00ce873a5",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        40,
        160
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1etyS5ZZLmzmocuemFs7v012CRkUoxm8s",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1etyS5ZZLmzmocuemFs7v012CRkUoxm8s",
          "cachedResultName": "AI_Folder"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9e9ef858-3a08-4c0a-b230-792c77a32ade",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        480,
        160
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "c82d3fee-ab06-49a1-acc5-770f3462d804",
      "name": "Information Extractor",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        920,
        160
      ],
      "parameters": {
        "text": "=You are an intelligent information extractor.\n\nYour task is to analyze the following PDF content and extract all relevant information, such as:\n\n- Names of people, organizations, or entities involved  \n- Dates, times, and locations  \n- Document numbers, reference IDs, or case/file numbers  \n- Financial amounts (e.g., totals, balances, payments)  \n- Descriptions of events, actions taken, or decisions made  \n- Responsibilities, obligations, or instructions  \n- References to laws, policies, contracts, or agreements  \n- Any technical, legal, business, or procedural terms  \n- Outcomes, conclusions, or next steps (if applicable)\n\nPresent your output in **organized paragraphs or bullet points** grouped by category.  \nAvoid summarizing \u2014 your goal is to **accurately extract and present the original information** as clearly and completely as possible.\n\n---\n\nPDF Content:  \n{{ $json.combined_text }}\n",
        "options": {
          "systemPromptTemplate": "You are an expert extraction algorithm.\n\nOnly extract relevant information from the text.\n\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value."
        },
        "attributes": {
          "attributes": [
            {
              "name": "Date ",
              "type": "date",
              "description": "Extract the Date "
            },
            {
              "name": "Letter Head Name",
              "description": "Extract the Name"
            },
            {
              "name": "Address",
              "description": "Extract the address it was sent"
            },
            {
              "name": "Date of Loss ",
              "type": "date",
              "description": "Extract the Date of Loss"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "254616b5-5270-47b7-9abd-e8fc19ec0ea3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        940,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4",
          "cachedResultName": "gpt-4"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cd5312ee-6680-4c43-a35a-de0088363cc3",
      "name": "CREATE GOOGLE DOC",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1640,
        160
      ],
      "parameters": {
        "title": "=Draft Document",
        "folderId": "1etyS5ZZLmzmocuemFs7v012CRkUoxm8s"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "caee797a-3c11-4f71-9afd-4ecc8163a68d",
      "name": "Aggregate Extract Text",
      "type": "n8n-nodes-base.code",
      "position": [
        700,
        160
      ],
      "parameters": {
        "jsCode": "let combinedText = '';\n\nfor (const item of items) {\n  const text = item.json.extracted_text || item.json.text || '';\n  if (typeof text === 'string' && text.trim()) {\n    combinedText += text.trim() + '\\n---\\n'; // Delimit between PDFs\n  }\n}\n\nif (combinedText === '') {\n  return [{\n    json: {\n      data: 'No substantial text could be extracted from the provided PDFs.'\n    }\n  }];\n}\n\nreturn [{\n  json: {\n    combined_text: combinedText\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7d3b7269-b1d0-4c32-b094-fef84a8d9b90",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 1220,
        "height": 480,
        "content": "This step retrieves the PDF from the designated Google Drive folder and extracts key information from it using an OpenAI agent. The extraction process can be customized to target specific data within the PDF's binary content, ensuring the right information is included in the final draft. Currently, it captures all details that appear relevant for generating a complete draft."
      },
      "typeVersion": 1
    },
    {
      "id": "f78cfa9f-dddb-4154-a18c-2a07cfe49e56",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 1640,
        "height": 480,
        "content": "This part of the workflow uses an OpenAI agent to generate a draft based on the extracted binary data from the PDF. It then creates a Google Document within the same Google Drive folder and updates it with the generated content. Finally, the workflow captures the document's URL and sends a summary email containing a link to the completed draft."
      },
      "typeVersion": 1
    },
    {
      "id": "f957fb25-a35d-43fd-8641-5d3ba1a1fb5a",
      "name": "Email Summary Agent",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2080,
        160
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a professional assistant writing a concise email summary. Your task is to extract **3\u20135 key points** from the following extracted text. These points should be:\n- Clearly written and easy to scan\n- Highly relevant to claims, coverage, losses, or responsible parties\n- Based on facts from the text \u2014 do not guess\n\nStart the response with: **\u201cSummary of Drafted Document:\u201d**, then list each bullet point using dashes.\n\nAvoid repeating any of the text verbatim unless it's a proper name or ID number.\n\n---\nText to summarize:\n{{ $('Aggregate Extract Text').item.json.combined_text }}\n"
            }
          ]
        },
        "simplify": false
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "8955dc77-672b-4fbc-943f-472f5120a03a",
      "name": "Drafting Agent",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1280,
        160
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini-2025-04-14",
          "cachedResultName": "GPT-4.1-MINI-2025-04-14"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "You are a professional assistant that summarizes PDF documents into well-written, structured summaries. Use a formal tone, clear organization, and complete sentences. Include all relevant names, dates, references, and outcomes. Do not copy the text verbatim\u2014rephrase and summarize it."
            },
            {
              "content": "={\n  \"values\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a highly skilled assistant specializing in drafting professional documents. Your expertise spans legal, business, technical, and general formats. Your job is to summarize extracted information from PDFs into well-written, formal drafts suitable for professional use.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Here is the extracted information:\\n\\n{{ $('Aggregate Extract Text').item.json.combined_text }}\\n\\nPlease write a clear, structured summary of the PDF using this information. Use complete sentences and logical flow. Do not copy the input text\u2014rephrase and synthesize it.\"\n    }\n  ]\n}\n\n\n"
            }
          ]
        },
        "simplify": false
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "457dae81-f2b1-4719-a573-efe5e755e7be",
      "name": "Download Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        260,
        160
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "940c2be4-ea9b-4851-aa87-3a8677133723",
      "name": "UPDATE Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1880,
        160
      ],
      "parameters": {
        "simple": false,
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $('Drafting Agent').item.json.choices[0].message.content }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "={{ $node[\"CREATE GOOGLE DOC\"].json.id }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "6dea5a05-adac-41e8-adbb-4eb352dcc20b",
      "name": "Edit Email Message",
      "type": "n8n-nodes-base.set",
      "position": [
        2440,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a221e0c5-4dcb-459a-8147-abbabbf34170",
              "name": "DraftURL",
              "type": "string",
              "value": "=https://docs.google.com/document/d/{{ $('CREATE GOOGLE DOC').first().json.id }}/edit"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0ff51fb9-f2f1-4684-aef0-93f96eb7f758",
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2680,
        160
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Hello,\n\nYour PDF extraction and draft generation process has completed successfully.\n\n\n{{ $node[\"Email Summary Agent\"].json.choices[0].message.content }}\n\nYou can view and edit the full draft here:\n{{ $node[\"Edit Email Message\"].json.DraftURL }}\n\nIf you have any questions or need further processing, please reply to this email.\n\n\u2014  \nThis is an automated message from the Draft Agent Bot.\n",
        "options": {},
        "subject": "=Draft Agent",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0f0bd4cd-e871-4a16-868f-4a650be1c198",
  "connections": {
    "Drafting Agent": {
      "main": [
        [
          {
            "node": "CREATE GOOGLE DOC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CREATE GOOGLE DOC": {
      "main": [
        [
          {
            "node": "UPDATE Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Aggregate Extract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Edit Email Message": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UPDATE Google Docs": {
      "main": [
        [
          {
            "node": "Email Summary Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Summary Agent": {
      "main": [
        [
          {
            "node": "Edit Email Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Google Drive": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Drafting Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Extract Text": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "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

This workflow automates the end-to-end process of extracting and summarizing information from PDFs stored in a specific Google Drive folder. When a new PDF or any binary data is added, the workflow is triggered and begins by downloading and processing the PDF to extract all…

Source: https://n8n.io/workflows/5441/ — 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 n8n workflow automates the complete processing of PDF invoices with AI-powered data extraction. The workflow monitors a Google Drive folder, extracts important invoice data, and automatically org

Google Drive, Information Extractor, Google Sheets +2
AI & RAG

This workflow is ideal for HR professionals, recruiters, and small businesses looking to streamline resume screening with AI-powered analysis and CRM integration.

Jot Form Trigger, Postgres, OpenAI +5
AI & RAG

This comprehensive workflow automates the entire invoice processing pipeline by monitoring a Google Drive folder for new invoice uploads, intelligently processing both PDF and image formats, extractin

OpenAI Chat, Google Drive Trigger, Google Drive +4
AI & RAG

Detects new unread Gmail messages Extracts sender name for personalized replies Classifies the email into one of four categories Applies the correct Gmail label and either sends an auto-reply, creates

Gmail Trigger, OpenAI Chat, Gmail +4
AI & RAG

thumnail_new. Uses googleDrive, googleSlides, googleSheetsTrigger, googleDocs. Event-driven trigger; 19 nodes.

Google Drive, Google Slides, Google Sheets Trigger +3