> For the complete documentation index, see [llms.txt](https://docs.n8n.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.n8n.io/build/integrate-ai/understand-ai-components/agents-vs-chains.md).

# Agents vs chains

In this workflow you can choose whether your chat query goes to an agent[^1] or chain[^2]. It shows some of the ways that agents are more powerful than chains.

{% @n8n-blocks/n8n-workflow-demo content="%7B%0A%20%20%22name%22%3A%20%22Agents%20vs%20chains%22%2C%0A%20%20%22nodes%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%229e1d8f35-e1ba-4600-977d-e54a919c2c62%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Chat%20Trigger%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22%40n8n%2Fn8n-nodes-langchain.chatTrigger%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%20520%2C%0A%20%20%20%20%20%20%20%20420%0A%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%22webhookId%22%3A%20%2284bfdbd0-e2ce-4bfa-b746-985e64a14484%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22options%22%3A%20%7B%7D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%224b89df4b-4f78-4f52-a51d-eeb66a7948e5%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22OpenAI%20Chat%20Model%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22%40n8n%2Fn8n-nodes-langchain.lmChatOpenAi%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201020%2C%0A%20%20%20%20%20%20%20%20420%0A%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%22credentials%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22openAiApi%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22id%22%3A%20%22tW3bkXa0SAK0OzvR%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22OpenAi%20account%20Debs%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22options%22%3A%20%7B%7D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%22a0045df2-d212-4e6a-a2d4-722136dcb8b5%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22OpenAI%20Chat%20Model1%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22%40n8n%2Fn8n-nodes-langchain.lmChatOpenAi%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%20980%2C%0A%20%20%20%20%20%20%20%20880%0A%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%22credentials%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22openAiApi%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22id%22%3A%20%22tW3bkXa0SAK0OzvR%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22OpenAi%20account%20Debs%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%22d702f647-1fa7-4b4f-91b1-e0152326ea11%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Simple%20Memory%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22%40n8n%2Fn8n-nodes-langchain.memoryBufferWindow%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201.2%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201280%2C%0A%20%20%20%20%20%20%20%20460%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%2276cc359a-5ec8-446a-a8e0-9035d18247cb%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Wikipedia%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22%40n8n%2Fn8n-nodes-langchain.toolWikipedia%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201540%2C%0A%20%20%20%20%20%20%20%20340%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22options%22%3A%20%7B%7D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%2201d1785f-f7c4-47d2-97b7-76eeff68002d%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22AI%20Agent%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22%40n8n%2Fn8n-nodes-langchain.agent%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201.5%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201060%2C%0A%20%20%20%20%20%20%20%20140%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22messages%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22messageValues%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22message%22%3A%20%22Every%20time%20you%20respond%2C%20start%20your%20response%20with%20the%20sentence%3A%20%5C%22This%20message%20came%20from%20the%20chain%5C%22.%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%22bcdcd704-13f5-4906-b337-7ec4629b9781%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Basic%20LLM%20Chain%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22%40n8n%2Fn8n-nodes-langchain.chainLlm%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201.4%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201040%2C%0A%20%20%20%20%20%20%20%20680%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22content%22%3A%20%22%23%23%20Try%20it%20out%5Cn%5CnSelect%20%2A%2AChat%2A%2A%2C%20and%20try%20out%20these%20queries%3A%5Cn%5Cn-%20Please%20show%20me%20a%20Wikipedia%20article%20about%20cats%20%28agent%29%5Cn-%20Please%20show%20me%20a%20Wikipedia%20article%20about%20cats%20%28chain%29%5Cn-%20What%20was%20my%20last%20question%3F%20%28chain%29%5Cn-%20What%20was%20my%20last%20question%3F%20%28agent%29%5Cn%22%2C%0A%20%20%20%20%20%20%20%20%22height%22%3A%20343.8587887368956%2C%0A%20%20%20%20%20%20%20%20%22color%22%3A%204%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%22f08e231b-739a-4b9d-b738-139b7e3bd60b%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Sticky%20Note%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22n8n-nodes-base.stickyNote%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%20240%2C%0A%20%20%20%20%20%20%20%20420%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22content%22%3A%20%22%2A%2ASet%20your%20credentials%2A%2A%22%2C%0A%20%20%20%20%20%20%20%20%22height%22%3A%20193%2C%0A%20%20%20%20%20%20%20%20%22width%22%3A%20167%2C%0A%20%20%20%20%20%20%20%20%22color%22%3A%202%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%225421fd4d-c82f-483a-8238-869b9a10000d%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Sticky%20Note1%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22n8n-nodes-base.stickyNote%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%20980%2C%0A%20%20%20%20%20%20%20%20360%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22content%22%3A%20%22%2A%2ASet%20your%20credentials%2A%2A%22%2C%0A%20%20%20%20%20%20%20%20%22height%22%3A%20193%2C%0A%20%20%20%20%20%20%20%20%22width%22%3A%20167%2C%0A%20%20%20%20%20%20%20%20%22color%22%3A%202%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%2223fac3a8-a220-40a5-8d3d-4a3013b0f1da%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Sticky%20Note2%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22n8n-nodes-base.stickyNote%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%20940%2C%0A%20%20%20%20%20%20%20%20820%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22content%22%3A%20%22%2A%2AMemory%20allows%20the%20agent%20to%20access%20previous%20parts%20of%20the%20chat%2A%2A%5Cn%22%2C%0A%20%20%20%20%20%20%20%20%22height%22%3A%20244%2C%0A%20%20%20%20%20%20%20%20%22color%22%3A%205%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%2208397bde-06e4-4bff-b130-cbc4408a0ecc%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Sticky%20Note3%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22n8n-nodes-base.stickyNote%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201200%2C%0A%20%20%20%20%20%20%20%20360%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22content%22%3A%20%22%2A%2AThe%20agent%20can%20use%20the%20Wikipedia%20tool%20to%20access%20articles%20from%20Wikipedia%2A%2A%22%2C%0A%20%20%20%20%20%20%20%20%22height%22%3A%20238%2C%0A%20%20%20%20%20%20%20%20%22color%22%3A%205%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%22a53ff4f2-9d06-4166-9ad6-760cd8fe4a54%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Sticky%20Note4%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22n8n-nodes-base.stickyNote%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201460%2C%0A%20%20%20%20%20%20%20%20240%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22rules%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22values%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22conditions%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22options%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22caseSensitive%22%3A%20false%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22leftValue%22%3A%20%22%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22typeValidation%22%3A%20%22strict%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22conditions%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22leftValue%22%3A%20%22%3D%7B%7B%20%24json.chatInput%20%7D%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22rightValue%22%3A%20%22agent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22operator%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22operation%22%3A%20%22contains%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22combinator%22%3A%20%22and%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22conditions%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22options%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22caseSensitive%22%3A%20false%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22leftValue%22%3A%20%22%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22typeValidation%22%3A%20%22strict%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22conditions%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22id%22%3A%20%22248f4a34-89c1-4d1e-867a-daa024c8635a%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22leftValue%22%3A%20%22%3D%7B%7B%20%24json.chatInput%20%7D%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22rightValue%22%3A%20%22chain%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22operator%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22operation%22%3A%20%22contains%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22combinator%22%3A%20%22and%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22options%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22ignoreCase%22%3A%20true%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%22ab2bff8d-e914-421d-9aa3-9d0ad815cea6%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Check%20user%20input%20for%20%5C%22chain%5C%22%20or%20%5C%22agent%5C%22%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22n8n-nodes-base.switch%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%203%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%20740%2C%0A%20%20%20%20%20%20%20%20420%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22parameters%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22content%22%3A%20%22%23%23%20Next%20steps%5Cn%5CnLearn%20more%20about%20%5BAdvanced%20AI%20in%20n8n%5D%28https%3A%2F%2Fdocs.n8n.io%2Fadvanced-ai%2F%29%22%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22id%22%3A%20%22f077f8e6-789a-4db1-8402-fb173c296017%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Sticky%20Note5%22%2C%0A%20%20%20%20%20%20%22type%22%3A%20%22n8n-nodes-base.stickyNote%22%2C%0A%20%20%20%20%20%20%22typeVersion%22%3A%201%2C%0A%20%20%20%20%20%20%22position%22%3A%20%5B%0A%20%20%20%20%20%20%20%201560%2C%0A%20%20%20%20%20%20%20%20840%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%0A%20%20%5D%2C%0A%20%20%22pinData%22%3A%20%7B%7D%2C%0A%20%20%22connections%22%3A%20%7B%0A%20%20%20%20%22Chat%20Trigger%22%3A%20%7B%0A%20%20%20%20%20%20%22main%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22node%22%3A%20%22Check%20user%20input%20for%20%5C%22chain%5C%22%20or%20%5C%22agent%5C%22%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22main%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22index%22%3A%200%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22OpenAI%20Chat%20Model%22%3A%20%7B%0A%20%20%20%20%20%20%22ai\_languageModel%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22node%22%3A%20%22AI%20Agent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22ai\_languageModel%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22index%22%3A%200%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22OpenAI%20Chat%20Model1%22%3A%20%7B%0A%20%20%20%20%20%20%22ai\_languageModel%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22node%22%3A%20%22Basic%20LLM%20Chain%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22ai\_languageModel%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22index%22%3A%200%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22Simple%20Memory%22%3A%20%7B%0A%20%20%20%20%20%20%22ai\_memory%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22node%22%3A%20%22AI%20Agent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22ai\_memory%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22index%22%3A%200%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22Wikipedia%22%3A%20%7B%0A%20%20%20%20%20%20%22ai\_tool%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22node%22%3A%20%22AI%20Agent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22ai\_tool%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22index%22%3A%200%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22Check%20user%20input%20for%20%5C%22chain%5C%22%20or%20%5C%22agent%5C%22%22%3A%20%7B%0A%20%20%20%20%20%20%22main%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22node%22%3A%20%22AI%20Agent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22main%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22index%22%3A%200%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22node%22%3A%20%22Basic%20LLM%20Chain%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22main%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22index%22%3A%200%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%22active%22%3A%20false%2C%0A%20%20%22settings%22%3A%20%7B%0A%20%20%20%20%22executionOrder%22%3A%20%22v1%22%0A%20%20%7D%2C%0A%20%20%22versionId%22%3A%20%2259784a0f-0601-4456-b48d-9a191e203461%22%2C%0A%20%20%22meta%22%3A%20%7B%0A%20%20%20%20%22templateCredsSetupCompleted%22%3A%20true%2C%0A%20%20%20%20%22instanceId%22%3A%20%22cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7%22%0A%20%20%7D%2C%0A%20%20%22id%22%3A%20%22qK43vJw6dRZkXo6h%22%2C%0A%20%20%22tags%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22createdAt%22%3A%20%222021-06-25T07%3A47%3A07.640Z%22%2C%0A%20%20%20%20%20%20%22updatedAt%22%3A%20%222021-06-25T07%3A47%3A07.640Z%22%2C%0A%20%20%20%20%20%20%22id%22%3A%20%221%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22docs%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22createdAt%22%3A%20%222023-02-22T12%3A06%3A03.372Z%22%2C%0A%20%20%20%20%20%20%22updatedAt%22%3A%20%222023-02-22T12%3A06%3A03.372Z%22%2C%0A%20%20%20%20%20%20%22id%22%3A%20%2263%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22createdBy%3ADebs%22%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D" url="<https://raw.githubusercontent.com/n8n-io/n8n-docs/refs/heads/main/docs/_workflows/advanced-ai/examples/agents_vs_chains.json>" %}

## Key features <a href="#key-features" id="key-features"></a>

This workflow uses:

* [Chat Trigger](broken://spaces/BKcbOzIWja8NfqKDcqHc/pages/ufgV9cVbZYhO7UuKUvU1): start your workflow and respond to user chat interactions. The node provides a customizable chat interface.
* [Switch node](/integrations/builtin/core-nodes/n8n-nodes-base.switch.md): directs your query to either the agent or chain, depending on which you specify in your query. If you say "agent" it sends it to the agent. If you say "chain" it sends it to the chain.
* [Agent](/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent.md): the Agent node interacts with other components of the workflow and makes decisions about what tools[^3] to use.
* [Basic LLM Chain](/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm.md): the Basic LLM Chain node supports chatting with a connected LLM, but doesn't support memory[^4] or tools.

## Using the example <a href="#using-the-example" id="using-the-example"></a>

To load the template into your n8n instance:

1. Download the workflow JSON file.
2. Open a new workflow in your n8n instance.
3. Copy in the JSON, or select **Workflow menu** <img src="/spaces/GixZThfitWP21x2gQFpD/files/LPMolGd367bGOPTPoinr" alt="Workflow menu icon" data-size="line"> > **Import from file...**.

The example workflows use Sticky Notes to guide you:

* Yellow: notes and information.
* Green: instructions to run the workflow.
* Orange: you need to change something to make the workflow work.
* Blue: draws attention to a key feature of the example.

[^1]: AI agents are artificial intelligence systems capable of responding to requests, making decisions, and performing real-world tasks for users. They use large language models (LLMs) to interpret user input and make decisions about how to best process requests using the information and resources they have available.

[^2]: AI chains allow you to interact with large language models (LLMs) and other resources in sequences of calls to components. AI chains in n8n don't use persistent memory, so you can't use them to reference previous context (use AI agents for this).

[^3]: In an AI context, a tool is an add-on resource that the AI can refer to for specific information or functionality when responding to a request. The AI model can use a tool to interact with external systems or complete specific, focused tasks.

[^4]: In an AI context, memory allows AI tools to persist message context across interactions. This allows you to have a continuing conversations with AI agents, for example, without submitting ongoing context with each message. In n8n, AI agent nodes can use memory, but AI chains can't.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.n8n.io/build/integrate-ai/understand-ai-components/agents-vs-chains.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
