8
n8n 한국어amn8n.com

PDF 벡터와 Webhooks를 사용하여 문서 질문과 답변 API를 구축

중급

이것은Internal Wiki, AI RAG, Multimodal AI분야의자동화 워크플로우로, 11개의 노드를 포함합니다.주로 If, Code, Webhook, PdfVector, RespondToWebhook 등의 노드를 사용하며. 사용법 PDF 벡터와 Webhooks를 사용하여 문서 질문 API 구축

사전 요구사항
  • HTTP Webhook 엔드포인트(n8n이 자동으로 생성)
워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
  "meta": {
    "instanceId": "placeholder"
  },
  "nodes": [
    {
      "id": "overview-note",
      "name": "API 개요",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        50,
        50
      ],
      "parameters": {
        "color": 5,
        "width": 350,
        "height": 160,
        "content": "## 🤖 Document Q&A API\n\nRESTful service for document intelligence:\n• **Webhook** endpoint accepts documents\n• **AI processes** questions in context\n• **Returns** JSON with answers & citations\n• **Sub-second** response times"
      },
      "typeVersion": 1
    },
    {
      "id": "request-note",
      "name": "요청 형식",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        450,
        450
      ],
      "parameters": {
        "width": 280,
        "height": 180,
        "content": "## 📥 API Request\n\n**POST** to `/document-qa`\n\nBody:\n```json\n{\n  \"question\": \"Your question\",\n  \"maxTokens\": 500,\n  \"file\": <binary>\n}\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "process-note",
      "name": "질의응답 처리",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        850,
        450
      ],
      "parameters": {
        "width": 260,
        "height": 160,
        "content": "## 🔍 AI Processing\n\nPDF Vector:\n• Parses document\n• Finds relevant sections\n• Generates answer\n• Includes citations\n\n💡 GPT-4 powered"
      },
      "typeVersion": 1
    },
    {
      "id": "response-note",
      "name": "응답 형식",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1150,
        450
      ],
      "parameters": {
        "color": 6,
        "width": 260,
        "height": 180,
        "content": "## 📤 API Response\n\n```json\n{\n  \"success\": true,\n  \"answer\": \"...\",\n  \"sources\": [...],\n  \"confidence\": 0.95\n}\n```\n\n✅ Production ready!"
      },
      "typeVersion": 1
    },
    {
      "id": "webhook-trigger",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "notes": "API endpoint for document Q&A",
      "position": [
        250,
        300
      ],
      "webhookId": "doc-qa-webhook",
      "parameters": {
        "path": "doc-qa",
        "httpMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "validate-request",
      "name": "요청 검증",
      "type": "n8n-nodes-base.code",
      "notes": "Validate and prepare request",
      "position": [
        450,
        300
      ],
      "parameters": {
        "jsCode": "// Validate incoming request\nconst body = $input.first().json.body;\nconst errors = [];\n\nif (!body.documentUrl && !body.documentId) {\n  errors.push('Either documentUrl or documentId is required');\n}\nif (!body.question) {\n  errors.push('Question is required');\n}\n\n// Generate session ID if not provided\nconst sessionId = body.sessionId || `session-${Date.now()}`;\n\nreturn [{\n  json: {\n    ...body,\n    sessionId,\n    valid: errors.length === 0,\n    errors,\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "check-valid",
      "name": "유효한 요청?",
      "type": "n8n-nodes-base.if",
      "position": [
        650,
        300
      ],
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.valid }}",
              "value2": true
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "pdfvector-ask",
      "name": "PDF 벡터 - 질문하기",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "notes": "Get answer from document",
      "position": [
        850,
        250
      ],
      "parameters": {
        "url": "={{ $json.documentUrl }}",
        "prompt": "Answer the following question about this document or image: {{ $json.question }}",
        "resource": "document",
        "inputType": "url",
        "operation": "ask"
      },
      "typeVersion": 1
    },
    {
      "id": "format-success",
      "name": "성공 응답 형식화",
      "type": "n8n-nodes-base.code",
      "notes": "Prepare successful response",
      "position": [
        1050,
        250
      ],
      "parameters": {
        "jsCode": "// Prepare successful response\nconst answer = $json.answer;\nconst request = $node['Validate Request'].json;\n\n// Calculate confidence score based on answer length and keywords\nlet confidence = 0.8; // Base confidence\nif (answer.length > 100) confidence += 0.1;\nif (answer.toLowerCase().includes('specifically') || answer.toLowerCase().includes('according to')) confidence += 0.1;\nconfidence = Math.min(confidence, 1.0);\n\nreturn [{\n  json: {\n    success: true,\n    data: {\n      answer,\n      confidence,\n      sessionId: request.sessionId,\n      documentUrl: request.documentUrl,\n      question: request.question\n    },\n    metadata: {\n      processedAt: new Date().toISOString(),\n      responseTime: Date.now() - new Date(request.timestamp).getTime(),\n      creditsUsed: 1\n    }\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "format-error",
      "name": "오류 응답 형식화",
      "type": "n8n-nodes-base.code",
      "notes": "Prepare error response",
      "position": [
        850,
        350
      ],
      "parameters": {
        "jsCode": "// Prepare error response\nconst errors = $json.errors || ['An error occurred processing your request'];\n\nreturn [{\n  json: {\n    success: false,\n    errors,\n    message: 'Invalid request',\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "webhook-response",
      "name": "응답 전송",
      "type": "n8n-nodes-base.respondToWebhook",
      "notes": "Send API response",
      "position": [
        1250,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}",
        "responseHeaders": {
          "entries": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "webhook-trigger": {
      "main": [
        [
          {
            "node": "validate-request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check-valid": {
      "main": [
        [
          {
            "node": "pdfvector-ask",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "format-error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "validate-request": {
      "main": [
        [
          {
            "node": "check-valid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "format-error": {
      "main": [
        [
          {
            "node": "webhook-response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "format-success": {
      "main": [
        [
          {
            "node": "webhook-response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "pdfvector-ask": {
      "main": [
        [
          {
            "node": "format-success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
자주 묻는 질문

이 워크플로우를 어떻게 사용하나요?

위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.

이 워크플로우는 어떤 시나리오에 적합한가요?

중급 - 내부 위키, AI RAG, 멀티모달 AI

유료인가요?

이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.

워크플로우 정보
난이도
중급
노드 수11
카테고리3
노드 유형6
난이도 설명

일정 경험을 가진 사용자를 위한 6-15개 노드의 중간 복잡도 워크플로우

저자
PDF Vector

PDF Vector

@pdfvector

A fully featured PDF APIs for developers - Parse any PDF or Word document, extract structured data, and access millions of academic papers - all through simple APIs.

외부 링크
n8n.io에서 보기

이 워크플로우 공유

카테고리

카테고리: 34