LLM Powered Personalized Recommendations with MongoDB and AI

This workflow delivers personalized recommendations from a MongoDB database using natural language inputs. Key nodes include Chat Trigger for user requests, Condition nodes for input and security validation, AI Agent for generating recommendations, MongoDB Tool for querying data, and Set nodes for context and response formatting. It ensures safe, tailored suggestions with robust error handling. To set up, install n8n by downloading from n8n.io for self-hosting or sign up at cloud.n8n.io for cloud use. Obtain MongoDB credentials (connection string, database, collection) from your provider (e.g., MongoDB Atlas). Add MongoDB credentials in n8n under Credentials > Add Credential > MongoDB, entering your connection details. For the AI Agent, add OpenAI credentials via Credentials > Add Credential > OpenAI API, using an API key from platform.openai.com. Import the workflow JSON via Workflows > Import. Configure the Chat Trigger node with a public webhook URL (use ngrok for local testing) at path /recommendation-webhook. Ensure the MongoDB Tool node targets the recommendations collection with a valid aggregation pipeline. Test by sending a request like “Recommend electronics under $100” to the webhook URL. Verify the AI Agent generates a MongoDB query and the Response Formatter node outputs structured recommendations. Check Condition nodes for errors like invalid inputs (>2000 characters) or malicious content (e.g., containing ‘script’), triggering error handlers with messages like “Invalid message format, use 1-2000 characters.” Deploy by saving and enabling the workflow, ensuring the webhook remains active. For errors, validate MongoDB credentials for connection issues or OpenAI API key validity in n8n’s Credentials section. Confirm outputs in the Response Formatter node include success status, recommendation details, and session metadata, ensuring only safe queries are processed and recommendations align with user preferences.

$6.99

Workflow steps: 11

Integrated apps: chatTrigger, if, set

LLM Powered Personalized Recommendations with MongoDB and AI preview