FlowKit

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.

By Clément Lacaille (Tech-Bharat) · updated 11 July 2026 · how we build and test

RAG Assistant Pack — €119

This workflow + 3 more, validated JSON, setup guide, 14-day guarantee

See the pack
Canvas generated from the delivered JSON exportworkflows/api-question-reponse-rag.json · 10 nodes · n8n
POST /ask (Webhook) — n8n-nodes-base.webhook v2POST /ask (Webhook)WebhookQuestion valide ? — n8n-nodes-base.if v2.2Question valide ?IF (condition)Répondre depuis les documents — @n8n/n8n-nodes-langchain.chainRetrievalQa v1.4Répondre depuis les…RAG chain (Q&A)Modèle OpenAI — @n8n/n8n-nodes-langchain.lmChatOpenAi v1.2Modèle OpenAIOpenAI modelRetriever — @n8n/n8n-nodes-langchain.retrieverVectorStore v1RetrieverRetrieverBase vectorielle Supabase — @n8n/n8n-nodes-langchain.vectorStoreSupabase v1.1Base vectorielle Su…Supabase vector storeEmbeddings OpenAI — @n8n/n8n-nodes-langchain.embeddingsOpenAi v1.2Embeddings OpenAIOpenAI embeddingsFormater la réponse — n8n-nodes-base.set v3.4Formater la réponseSet (fields)Réponse JSON — n8n-nodes-base.respondToWebhook v1.1Réponse JSONWebhook responseErreur 400 — n8n-nodes-base.respondToWebhook v1.1Erreur 400Webhook response
data flow AI sub-node3 explanatory sticky notes in the canvas (not drawn)
workflows/api-question-reponse-rag.json10.4 KB · 10 nodes
{
  "name": "FlowKit — API question-réponse sur vos documents",
  "nodes": [
    {"name": "POST /ask (Webhook)", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [-440,0]},
    {"name": "Question valide ?", "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [-220,0]},
    {"name": "Répondre depuis les documents", "type": "@n8n/n8n-nodes-langchain.chainRetrievalQa", "typeVersion": 1.4, "position": [0,0]},
    {"name": "Modèle OpenAI", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "typeVersion": 1.2, "position": [-120,200]},
    {"name": "Retriever", "type": "@n8n/n8n-nodes-langchain.retrieverVectorStore", "typeVersion": 1, "position": [120,200]},
    {"name": "Base vectorielle Supabase", "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase", "typeVersion": 1.1, "position": [120,400]},
    // … 4 more nodes, connections, settings
  ]
}

Real excerpt of the delivered file (structure only: node parameters and prompts are part of the paid pack).

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.

  1. 01

    POST /ask (Webhook)

    Webhook

    HTTP POST endpoint (flowkit-ask path) expecting a JSON body {"question": "…"}. The responseNode mode gives the workflow full control over the HTTP response.

  2. 02

    Question valide ?

    IF (condition)

    Rejects requests without a usable question before spending a single token — basic API hygiene.

  3. 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.

  4. 04

    Modèle OpenAI

    OpenAI model

    ai_languageModel sub-node (gpt-4o-mini) — same model as the chat for consistent answers across channels.

  5. 05

    Retriever

    Retriever

    Looks up the 4 most relevant passages in the vector store before generation.

  6. 06

    Base vectorielle Supabase

    Supabase vector store

    Retrieve mode on the documents table — the same one fed by the pack's ingestion workflows.

  7. 07

    Embeddings OpenAI

    OpenAI embeddings

    Vectorizes the incoming question in the same space as the indexed corpus.

  8. 08

    Formater la réponse

    Set (fields)

    Builds the output object: answer, model used, timestamp — a stable API contract for your integrations.

  9. 09

    Réponse JSON

    Webhook response

    Returns the final JSON with a 200 status.

  10. 10

    Erreur 400

    Webhook response

    Validation 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.