N
n8n Store
Workflow Market
AI-Powered Company Documents Q&A Assistant with Google Drive and GPT-4 Mini

AI-Powered Company Documents Q&A Assistant with Google Drive and GPT-4 Mini

by rawsun0070 views

Description

Categories

🤖 AI & Machine Learning

Nodes Used

n8n-nodes-base.webhookn8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.googleDrive@n8n/n8n-nodes-langchain.agentn8n-nodes-base.respondToWebhookn8n-nodes-base.googleDriveTrigger@n8n/n8n-nodes-langchain.lmChatOpenAi@n8n/n8n-nodes-langchain.embeddingsOpenAi
PriceFree
Views0
Last Updated11/28/2025
workflow.json
{
  "meta": {
    "instanceId": "",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d1ec41c9-88e2-42aa-b3d9-8f1f65a964fd",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1072,
        -48
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "4966431c-87a2-4afe-bc0d-4120062885cc",
      "name": "Watch Company Docs Folder",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -400,
        -256
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b787795b-d183-4e33-9074-7ebfef517eb2",
      "name": "Fetch New Document",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -160,
        -256
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "binaryPropertyName": "data"
        },
        "operation": "download",
        "authentication": "serviceAccount"
      },
      "typeVersion": 3
    },
    {
      "id": "4c91fd55-c584-4f9b-a4ae-b1546044a84d",
      "name": "Store in Knowledge Base",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        80,
        -256
      ],
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "company docs",
          "cachedResultName": "company docs"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "3293c954-3568-4c37-8a2c-b43d6961360e",
      "name": " Load Document Content",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        176,
        -32
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "binaryMode": "specificField",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ca2b0852-a98c-4a45-ae3c-6d31c955574f",
      "name": "Split into Searchable Chunks",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        224,
        176
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "c79fccdf-931e-4f50-9b16-3bc019f9a06b",
      "name": "Generate Document Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -464,
        272
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "bb4d9fff-c7ea-4f40-89b4-979ec4219a30",
      "name": "Company Knowledge Assistant",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1040,
        -256
      ],
      "parameters": {
        "text": "={{ $json.body.data }}",
        "options": {
          "systemMessage": "You are a helpful company assistant with access to company documents stored in a knowledge base.\n\nYour task is to:\n1. Answer user questions accurately using information from the company documents\n2. Use the Vector Store tool to search for relevant information when needed\n3. Cite specific documents or sections when providing answers\n4. If you cannot find relevant information, politely say so and offer to help with something else\n5. Be professional, concise, and helpful in all responses\n\nAlways prioritize accuracy over speculation."
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "b5470c8d-d729-46c8-bdb3-f45779735a27",
      "name": "Search Company Documents",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        -896,
        80
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 5,
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "company docs"
        },
        "toolDescription": "Search company documents and knowledge base for relevant information. Use this when users ask questions about company policies, procedures, or any documented information."
      },
      "typeVersion": 1.3
    },
    {
      "id": "4e027156-55e9-4875-9166-fb94b314ba32",
      "name": "Receive User Question",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1280,
        -256
      ],
      "webhookId": "{{WEBHOOK_ID_PLACEHOLDER}}",
      "parameters": {
        "path": "chat-input",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d330e63d-fb0c-4399-810f-cca702679bb3",
      "name": "Conversation History",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -960,
        -80
      ],
      "parameters": {
        "sessionKey": "={{ $json.body.session_id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "0eabe2dc-de90-4021-aa72-b48724b2ad2f",
      "name": "Send Answer to User",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -688,
        -256
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.output }}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "41d2d50c-c6e7-4d34-b567-30448b0e873e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1872,
        -352
      ],
      "parameters": {
        "width": 432,
        "height": 672,
        "content": "## How it works\n\nThis workflow creates an AI assistant that answers questions using your company's documents. It has two independent flows:\n\n**Document Processing**: Monitors a Google Drive folder for new files. When detected, documents are downloaded, split into chunks, converted to embeddings, and stored in an in-memory vector database for semantic search.\n\n**Chat Interface**: Users send questions via webhook. The AI agent searches the knowledge base, retrieves relevant context, and generates accurate answers with source citations. Conversation history is maintained for context-aware responses.\n\n## Setup steps\n\n1. Connect your Google Drive OAuth2 credentials to the trigger node\n2. Select the folder to monitor in \"Watch Company Docs Folder\"\n3. Add your OpenAI API key to both the Chat Model and Embeddings nodes\n4. Configure Google Service Account for document downloads\n5. Test the webhook endpoint with a POST request containing `{\"data\": \"your question\", \"session_id\": \"user123\"}`"
      },
      "typeVersion": 1
    },
    {
      "id": "52aea4b4-6923-4778-9fc1-accdf0d6d1f0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        -448
      ],
      "parameters": {
        "color": 6,
        "width": 688,
        "height": 112,
        "content": "## Chat Flow\nWebhook receives questions → AI agent searches vector store → GPT-4 generates answers with citations → Response sent back to user"
      },
      "typeVersion": 1
    },
    {
      "id": "1967eeaf-3615-497d-8b24-5ca4cdfe3ec0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -448
      ],
      "parameters": {
        "color": 6,
        "width": 752,
        "height": 112,
        "content": "## Document Processing\nDrive trigger detects new files → Downloads document → Extracts and chunks text → Generates embeddings → Stores in vector database"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Company Knowledge Assistant",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch New Document": {
      "main": [
        [
          {
            "node": "Store in Knowledge Base",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversation History": {
      "ai_memory": [
        [
          {
            "node": "Company Knowledge Assistant",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Receive User Question": {
      "main": [
        [
          {
            "node": "Company Knowledge Assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    " Load Document Content": {
      "ai_document": [
        [
          {
            "node": "Store in Knowledge Base",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Search Company Documents": {
      "ai_tool": [
        [
          {
            "node": "Company Knowledge Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Watch Company Docs Folder": {
      "main": [
        [
          {
            "node": "Fetch New Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Knowledge Assistant": {
      "main": [
        [
          {
            "node": "Send Answer to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Document Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Store in Knowledge Base",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Search Company Documents",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Split into Searchable Chunks": {
      "ai_textSplitter": [
        [
          {
            "node": " Load Document Content",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流