Skip to main content

MongoDB AI agent - intelligent movie recommendations

Workflow preview

Workflow preview
100%
MongoDB AI agent - intelligent movie recommendations preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Who is this for? This workflow is designed for: Database administrators and developers working with MongoDB Content managers handling movie databases Organizations looking to implement AI powered s...

Best for

  • Engineering automation workflows
  • AI RAG automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.mongodbtool, @n8n/n8n-nodes-langchain.memorybufferwindow, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.toolworkflow, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Pavel Duchovny.

Original n8n.io source

1.1 Workflow description

Title
MongoDB AI agent - intelligent movie recommendations
Workflow name
MongoDB AI agent - intelligent movie recommendations

Who is this for?

This workflow is designed for:

  • Database administrators and developers working with MongoDB
  • Content managers handling movie databases
  • Organizations looking to implement AI-powered search and recommendation systems
  • Developers interested in combining LangChain, OpenAI, and MongoDB capabilities

What problem does this workflow solve?

Traditional database queries can be complex and require specific MongoDB syntax knowledge. This workflow addresses:

  • The complexity of writing MongoDB aggregation pipelines
  • The need for natural language interaction with movie databases
  • The challenge of maintaining user preferences and favorites
  • The gap between AI language models and database operations

What this workflow does

This workflow creates an intelligent agent that:

  1. Accepts natural language queries about movies
  2. Translates user requests into MongoDB aggregation pipelines
  3. Queries a movie database containing detailed information including:
    • Plot summaries
    • Genre classifications
    • Cast and director information
    • Runtime and release dates
    • Ratings and awards
  4. Provides contextual responses using OpenAI's language model
  5. Allows users to save favorite movies to the database
  6. Maintains conversation context using a window buffer memory

Setup

  1. Required Credentials:

    • OpenAI API credentials
    • MongoDB connection details
  2. Node Configuration:

    • Configure the MongoDB connection in the MongoDBAggregate node
    • Set up the OpenAI Chat Model with your API key
    • Ensure the webhook trigger is properly configured for receiving chat messages
  3. Database Requirements:

    • A MongoDB collection named "movies" with the specified document structure
    • Proper indexes for efficient querying
    • Appropriate user permissions for read/write operations

How to customize this workflow

  1. Modify the Document Structure:

    • Update the tool description in the MongoDBAggregate node to match your collection schema
    • Adjust the aggregation pipeline templates for your specific use case
  2. Enhance the AI Agent:

    • Customize the prompt in the "AI Agent - Movie Recommendation" node
    • Modify the window buffer memory size based on your context needs
    • Add additional tools for more functionality
  3. Extend Functionality:

    • Add more MongoDB operations beyond aggregation
    • Implement additional workflows for different types of queries
    • Create custom error handling and validation
    • Add user authentication and rate limiting
  4. Integration Options:

    • Connect to external APIs for additional movie data
    • Add webhook endpoints for different platforms
    • Implement caching mechanisms for frequent queries
    • Add data transformation nodes for specific output formats

This workflow serves as a foundation that can be adapted to various use cases beyond movie recommendations, such as e-commerce product search, content management systems, or any scenario requiring intelligent database interaction.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1

Block 2 - MongoDBAggregate

Type / Role
n8n-nodes-base.mongoDbTool - mongoDbTool
Config choices
Version 1.1

Block 3 - Window Buffer Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.2

Block 4 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 5 - insertFavorite

Type / Role
@n8n/n8n-nodes-langchain.toolWorkflow - toolWorkflow
Config choices
Version 1.2

Block 6 - AI Agent - Movie Recommendation

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 7 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow MongoDB AI agent - intelligent movie recommendations
Complexity intermediate
Nodes 8
Categories Engineering, AI RAG
Author Pavel Duchovny
Published 17 Nov 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2554/2554.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does MongoDB AI agent - intelligent movie recommendations do?

Who is this for? This workflow is designed for: Database administrators and developers working with MongoDB Content managers handling movie databases Organizations looking to implement AI powered s...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI RAG use case.