Skip to content
NEWMeet Alaaddin, your AI genie with a voice. trig8n launches 1 January 2027. See what is new

Library / RAG & Knowledge Bases

RAG & Knowledge Bases

Answer support chat questions from uploaded documents using OpenAI and a webhook

Indexes uploaded PDFs, CSVs and text files into an in-memory vector store, then answers each chat message sent to the webhook with OpenAI, keeping session history.

What it does

# Support chatbot answering from your own documents A chat API that answers customer questions from files you upload. Ask it anything over your PDFs, CSVs or text files and it replies in a natural conversation, remembering what was said earlier. Point a website widget, WhatsApp bot or app at the webhook and it just works. ### How it works 1. You upload documents through a simple form. They are split, embedded with OpenAI and held in an in-memory vector store. 2. A webhook receives each chat message along with a session ID, protected by header authentication. 3. The support agent answers common questions straight from its system prompt. For anything specific it calls a second agent that searches the uploaded documents and hands back only the facts it found. 4. Conversation memory keeps the last 15 messages per session, so follow-up questions and multi-step requests work naturally. 5. The reply is formatted and returned to whatever sent the message. ### Setup 1. Add your OpenAI API key to the three model and embedding nodes. 2. On the Receive chat message node, create a header auth credential. Your chat app must send that same header and secret. 3. Open the Support agent node and replace every bracketed placeholder in the system prompt with your own company details. 4. Activate, open the form URL, upload your documents, then POST to the webhook with a JSON body containing message and session_id. ### Customization The in-memory store is cleared whenever n8n restarts, so re-upload after a restart. For permanent storage, swap both vector store nodes for Pinecone, Qdrant or Supabase.

The steps

  1. Upload files to the knowledge base
  2. Embeddings - OpenAI
  3. Data Loader - Split uploaded files
  4. Store documents in vector store
  5. Search knowledge base
  6. Chat model - Knowledge base agent
  7. Receive chat message
  8. Support agent
  9. Chat model - Support agent
  10. Conversation memory
  11. Knowledge base agent
  12. Send reply
  13. Format reply

Similar automations