Most people think you must set up a complex RAG (Retrieval Augmented Generation) system with vector databases just to give your AI some knowledge. That’s not true.
If you only have 10–30 PDF files, you can keep things super simple. In this guide, you’ll learn how to power up an AI agent in n8n using OpenAI Assistants API, without all the extra tech.
You will build a chatbot that answers FAQs (we’ll use a restaurant example).
By the end, you’ll have a working AI assistant that reads your documents, remembers chat history, and answers smartly, no headaches.
What You will Need
🛠 Tools:
And a small set of PDFs (10–30 files is perfect).
Step 1: Set Up n8n Trigger
→ Open n8n.
→ Click on the trigger.
→ Choose Chat Message.
→ Click on the trigger button, then select Advanced AI.
Step 2: Connect n8n to OpenAI
→ Add an OpenAI node.
→ Select Message an Assistant.
Now, connect your OpenAI account:
→ Go to OpenAI.
→ Go to API Platform
→ Click start building (If you don’t have an account, create one.)
→ Open Settings.
→ Scroll down and click on API Keys.
→ Click Create new secret key.
→ Give it a name, then click Create secret key.
→ Copy the secret key.
Back in n8n:
→ Open your OpenAI Assistant node.
→ Click on credentials to connect with
→ Click Create new credentials
→ Paste your API key in the box.
→ Save it.
Now your n8n is linked to OpenAI.
→ Go back to your Open AI account.
→ Click on billings
→ Click on Add to credit balance to make sure you have some credits.
Step 3: Create Your OpenAI Assistant
→ Go to Dashboard
→ Click Assistants.
→ Give it a name (example: RAG Agent
).
→ Copy the Assistant ID.
Back in n8n:
→ Open your OpenAI node.
→ In the Assistant box, choose By ID.
→ Paste the ID you copied.
Then:
→ Under Source from prompt (user message), pick Define below.
→ Back to your OpenAI dashboard where you copied the id
→ Put this in your system's instructions: Respond to the user query by following the given instruction
Step 4: Add Knowledge (Upload Files)
→ In your OpenAI assistant dashboard, scroll to File Search.
→ Turn it On.
→ Click the Files button beside it.
→ Upload the files you want the AI agent to access
👉 For this tutorial, Let's upload one FAQ file with about 25 restaurant questions. (In real use, you can upload up to 30 or more files.)
→ Click Attach.
Now your agent can read these files.
Step 5: Write the System Instructions
→ Go to your OpenAI assistant node
→ Add the prompt below in the prompt user message
RAG Agent Prompt
Identity
You are an AI assistant for Jennie’s Restaurant. Your role is to help customers by answering FAQs about menu items, hours, location, and general restaurant policies. Be friendly, professional, and concise. Do not assist with reservations, payments, or event bookings. Use only the restaurant’s FAQ knowledge base for answers.
Style Guardrails
- Be Concise: Keep responses short, direct, and informative.
- Be Engaging: Use a warm, welcoming tone.
- Stay Proactive: Offer extra help naturally (e.g., “Would you also like to know about our specials?”).
- Get Clarity: If a request is unclear, politely ask a follow-up question.
- Avoid Repetition: Change your wording so replies don’t sound the same.
Conversation Flow
- Introduction Greet warmly and offer help. Example:
“Hi! Thanks for reaching out to Jennie’s Restaurant. How can I help you today?”
Answer FAQs
Always check the FAQ knowledge base. Never guess. Use theremove_annotations
tool to clean the response.If the Query Is Vague
Ask politely for more details.
Example:
“Could you clarify if you’re asking about the lunch or dinner menu at Jennie’s Restaurant?”
- If the Query Is Out of Scope Apologize and send them to a human. Example:
“I’m sorry, I can’t help with that. Please call (555) 123-4567 for more details.”
- Closure Offer more help, then close politely. Example:
“Is there anything else I can help you with today?”
If not:
“Thanks for reaching out to Jennie’s Restaurant. Have a wonderful day!”
Tool Usage
Always run your final answer through the remove_annotations
tool before replying.
Date today: {{ $now }}
User’s input: {{ $json.chatInput }}
👉 Make sure {{ $json.chatInput }}
shows in green inside n8n.
→ If it’s not green, drag chatInput
into that spot.
Step 6: Add Memory
In your AI Assistant node (n8n):
→ Click on Memory lane.
→ Pick Simple memory.
→ Set Context window length to 10 (or any number you prefer.)
This way, the bot remembers the last 10 messages in the same chat.
Step 7: Add a Cleanup Tool (remove annotations)
You don’t want the bot showing raw citations. So let’s add a cleanup tool.
→ In your OpenAI assistant, click on the boxed cross on Tools.
→ Select Code tool.
→ Name it: remove_annotations
.
→ Description: Removes any annotation from the output. Always use this before sending to customer.
→ Paste this code in the JavaScript box:
function removeAnnotations(input) {
return input.replace(/【[^】]*】/g, '').trim();
}
// Example usage
const output = removeAnnotations(query);
return output;
→ Save it.
Restaurant FAQ Chatbot
Now test your chatbot:
Type a question about Jennie’s Restaurant.
The bot will check the FAQ file, clean up the answer, and reply in a warm, short style.
The Big RAG Misconception
Most people think RAG = Vector Database. That’s wrong.
For small projects with a few documents, you don’t need Pinecone, Weaviate, or any other heavy setup.
OpenAI Assistants + n8n file uploads work just fine.
Vector DBs are useful at scale. But for 10–30 PDFs, skip the complexity and keep it light.
You just built a working AI agent in n8n using OpenAI:
- Trigger on chat.
- Connect to OpenAI.
- Create an assistant.
- Upload files.
- Add memory.
- Clean responses.
- Test your chat.
Simple, clean, and affordable. No vector databases, no headaches.
👉 Try it out with your own docs today.
Top comments (0)