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.

Pipelineapi-question-reponse-rag.json · 10 nodes
  1. POST /ask (Webhook)triggerWebhook
  2. Question valide ?IF (condition)
  3. Répondre depuis les documentsRAG chain (Q&A)
  4. Base vectorielle SupabaseSupabase vector store
  5. Formater la réponseSet (fields)
  6. Réponse JSONWebhook response
  7. Erreur 400Webhook response

Attached AI sub-nodes

  • Modèle OpenAIOpenAI model
  • RetrieverRetriever
  • Embeddings OpenAIOpenAI embeddings

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.