n8n template · RAG Assistant Pack
Expose a question-answering API over your documents with n8n
The n8n chat can't be embedded everywhere — an API can. This workflow exposes a POST /ask endpoint: send {"question": "…"} and receive the answer grounded in your documents as structured JSON, ready to display in your site, CRM or internal tool.
- POST /ask (Webhook)triggerWebhook
- Question valide ?IF (condition)
- Répondre depuis les documentsRAG chain (Q&A)
- Base vectorielle SupabaseSupabase vector store
- Formater la réponseSet (fields)
- Réponse JSONWebhook response
- Erreur 400Webhook response
Attached AI sub-nodes
- Modèle OpenAIOpenAI model
- RetrieverRetriever
- Embeddings OpenAIOpenAI embeddings
$ n8n import:workflow --input=api-question-reponse-rag.json ✔ Import successful — 10 nodes, valid connections
The problem it solves
Once RAG is in place, every team wants to call it from their own tool: the website widget, the back office, a support channel. Multiplying chatbots would be absurd; you need a single programmatic interface in front of the same vector store.
This template is that interface: input validation, explicit 400 error, timestamped JSON response. It's also the natural starting point for plugging a custom frontend onto your assistant.
How the workflow works, node by node
Node names are in French, exactly as they appear in the imported workflow — the logic is language-agnostic.
- 01
POST /ask (Webhook)
WebhookHTTP POST endpoint (flowkit-ask path) expecting a JSON body {"question": "…"}. The responseNode mode gives the workflow full control over the HTTP response.
- 02
Question valide ?
IF (condition)Rejects requests without a usable question before spending a single token — basic API hygiene.
- 03
Répondre depuis les documents
RAG chain (Q&A)Same RAG chain as the pack's chatbot: retrieved passages injected into the prompt, answer constrained to the context, source citations.
- 04
Modèle OpenAI
OpenAI modelai_languageModel sub-node (gpt-4o-mini) — same model as the chat for consistent answers across channels.
- 05
Retriever
RetrieverLooks up the 4 most relevant passages in the vector store before generation.
- 06
Base vectorielle Supabase
Supabase vector storeRetrieve mode on the documents table — the same one fed by the pack's ingestion workflows.
- 07
Embeddings OpenAI
OpenAI embeddingsVectorizes the incoming question in the same space as the indexed corpus.
- 08
Formater la réponse
Set (fields)Builds the output object: answer, model used, timestamp — a stable API contract for your integrations.
- 09
Réponse JSON
Webhook responseReturns the final JSON with a 200 status.
- 10
Erreur 400
Webhook responseValidation failure branch: {"error": "question manquante"} — the caller knows immediately how to fix the call.
What you need to run it
- n8n ≥ 1.60 with the LangChain nodes
- A populated Supabase pgvector store (PDF or Notion ingestion from the pack)
- An OpenAI API key
- Recommended: webhook authentication (API key header) before public exposure
Customization ideas
- Add header authentication in the webhook options before any internet exposure
- Also return the sources used by reading the retrieved passages' metadata
- Log questions/answers to a Supabase table to analyze what your users search for
FAQ
Frequently asked questions
How do I import this template into n8n?
Import api-question-reponse-rag.json via 'Import from File', attach OpenAI and Supabase, activate, then test: curl -X POST https://your-n8n/webhook/flowkit-ask -H 'Content-Type: application/json' -d '{"question":"…"}'.
What response time should I expect?
Typically 2 to 5 seconds: vector search (fast) plus LLM generation (most of the delay). For a web widget, show a loading state; the mini model keeps latency low.
Can I call this API from a public website?
Technically yes, but add authentication and rate limiting first (reverse proxy or a counting node): an open LLM endpoint is your OpenAI bill left open.