Block 1 - When chat message received
- Type / Role
- @n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
- Config choices
- Version 1.1
This workflow is provided as-is. Please review and test before using in production.
Dynamically switch between LLMs for AI Agents using LangChain Code Purpose This example workflow demonstrates a way to connect multiple LLMs to a single AI Agent/LangChain Node and programmatically...
@n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.code, n8n-nodes-base.set, n8n-nodes-base.noop, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.sentimentanalysis, @n8n/n8n-nodes-langchain.chainllm
This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Mario.
Original n8n.io sourceThis example workflow demonstrates a way to connect multiple LLMs to a single AI Agent/LangChain Node and programmatically use one – or in this case loop through them.
This AI workflow takes in customer complaints and generates a response that is being validated before returned. If the answer was not satisfactory, the response will be generated again with a more capable model.
Beware that the order of the used LLMs is determined by the order they have been added to the workflow, not by the position on the canvas.
After cloning this workflow into your environment, open the chat and send this example message:
> I really love waiting two weeks just to get a keyboard that doesn’t even work. Great job. Any chance I could actually use the thing I paid for sometime this month?
Most likely you will see that the first validation fails, causing it to loop back to the generation node and try again with the next available LLM.
Since AI responses are unpredictable, the results and number of tries will differ for each run.
Please note, that this workflow can only run on self-hosted n8n instances, since it requires the LangChain Code Node.
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.
| Workflow | Dynamically switch between LLMs for AI agents using LangChain code |
|---|---|
| Complexity | advanced |
| Nodes | 22 |
| Categories | Support Chatbot, AI Chatbot |
| Author | Mario |
| Published | 01 May 2025 |
Use the JSON export at /data/workflows/3820/3820.json as the source template for this automation.
Open n8n, import the downloaded JSON, and review each node before activating the workflow.
Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.
Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.
Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.
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.
Dynamically switch between LLMs for AI Agents using LangChain Code Purpose This example workflow demonstrates a way to connect multiple LLMs to a single AI Agent/LangChain Node and programmatically...
Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.
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 Support Chatbot, AI Chatbot use case.