Build flexible AI agents using this dynamic automation. Leverage OpenRouter with the OpenAI node, memory, and chat capabilities in your custom n8n workflow.
Download this n8n workflow template and start using it instantly.
n8n automation developers looking for highly customizable LLM solutions.
Users who need access to multiple AI models (DeepSeek, Mistral, etc.) without changing their core n8n workflow structure.
Technical teams seeking cost-effective and flexible LLM routing through OpenRouter.
Anyone creating interactive AI agents using an n8n trigger for conversational input.
This powerful automation solves the common challenge of vendor lock-in by routing all Large Language Model (LLM) requests through OpenRouter. OpenRouter acts as a unified API layer, providing access to dozens of models while maintaining compatibility with the standard OpenAI LangChain integration within n8n. This specific n8n workflow utilizes the When chat message received n8n trigger to start a conversational flow, ideal for building dynamic chat agents. By defining the model name dynamically in the Settings n8n node, users can switch between models like DeepSeek, Gemini, or proprietary models instantly. This reusable n8n templates structure is essential for building flexible and future-proof AI applications using the n8n platform, providing unmatched flexibility within an n8n workflow.
The n8n workflow begins with the When chat message received n8n trigger, which activates upon receiving a new chat input, supplying the user's prompt and a unique session ID.
Settings n8n node (a Set node), where crucial variables are defined: the specific model to use (e.g., deepseek/deepseek-r1-distill-llama-8b), the prompt extracted from the n8n trigger, and the sessionId for context.LLM Model (configured for OpenRouter access) and the Chat Memory n8n node (configured to use the dynamic sessionId for conversation history).AI Agent n8n node. The agent receives the input prompt defined in the Settings n8n node and uses the selected LLM via OpenRouter, maintaining conversation history through the memory buffer. This allows the AI agent n8n node to process complex, multi-turn conversations.AI Agent processes the request using the specified third-party model, generating a response that completes this robust n8n workflow, leveraging the power of OpenRouter.To use this advanced n8n workflow, follow these steps:
https://openrouter.ai/api/v1.LLM Model n8n node is pre-configured to use the "OpenRouter" credential. Ensure the connection is established correctly.Settings n8n node and adjust the model assignment value if you wish to use a different LLM supported by OpenRouter (see the accompanying sticky note for examples). This change only requires modifying one n8n node.When chat message received n8n trigger will require platform-specific configuration depending on where the chat input originates. When chat message received (n8n trigger):
Function: Serves as the starting point (n8n trigger) for the conversational process, providing the user input (chatInput) and necessary context (sessionId). This initiates the entire n8n workflow.
Key Configuration: Essential for initiating the workflow structure, supplying data to the subsequent n8n node.
Settings (n8n node - Set):
Function: Dynamically defines the parameters for the AI run, including the specific model (e.g., DeepSeek) accessed through OpenRouter, the user prompt, and the unique sessionId needed for the memory n8n node.
Key Configuration: Assignments include model: deepseek/deepseek-r1-distill-llama-8b, prompt: {{ $json.chatInput }}, and sessionId: {{ $json.sessionId }}.
LLM Model (n8n node - LangChain Chat OpenAI):
Function: Configures the actual connection to the Large Language Model. Although labeled OpenAI, it uses OpenRouter credentials and base URL for vendor flexibility, making this n8n node crucial for integration.
Key Configuration: Uses the dynamic expression ={{ $json.model }} to select the provider model. Credentials are set to "OpenRouter."
Chat Memory (n8n node - LangChain Memory Buffer Window):
Function: Stores the history of the conversation, allowing the AI agent to reference previous messages in the current session ID, ensuring continuous context within the n8n workflow.
Key Configuration: Session Key is dynamically set to ={{ $json.sessionId }}.
AI Agent (n8n node - LangChain Agent):
Function: The central processing logic of the n8n workflow. It orchestrates the memory and the LLM model to generate intelligent responses based on the input prompt defined in the Settings n8n node.
* Key Configuration: Input text is dynamically set using ={{ $json.prompt }}.
Deploy this expert n8n workflow to automatically scrape Upwork jobs, extract client names using AI, find validated LinkedIn profiles via Phantombuster, and enrich lead data using Hunter.io before saving to Google Sheets.

Use this powerful n8n workflow to automatically scrape fresh Upwork job listings using Apify and log the structured data directly into Google Sheets. Leverage n8n for hands-free automation.

Use this powerful n8n workflow to automatically scrape Upwork job listings, log them to Google Sheets, summarize key opportunities using OpenAI (GPT-4o mini), and receive daily email notifications via Gmail. Deploy these n8n templates today.

Implement robust API rate limiting (per minute and per hour) using Redis in an n8n workflow. Protect backend resources like Airtable easily with this essential n8n template.









































