Automate Movie Recommendations with MongoDB and OpenAI in n8n

This n8n workflow leverages OpenAI and MongoDB aggregation to automate movie recommendations and favorites tracking, saving hours for movie curators and enthusiasts. It smartly queries movie data and stores user favorites seamlessly.
agent
lmChatOpenAi
mongoDbTool
+3
Workflow Identifier: 1522
NODES in Use: chatTrigger, agent, lmChatOpenAi, mongoDbTool, memoryBufferWindow, toolWorkflow
Automate movie picks with n8n and OpenAI

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What this workflow does

This workflow acts as a chat assistant that listens for movie recommendation requests.
It uses AI to understand messages and build MongoDB queries to find movies.
It also can save users’ favorite movies into the database automatically.
This stops you from spending a lot of time writing queries or managing favorite lists manually.


Who should use this workflow

This is useful for anyone managing movie recommendations online.
People who want to automate chat replies and reduce errors when searching and saving movies will find this helpful.
No need to write complex queries every time or update favorites by hand.


Tools and services used

  • Webhook node: Receives chat messages from users.
  • AI Agent – Movie Recommendation node: Understands chat input and uses tools to handle queries and saving data.
  • OpenAI Chat Model node: Processes user text to improve understanding.
  • MongoDBAggregate node: Runs MongoDB aggregation queries generated by AI.
  • Window Buffer Memory node: Keeps up to 10 past messages to keep chat context.
  • insertFavorite tool workflow node: Adds user favorite movies into MongoDB.

Input → Process → Output

Inputs

  • User chat messages sent to the webhook.
  • User commands or confirmations to save favorites.

Processing steps

  • Webhook node activates the workflow on incoming chat.
  • AI Agent interprets chat, deciding what MongoDB query to run or if favorites need inserting.
  • OpenAI Chat Model helps understand natural language requests.
  • MongoDBAggregate runs AI-provided aggregation pipelines to fetch movie data.
  • Window Buffer Memory keeps chat context so replies feel connected.
  • insertFavorite workflow inserts favorite movie title data into MongoDB if user confirms.

Outputs


Beginner step-by-step: How to run this workflow in n8n

Step 1: Download and Import Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open your n8n editor.
  3. Click on “Import from File” and select the downloaded workflow.

Step 2: Configure API Keys and Credentials

  1. Add your OpenAI API Key in the OpenAI Chat Model node.
  2. Set up MongoDB credentials in the MongoDBAggregate and insertFavorite nodes.
  3. Update any references to collections, IDs, or database names if your setup differs.

Step 3: Check and Edit Prompts if Needed

  1. In the AI Agent node, make sure the prompt matches your style or needs.
  2. Copy the prompt below for exact use:
    =Assistant for best movies context, you have tools to search using "MongoDBAggregate" and you need to provide a MongoDB aggregation pipeline code array as a "query" input param. User input and request: {{ $json.chatInput }}. Only when a user confirms a favorite movie use the insert favorite using the "insertFavorite" workflow tool of to insertFavorite as { "title" : "<TITLE>" }.

Step 4: Test the Workflow

  1. Send a test chat message via the webhook URL, such as “Recommend me 5-star movies”.
  2. Watch the workflow execution to ensure MongoDB returns movies and the chatbot replies.
  3. Test inserting a favorite movie by confirming in chat.

Step 5: Activate for Production

  1. Enable the workflow by switching it to active in n8n.
  2. Set your chat bot or frontend to send messages to the webhook URL.
  3. Monitor logs to catch errors early.
  4. Consider setting retries or alerts for failures.

For those using self-host n8n, see self-host n8n resources for setup options.


Customization ideas

  • Change the number in Window Buffer Memory node to keep more or less chat history.
  • Modify MongoDB collection or aggregation query type to target different movie genres.
  • Add new AI tools in the AI Agent node to allow rating movies or handling comments.

Common issues and fixes

  • Error executing MongoDB aggregation pipeline
    Means the AI made a wrong query. Test the query outside n8n and adjust the AI prompt.
  • Webhook not receiving chat messages
    Check if the Webhook node is set to public and the webhook URL used is correct.
  • Insert favorite workflow not running as expected
    Verify the integration inside the AI Agent node and test the insertFavorite tool separately.

Summary of results

✓ Saves hours of manual work writing queries and data entry.
✓ Reduces mistakes by automating movie searches and favorites.
✓ Provides faster, more personal chatbot replies.
✓ Keeps conversation memory for better user experience.
✓ Allows easy updates to movie favorites in MongoDB.


Automate movie picks with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

The MongoDBAggregate node will error. Test the pipeline manually and adjust AI prompts to match your database structure.
Add the API Key in the credentials section of the OpenAI Chat Model node inside n8n.
Insufficient information provided about handling multiple favorites; testing is needed to confirm.
Send chat messages to the webhook URL and watch the workflow execution in n8n for expected movie recommendations and database updates.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.