{"product_id":"n8n-ai-agent-workflow-javascript-custom-tool-langchain","title":"n8n AI Agent Workflow: JavaScript Custom Tool (LangChain)","description":"\u003ch3\u003eBuild a JavaScript Custom Tool AI Agent in n8n using LangChain\u003c\/h3\u003e\n\u003cp\u003eThis n8n AI Agent Workflow lets you run an \u003cstrong\u003eAI agent with a JavaScript Custom Tool (LangChain)\u003c\/strong\u003e. It uses an OpenAI-backed chat trigger to receive the user’s request, then executes your custom JavaScript tool logic through the LangChain agent to produce the final response—fully inside n8n automation.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eStarts with a \u003cstrong\u003eManual Trigger\u003c\/strong\u003e (so you can run and test the workflow on demand).\u003c\/li\u003e\n  \u003cli\u003eReceives input via the \u003cstrong\u003en8nn8n-nodes-langchainchat trigger\u003c\/strong\u003e, routing the message into a LangChain agent flow.\u003c\/li\u003e\n  \u003cli\u003eInitializes required values using the \u003cstrong\u003eset\u003c\/strong\u003e node before agent execution.\u003c\/li\u003e\n  \u003cli\u003eRuns an \u003cstrong\u003en8nn8n-nodes-langchainagent\u003c\/strong\u003e that can decide when to call tools.\u003c\/li\u003e\n  \u003cli\u003eImplements your \u003cstrong\u003eJavaScript Custom Tool\u003c\/strong\u003e using the \u003cstrong\u003en8nn8n-nodes-langchaintool code\u003c\/strong\u003e node, where the tool’s behavior is defined in code.\u003c\/li\u003e\n  \u003cli\u003eConnects the agent to an \u003cstrong\u003eOpenAI language model\u003c\/strong\u003e through the \u003cstrong\u003en8nn8n-nodes-langchainlm chat open ai\u003c\/strong\u003e node.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eExtend an AI agent with bespoke business logic\u003c\/strong\u003e (e.g., custom parsing, formatting, or rule-based actions) using a JavaScript tool.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCreate internal automation copilots\u003c\/strong\u003e in n8n that can interpret requests and invoke your custom tool when needed.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003ePrototype and test LangChain tool behaviors\u003c\/strong\u003e quickly with manual runs before integrating into larger production workflows.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSaaS operations workflows\u003c\/strong\u003e where the agent must apply deterministic transformations via code, then respond with an AI-generated result.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\u003cstrong\u003eManual Trigger\u003c\/strong\u003e\u003c\/li\u003e\n  \u003cli\u003e\u003cstrong\u003en8nn8n-nodes-langchainchat trigger\u003c\/strong\u003e\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eset\u003c\/strong\u003e (variable initialization)\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8nn8n-nodes-langchainagent\u003c\/strong\u003e (agent orchestration)\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8nn8n-nodes-langchaintool code\u003c\/strong\u003e (JavaScript Custom Tool logic)\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8nn8n-nodes-langchainlm chat open ai\u003c\/strong\u003e (OpenAI model for the chat agent)\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45837389365427,"sku":"N8N-1963","price":44.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/LhTZV6oeGjnwyIBXL6YXK_o2r31NRi.png?v=1786793794","url":"https:\/\/buyflowscripts.com\/products\/n8n-ai-agent-workflow-javascript-custom-tool-langchain","provider":"N8N Commerce","version":"1.0","type":"link"}