Dokumenten-Frage-API mit PDF-Vektoren und Webhooks erstellen
Dies ist ein Internal Wiki, AI RAG, Multimodal AI-Bereich Automatisierungsworkflow mit 11 Nodes. Hauptsächlich werden If, Code, Webhook, PdfVector, RespondToWebhook und andere Nodes verwendet. Ein Dokumenten-Frage-Antwort-API mit PDF-Vektoren und Webhooks erstellen
- •HTTP Webhook-Endpunkt (wird von n8n automatisch generiert)
Verwendete Nodes (11)
Kategorie
{
"meta": {
"instanceId": "placeholder"
},
"nodes": [
{
"id": "overview-note",
"name": "API Übersicht",
"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": "Anfrageformat",
"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": "F&A-Verarbeitung",
"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": "Antwortformat",
"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": "Anfrage validieren",
"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": "Gültige Anfrage?",
"type": "n8n-nodes-base.if",
"position": [
650,
300
],
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.valid }}",
"value2": true
}
]
}
},
"typeVersion": 1
},
{
"id": "pdfvector-ask",
"name": "PDF Vector - Frage stellen",
"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": "Erfolgsantwort formatieren",
"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": "Fehlerantwort formatieren",
"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": "Antwort senden",
"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
}
]
]
}
}
}Wie verwende ich diesen Workflow?
Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.
Für welche Szenarien ist dieser Workflow geeignet?
Fortgeschritten - Internes Wiki, KI RAG, Multimodales KI
Ist es kostenpflichtig?
Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.
Verwandte Workflows
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.
Diesen Workflow teilen