MongoDB Movie Recommendation AI Agent
MongoDB Agent
An intelligent movie recommendation system powered by OpenAI and MongoDB, supporting natural language queries of the movie database, personalized recommendations, and watchlist management.
Workflow Overview
This is an AI-powered agent workflow built on OpenAI and MongoDB for movie recommendation and management. The workflow receives chat messages, queries movie data using MongoDB's aggregation framework, and supports storing users' favorite movies back into the database.
Workflow Name
MongoDB Agent
Core Features
- Intelligent Conversational Interaction: Receives user movie queries via a chat interface
- MongoDB Data Querying: Retrieves relevant information from the MongoDB movie database using aggregation pipelines
- Movie Recommendations: Provides personalized movie suggestions based on user preferences
- Favorites Management: Allows users to save favorite movies to the database
Node Details
1. When chat message received (Chat Message Trigger)
- Type:
@n8n/n8n-nodes-langchain.chatTrigger - Function: Entry point of the workflow, receiving user chat messages via webhook
- Configuration:
- Mode: Webhook (publicly accessible)
- Accepts requests from all origins (
allowedOrigins: "*")
2. AI Agent - Movie Recommendation (AI Movie Recommendation Agent)
- Type:
@n8n/n8n-nodes-langchain.agent - Function: Core AI agent coordinating the entire workflow logic
- Prompt Instructions:
- Acts as a movie context assistant
- Uses the MongoDBAggregate tool for searching
- Must provide an array of MongoDB aggregation pipeline code
- Only uses the insertFavorite tool to save favorites upon explicit user confirmation
3. OpenAI Chat Model
- Type:
@n8n/n8n-nodes-langchain.lmChatOpenAi - Function: Provides AI language understanding and generation capabilities
- Credentials: Connected to the OpenAI API
4. Window Buffer Memory
- Type:
@n8n/n8n-nodes-langchain.memoryBufferWindow - Function: Maintains conversation context
- Configuration: Keeps a context window of the most recent 10 messages
5. MongoDBAggregate (MongoDB Aggregation Tool)
- Type:
n8n-nodes-base.mongoDbTool - Function: Executes MongoDB aggregation queries
- Operation: Aggregate
- Collection: movies
- Document Structure: Contains the following fields
plot: Brief movie synopsisgenres: Movie genres (array)runtime: Runtime durationcast: Cast listposter: Poster URLtitle: Movie titlefullplot: Full plot descriptionlanguages: Languagesreleased: Release datedirectors: Directorsrated: Rating classificationawards: Awards informationyear: Yearimdb: IMDb rating details
6. insertFavorite (Insert Favorite Tool)
- Type:
@n8n/n8n-nodes-langchain.toolWorkflow - Function: Invokes a sub-workflow to insert the user's favorite movie into the database
- Workflow ID:
6QuKnOrpusQVu66Q(insertMongoDB) - Data Structure:
{"title": "Movie Title"}
7–8. Sticky Note
- Function: Provides documentation and process explanations for the workflow
Workflow Process
- Message Reception: User sends a movie-related query through the chat interface
- AI Analysis: OpenAI model interprets user intent and requirements
- Data Retrieval: Invokes the MongoDBAggregate tool to query movie data as needed
- Result Enhancement: AI agent processes query results and generates user-friendly responses
- Favorite Saving: If the user confirms liking a movie, the insertFavorite tool is invoked to save it
- Context Maintenance: Window Buffer Memory ensures conversational continuity
Connections
- When chat message received → AI Agent - Movie Recommendation
- OpenAI Chat Model → AI Agent - Movie Recommendation (language model)
- Window Buffer Memory → AI Agent - Movie Recommendation (memory)
- MongoDBAggregate → AI Agent - Movie Recommendation (tool)
- insertFavorite → AI Agent - Movie Recommendation (tool)
Technical Characteristics
- Autonomous Agent Architecture: AI independently decides when and which tools to use
- Context Preservation: Maintains conversation continuity through windowed memory
- Flexible Querying: Supports complex MongoDB aggregation pipeline queries
- Bidirectional Interaction: Capable of both reading from and writing to the database
- Public Accessibility: Exposed via webhook for integration with external systems
Use Cases
- Movie recommendation chatbot
- Intelligent movie database query system
- Personalized movie favorites management
- Movie information retrieval assistant
Status
- Active: true (workflow is activated)
- Execution Order: v1
Tech Stack
- AI Framework: LangChain
- Language Model: OpenAI
- Database: MongoDB
- Platform: n8n workflow automation