WORKEASIER implementation guide · 9 min read
Build a RAG support bot in n8n with Supabase vector search
Updated
A support bot that answers from a model's general knowledge will confidently invent policies. Retrieval-augmented generation (RAG) grounds each answer in your own help-center content: the workflow finds the most relevant passages and asks the model to answer only from them. This guide explains the two workflows involved and the safeguards that matter most.
Two workflows: ingestion and answering
RAG needs a knowledge store before it can answer anything. Keep ingestion — reading articles, splitting them and storing embeddings — in its own workflow that runs on a schedule or when content changes. The answering workflow then only reads from that store. Separating them means a slow re-index never delays a customer reply.
Ingest: chunk, embed and store
The ingestion workflow reads help-center articles, for example from the Zendesk Help Center API, and splits each one into chunks small enough to retrieve precisely but large enough to keep context — a few paragraphs, with the article title attached to every chunk.
Each chunk is sent to an embeddings API, such as Voyage AI, and the resulting vector is stored in Supabase in a table with a pgvector column alongside the chunk text and its source URL. The WORKEASIER support module ships this as a separate ingestion workflow plus a Supabase setup script. Its ingestion clears the chunks table before inserting, so run it against a dedicated test project first.
Retrieve: embed the ticket and search
When a ticket arrives, the answering workflow embeds the customer's question with the same embeddings model used at ingestion — mixing models makes similarity scores meaningless. It then calls a Postgres function in Supabase that returns the closest chunks by vector similarity, typically through Supabase's RPC endpoint.
Return a similarity score with each chunk and set a threshold. Retrieval always returns something; the threshold decides whether that something is relevant enough to answer from.
Decide before drafting: answer or hand off
Classify the ticket before writing a reply. Billing disputes, legal threats, account security and angry customers usually belong with a person no matter what the knowledge base says. When retrieval finds nothing above the threshold, the right answer is also a handoff, not a creative guess.
The WORKEASIER module makes classification and escalation separate decisions from drafting, and gives the handoff path its own nodes so it can be tested like any other branch.
Draft with Claude, grounded in retrieved text
Give Claude the ticket, the retrieved chunks and a strict instruction to answer only from that material and to say when it cannot. Ask for a structured result — the reply, the sources used and a confidence or can-answer flag — so the next step can check it.
Treat ticket text as untrusted input. Customers can, deliberately or not, include instructions that try to change the model's behavior. Keep system instructions separate from customer content, and never let the ticket text decide whether a reply is sent publicly.
Validate, deliver and prevent duplicates
Validate the draft before delivery: required fields present, sources cited, no answer when the model flagged insufficient context. Then choose between a public reply and an internal note for an agent to review. Starting with internal notes only is a sensible first release.
Helpdesk webhooks can fire more than once for the same ticket, so use an idempotency guard and a send lock before any public reply. Log every decision so you can review what the bot did and why.
Frequently asked questions
- Do I need a separate vector database for RAG in n8n?
- Not necessarily. Supabase Postgres with the pgvector extension can store embeddings and run similarity search, which keeps chunks, metadata and logs in one database.
- Why does my RAG bot answer questions that are not in the knowledge base?
- Vector search always returns the nearest chunks, even when none are relevant. Return similarity scores, set a threshold, instruct the model to refuse without sufficient context and route those tickets to a person.
- Can I use a different embeddings model for queries and documents?
- No. Embed queries with the same model used during ingestion. Vectors from different models are not comparable, so similarity results become unreliable.