DEV Community

Cover image for Turn Your PDFs into a Chatbot with n8n + Open AI (No Vector DB Needed).

Turn Your PDFs into a Chatbot with n8n + Open AI (No Vector DB Needed).

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:

  1. n8n
  2. OpenAI

And a small set of PDFs (10–30 files is perfect).


Step 1: Set Up n8n Trigger

→ Open n8n.

n8n homepage

→ Click on the trigger.
→ Choose Chat Message.

trigger

→ Click on the trigger button, then select Advanced AI.

advanced AI


Step 2: Connect n8n to OpenAI

→ Add an OpenAI node.

Open AI NODE

→ Select Message an Assistant.

Message an assistant

Now, connect your OpenAI account:

→ Go to OpenAI.

openai homepage

→ Go to API Platform

openAI API Platform

→ Click start building (If you don’t have an account, create one.)

openai

→ Open Settings.

setting

→ Scroll down and click on API Keys.

API Keys

→ Click Create new secret key.

Create new secret key page

→ Give it a name, then click Create secret key.

openai

→ Copy the secret key.

Back in n8n:

→ Open your OpenAI Assistant node.
→ Click on credentials to connect with
→ Click Create new credentials

n8n

→ Paste your API key in the box.
→ Save it.

api key - save

Now your n8n is linked to OpenAI.

→ Go back to your Open AI account.
→ Click on billings

OPEN AI

→ Click on Add to credit balance to make sure you have some credits.

credit page


Step 3: Create Your OpenAI Assistant

→ Go to Dashboard

open ai dashboard

→ Click Assistants.

create new assistant

→ Give it a name (example: RAG Agent).

RAG AI Agent

→ Copy the Assistant ID.

assistant id

Back in n8n:

→ Open your OpenAI node.
→ In the Assistant box, choose By ID.
→ Paste the ID you copied.

n8n

Then:

→ Under Source from prompt (user message), pick Define below.

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

OpenAI


Step 4: Add Knowledge (Upload Files)

→ In your OpenAI assistant dashboard, scroll to File Search.
→ Turn it On.

KNOWLEDGE BASE

→ Click the Files button beside it.

OPENAI files

→ Upload the files you want the AI agent to access

AI agent

👉 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.)

one FAQ file

→ Click Attach.

pdf upload

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

System Instructions


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

  1. Introduction Greet warmly and offer help. Example:

“Hi! Thanks for reaching out to Jennie’s Restaurant. How can I help you today?”

  1. Answer FAQs
    Always check the FAQ knowledge base. Never guess. Use the remove_annotations tool to clean the response.

  2. 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?”

  1. 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.”

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

OPENAI assistant

→ If it’s not green, drag chatInput into that spot.

drag chatInput


Step 6: Add Memory

In your AI Assistant node (n8n):

→ Click on Memory lane.

memory lane

→ Pick Simple memory.

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.

Context window length


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.

openAI

→ Select Code tool.

Code tool image

→ Name it: remove_annotations.

remove annontation

→ Description: Removes any annotation from the output. Always use this before sending to customer.

n8n description

→ Paste this code in the JavaScript box:

function removeAnnotations(input) {
  return input.replace(/【[^]*】/g, '').trim();
}

// Example usage
const output = removeAnnotations(query);
return output;
Enter fullscreen mode Exit fullscreen mode

javascript

→ Save it.

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)