Movie Recommendation Chatbot Using RAG, Qdrant & n8n
This tutorial walks you through building a movie recommendation chatbot powered by Retrieval-Augmented Generation (RAG). We'll use Qdrant as the vector database and n8n to orchestrate the workflows.
Prerequisites
Free accounts on:
Qdrant Cloud
n8n Cloud or a self-hosted n8n instance
OpenAI API key (or another embedding service)
A movie dataset (CSV or JSON) containing fields like
title
,description
,genre
, etc.
Step 1: Prepare Your Movie Dataset
Obtain a movie dataset from sources like IMDb or Kaggle.
Make sure each movie record includes:
title
description
Optional fields like
genre
,release_year
, etc.
Save the dataset in CSV or JSON format.
Step 2: Configure Qdrant Vector Database
Log into your Qdrant Cloud account.
Create a new collection with these settings:
Name:
movies
Distance metric: Cosine
Vector size: 1536 (to match OpenAI embeddings)
Keep track of your:
API key
Collection name
Endpoint URL
Step 3: Build Data Ingestion Workflow in n8n
Open n8n and create a workflow named Ingest Movies to Qdrant.
Add these nodes in order:
Read CSV or HTTP Request (to load your dataset)
AI Embedder (use OpenAI embeddings to vectorize movie info)
Qdrant Upsert (insert vectors and metadata into Qdrant)
Map each movie’s title and description to generate its embedding.
Attach metadata like genre and release year to each vector.
Run the workflow to upload your movie data into Qdrant.
Step 4: Create the Recommendation Chatbot Workflow
In n8n, create a new workflow called Movie Chatbot RAG.
Add these nodes:
Webhook (to receive user queries via HTTP POST)
AI Embedder (convert user input into an embedding vector)
Qdrant Search (find nearest movie vectors based on query)
AI Summarizer/LLM (generate movie recommendations from results)
Respond (return the recommended movies as a response)
Example user prompt:
“I like action-packed sci-fi movies with time travel.”Use the query embedding to perform a nearest-neighbor search in Qdrant.
Return the top N movie recommendations with titles and descriptions.
Step 5: Test and Deploy
Trigger your chatbot workflow using the webhook URL and try various prompts.
Adjust parameters such as:
Number of nearest neighbors returned
AI prompt templates for summarizing results
Deploy your workflows and make the webhook URL publicly accessible (secure it with authentication).
Optionally, connect the webhook to a frontend chat UI for user interaction.
Security Best Practices
Store API keys in environment variables.
Protect your webhook with authentication or IP whitelisting.
Implement rate limiting to avoid abuse.
Summary of Steps
Optional Enhancements
Use Qdrant’s payload filtering to filter recommendations by genre or year.
Add user feedback (thumbs up/down) to improve recommendations.
Support multiple languages using translation APIs.