Build a GPT-4o Conversational Agent with n8n & LangChain [2026 Tutorial]

Create a fully conversational AI agent using GPT-4o, LangChain, and n8n. Includes multi-turn memory, tool integration, and complete workflow JSON.
agent
toolWikipedia
toolSerpApi
+4
Workflow Identifier: 1659
NODES in Use: manualChatTrigger, agent, memoryBufferWindow, toolWikipedia, toolSerpApi, lmChatOpenAi, stickyNote
Automate chat with n8n and LangChain

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What this workflow does

This workflow creates a chat assistant using GPT-4o-mini that answers user questions quickly and correctly.

It solves the problem of searching many websites for facts, saving time and avoiding mistakes.

The outcome is a chat agent that understands what users say, remembers recent talk, and uses Wikipedia and SerpAPI for fresh information.


Who should use this workflow

This is useful for customer support teams or anyone who must answer many questions fast and with good info.

It helps reduce time spent searching and improves answer accuracy.


Tools and services used


Inputs, Processing, and Outputs

Inputs

Processing Steps

  • The Window Buffer Memory node keeps the last 20 messages to keep conversation flow.
  • The AI Agent node reads the user input and decides how to answer.
  • The AI Agent calls the Tool Wikipedia and Tool SerpAPI nodes to find facts live from the web.
  • The Chat OpenAI node with GPT-4o-mini model generates the reply using collected info and memory.

Outputs

  • The AI Agent sends a clear, up-to-date, and well-informed chat reply to the user.

Beginner step-by-step: How to run this workflow in n8n

1. Importing the workflow

  1. Download the workflow file using the Download button on this page.
  2. Open n8n editor and click “Import from File”.
  3. Select and upload the downloaded workflow file.

2. Configuring the workflow

  1. Enter your OpenAI API Key in the Chat OpenAI node’s credentials.
  2. Add your SerpAPI key in the Tool SerpAPI node.
  3. No changes needed for Wikipedia API since it is public.
  4. Check if any IDs, emails, channels, or folders need updating for your setup (if applicable).

3. Testing and activating

  1. Run the workflow manually and send a test message through the Manual Chat Trigger node.
  2. See if the AI Agent returns a thoughtful answer.
  3. If all tests pass, activate the workflow for live use.
  4. For better privacy and control, consider also self-host n8n.

Customization ideas

  • You can change how many past messages the AI remembers by adjusting “contextWindowLength” in the Memory Buffer Window node.
  • Add more search or knowledge tools by including more LangChain-compatible tool nodes connected to the AI Agent.
  • Switch the GPT model in the Chat OpenAI node to a newer one if available for better answers.
  • Modify the AI Agent’s prompt settings to change how the agent thinks or replies.
  • Replace the manual trigger node with a webhook to accept chat messages automatically from other apps or websites.

Possible problems and fixes

  • AI Agent not responding: Check OpenAI API key and usage limits; verify credentials are correct.
  • Search tools not working: Confirm Wikipedia and SerpAPI nodes are connected and configured properly.
  • Memory not keeping context: Make sure Memory Buffer Window node is linked to AI Agent’s memory input and increase history length if needed.

Summary of results

✓ Faster answers to complex questions without manual searching.

✓ Reduced errors from outdated or missing info.

✓ Smarter chat replies that remember recent conversation.

→ Saves support teams many hours weekly.

→ Improves user satisfaction with instant, accurate help.


Automate chat with n8n and LangChain

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Yes, other supported OpenAI models can replace GPT-4o-mini by updating the model name in the Chat OpenAI node settings.
No, the Window Buffer Memory node keeps only the last 20 messages per session. Permanent storage is not provided.
Yes, extra LangChain-compatible tool nodes like Google Search can be connected to the AI Agent’s tool inputs.
Replace the Manual Chat Trigger node with a webhook node to receive external chat messages and start the workflow automatically.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.