Advanced AI Agent System with Think-Act Reasoning using OpenRouter - n8n Workflow

Build sophisticated AI agents in n8n using a Think-Act architecture. This n8n workflow leverages OpenRouter language models and robust n8n node configurations for complex, multi-step reasoning tasks.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • AI Developers and Machine Learning Engineers building complex autonomous systems.

  • Automation specialists implementing resilient, structured AI agents using n8n.

  • Users requiring flexible and high-performance LLM routing via OpenRouter within an n8n workflow.

  • Anyone looking to utilize advanced AI patterns like Think-Plan-Act within their automation strategy.

Overview

This n8n workflow demonstrates how to construct highly reliable and multi-step AI agents using the Think-Act architectural pattern. This pattern separates the planning (Thinking) phase from the execution (Acting) phase, leading to more accurate, auditable, and structured outputs. The entire system is built upon various OpenRouter models, offering flexible access to leading LLMs. The structure utilizes multiple interconnected n8n node setups to manage different tasks, triggered by dedicated webhooks, showcasing a scalable approach to deploying sophisticated AI services using n8n templates. This workflow is ideal for scenarios requiring intricate logical steps, like sophisticated data extraction, complex query resolution, or multi-tool execution.

How it Works

This n8n workflow is initiated by one of two distinct webhooks, allowing for two parallel agent pipelines. We will trace the first pipeline triggered by the start-thinking n8n trigger:


  1. Trigger and Configuration: The workflow starts via the start-thinking webhook. The request payload is passed immediately to the Config Code n8n node, which typically sets up initial context, prompts, and tools for the agent.

  2. The Think Agent (Planning Phase): The data moves to the Think LangChain Agent n8n node. This agent, configured with the OpenRouter Chat Model4 and supported by the Thinking output parser, determines the required steps, tools, and overall strategy to solve the initial problem.

  3. The Act Agent (Execution Phase): The output of the Think agent—the plan—is passed to the Act LangChain Agent n8n node. The Act agent uses the OpenRouter Chat Model and Task Output Parser to execute the steps defined in the plan, generating the final result.

  4. Structured Output: Both the thinking and acting phases are stabilized using specialized n8n node components like the Structured Output Parsers, which force the LLM output into a reliable JSON format, enhancing the utility of the overall n8n workflow.

  5. Final Action: The result is passed to a placeholder node (No Operation, do nothing), which serves as the integration point for subsequent actions in your extended n8n templates.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON and paste it into your n8n instance using the 'New' button and selecting 'Import from JSON'.

  2. Setup Credentials: You will need OpenRouter credentials. Ensure you have configured an OpenRouter API key credential within n8n. Apply this credential to all instances of the 'OpenRouter Chat Model' n8n node.

  3. Configure Webhooks: Note the two Webhook n8n trigger nodes (start-thinking and get-weather). Activate the workflow and test the URLs associated with these triggers to ensure they are correctly receiving input data.

  4. Customize Code Nodes: Review the Config and Config1 Code n8n nodes. These nodes define the system prompts, tool schemas, and initial context passed to the AI agents. You must customize the JavaScript within these nodes to define the specific capabilities and goals of your agents.

  5. Review Parsers: Verify the settings within the Structured Output Parser n8n node types to match the expected JSON schema of your final desired output.

Node Details

Webhook (start-thinking / get-weather): Serves as the initial n8n trigger for the agent pipelines. It accepts incoming HTTP requests to start the reasoning process.
Code (Config / Config1): Critical n8n node for setting up the agent context. Used to inject dynamic variables, tools definitions (not explicitly shown but implied for Agent nodes), and specific system instructions before invoking the LLM.
LangChain Agent (Think / Act): The core intelligence of this n8n workflow. The 'Think' agent creates the plan, and the 'Act' agent executes the planned steps. Both are essential n8n node types for complex AI orchestration.
OpenRouter Chat Model (Multiple Instances): Functions as the Large Language Model provider. Used extensively throughout the workflow—in the Think Agent, the Act Agent, and within the Output Parsers—to handle reasoning, planning, and auto-correction.
Output Parser Autofixing (Task Output Parser / Thinking output parser): These specialized n8n node components ensure that the potentially messy text output from the LLM is corrected and formatted into a structured, usable format (often JSON), greatly improving the reliability of the n8n workflow.
Structured Output Parser: Used in conjunction with the autofixing parsers to define the strict JSON schema required for the AI's output, maintaining consistency across the entire n8n template.

Related n8n Workflows

Paid

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

Senior Full Stack engineer with more than 13y of building web applications.

Featured*