PDFベクトルとWebhooksを使ってドキュメントQ&A APIを構築する
中級
これはInternal Wiki, AI RAG, Multimodal AI分野の自動化ワークフローで、11個のノードを含みます。主にIf, Code, Webhook, PdfVector, RespondToWebhookなどのノードを使用。 PDFベクトルとWebhookを使ったドキュメントQA 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": "Q&A処理",
"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からインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
中級 - 内部Wiki, AI RAG検索拡張, マルチモーダルAI
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
GPT-4と複数のデータベース検索を使った学術文献综述の自動化
GPT-4と複数のデータベース検索を使った学術文献レビューの自動化
If
Set
Code
+
If
Set
Code
13 ノードPDF Vector
文書抽出
PDFベクトル、Google Drive、データベースを使用した領秤データの抽出と保存
PDFベクトル、Google Drive、データベースを使って領収書データを抽出・保存する
If
Code
Slack
+
If
Code
Slack
26 ノードPDF Vector
請求書処理
GPT-4とPDF Vectorを使用したマルチフォーマット研究論文要約の生成
GPT-4 と PDF Vector を使用してマルチフォーマット研究論文の要旨を生成
Code
Open Ai
Webhook
+
Code
Open Ai
Webhook
9 ノードPDF Vector
AI要約
五つのデータベースをまたいだ学术研究検索、PDFベクターと複数エクスポート
五つのデータベースを横断した学术研究検索、PDFベクターおよび複数のエクスポート
Set
Code
Pdf Vector
+
Set
Code
Pdf Vector
9 ノードPDF Vector
AI RAG検索拡張
PDFベクター、GPT-4、Neo4jを使用して学術知識グラフを構築
PDFベクトル、GPT-4、Neo4jを使って、研究論文から学術知識グラフを構築
Code
Neo4j
Open Ai
+
Code
Neo4j
Open Ai
10 ノードPDF Vector
AI RAG検索拡張
Google DriveとLLM解析を使用したバッチPDFからMarkdownへの変換
Google DriveとLLM駆動の解析でバッチPDFをMarkdownに変換
If
Set
Code
+
If
Set
Code
8 ノードPDF Vector
コンテンツ作成
ワークフロー情報
難易度
中級
ノード数11
カテゴリー3
ノードタイプ6
作成者
PDF Vector
@pdfvectorA 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で表示 →
このワークフローを共有