BULDRR AI Vikash KumarSchedule a Call
Updated Workflow #1338

n8n Telegram GPT-4 Bot 2026: Memory + Web Search + Custom Tools (LangChain)

Build a production-ready GPT-4 Telegram bot with n8n and LangChain — featuring persistent conversation memory, web search capabilities, and custom tools, all without a server.

n8n Telegram GPT-4 Bot 2026: Memory + Web Search + Custom Tools (LangChain)
CONNECTS
telegramTrigger, agent, lmChatOpenAi, memoryBufferWindow, toolWorkflow, httpRequest, telegram, set
Learn it with AI
✦ SEE IT BEFORE YOU DOWNLOAD

The canvas, and the 8 nodes behind it.

Preview of the n8n Telegram GPT-4 Bot 2026: Memory + Web Search + Custom Tools (LangChain) workflow canvas in n8n
✦ NODE BY NODE

What runs inside this workflow

n8n Telegram GPT-4 Bot 2026: Memory + Web Search + Custom Tools (LangChain) is built from these n8n nodes: telegramTrigger, agent, lmChatOpenAi, memoryBufferWindow, toolWorkflow, httpRequest, telegram, set.

    ✦ LEARN HOW TO BUILD THIS WORKFLOW WITH AI
    Send this workflow to your assistant and have it taught to you.

    Each button opens the assistant with the prompt already written — asking it to explain this exact workflow step by step, as if teaching a complete beginner.

    Using our workflows often?
    Mark BULDRR AI as a preferred source and our templates surface higher in your own Google results.
    Add as a preferred source

    What This Automation Does

    Most Telegram groups die because no one has time to answer the same questions over and over. This n8n workflow fixes that permanently. It connects your Telegram bot to OpenAI GPT-4 via LangChain — so when someone sends a message, the bot reads it, thinks about it using GPT-4, and replies intelligently within seconds. Ask it a question, it answers. Ask it to generate an image, it uses DALL-E 3 to create one and sends it back inside the chat. What makes this different from a basic chatbot: it remembers. The Window Buffer Memory node stores the last 10 messages per user, so conversations feel natural — not like talking to a broken FAQ bot. The full node stack: Telegram Trigger → AI Agent (LangChain) → GPT-4 Chat Model + DALL-E 3 Tool → Telegram reply. Every message handled automatically, 24/7, with zero manual input from you.

    What This Production-Ready Telegram AI Bot Can Do

    This is not a basic chatbot. It's a fully featured AI bot built on LangChain + GPT-4 — ready to deploy in real Telegram groups and chats from day one. Here's exactly what it does: Conversation Memory Remembers the last 10 messages per chat using Window Buffer Memory. Each Telegram chat gets its own isolated history — no cross-talk between users or groups. Custom Tool Use (LangChain Agent) The AI doesn't just reply — it decides which tool to use based on the message. Ask a question → GPT-4 answers. Ask for an image → DALL-E 3 generates it automatically. AI Image Generation Send any image prompt to the bot and DALL-E 3 creates and delivers the image directly inside Telegram. No extra steps, no external links. Real-Time Telegram Replies Fires the moment a message arrives via Telegram Trigger. Processes, generates, and replies — all within seconds. Error Handling Built In Special character escaping node ensures AI replies always render correctly in Telegram's HTML mode — no broken formatting, no display errors. One workflow. Five production-grade features. No server hosting required — n8n handles everything.

    Production-Ready vs a Basic Telegram Bot — What's the Difference?

    Most Telegram bot tutorials show a bot that echoes messages
    or sends a fixed reply. This workflow is built differently.

    Feature Basic Hobby Bot This Workflow
    Understands context ✗ ✓ (GPT-4)
    Remembers past messages ✗ ✓ (per-chat memory)
    Generates images ✗ ✓ (DALL·E 3)
    Uses tools intelligently ✗ ✓ (LangChain Agent)
    Handles special characters ✗ ✓ (error node built-in)
    Scales to multiple chats ✗ ✓ (isolated sessions)
    No server hosting needed Varies ✓ (runs on n8n)

    A hobby bot answers one type of message in one fixed way.
    This workflow handles whatever your users throw at it —
    questions, image requests, follow-ups, multi-turn conversations
    — and responds intelligently every time.


    Who Should Use This Workflow

    Telegram community managers: You run a group of 500+ members and the same 10 questions get asked daily. This bot answers them all instantly, every time, without you typing a word. Course creators and coaches: You have a student support group on Telegram. This bot handles common questions about curriculum, deadlines, and resources — so you only step in for complex ones. SaaS founders and indie hackers: You want to add an AI support layer to your product's Telegram community without hiring a support agent. This workflow costs pennies per message vs. hundreds per month for a human. Content creators: Your audience asks for images, ideas, and explanations. The DALL-E 3 integration means your bot can generate custom images on request, right inside the Telegram chat. No coding skills required — just an n8n instance, a Telegram Bot token, and an OpenAI API key.  

    Tools and Services Used

    • Telegram Bot API: Receives user messages.
       
    • Langchain Nodes: Link the workflow with OpenAI models and memory.
     
    • OpenAI GPT-4 (gpt-4-1106-preview): Understands and replies to text messages.
       

    Beginner Step-by-Step: How to Use This Workflow in n8n

    Step 1: Create your Telegram Bot 1. Open Telegram and search for @BotFather. 2. Send /newbot and follow the prompts to name your bot. 3. BotFather gives you a Bot Token — copy it. It looks like: 7123456789:AAFxyz-abcdefghijklmnop 4. To use the bot in a group, add it as an admin and disable privacy mode via BotFather (/setprivacy → Disable). Step 2: Get your OpenAI API Key 5. Go to platform.openai.com → API Keys → Create new secret key. 6. Copy it immediately — you can't see it again after closing the page. 7. Make sure your OpenAI account has GPT-4 and DALL-E 3 access (requires a paid plan). Step 3: Import the workflow into n8n 8. Click the Download button on this page. 9. In n8n: top menu → Import → Import from File → select the .json. 10. All 8 nodes will load: Telegram Trigger, AI Agent, OpenAI Chat Model, Window Buffer Memory, DALL-E Tool, HTTP Request, Telegram (send), Set (error correction). Step 4: Add credentials 11. Click the Telegram Trigger node → Credentials → Add New → paste your Bot Token. 12. Click the OpenAI Chat Model node → Credentials → Add New → paste your OpenAI API Key. 13. Use the same OpenAI credential for the DALL-E HTTP Request node. Step 5: Set the session key for memory 14. Click the Window Buffer Memory node. 15. Set the Session Key field to this expression: =chat_with_{{ $('Listen for incoming events').first().json.message.chat.id }} 16. This makes sure each Telegram chat gets its own conversation memory — different users won't mix histories. Step 6: Test before going live 17. Click "Execute Workflow" in n8n. 18. Send a text message to your Telegram bot — it should reply with a GPT-4 generated answer. 19. Send "generate an image of a sunset" — it should reply with a DALL-E 3 image in the chat. 20. If both work, toggle the workflow to Active.  

    Inputs, Processing Steps, and Outputs

    Inputs

    • New text messages or commands from Telegram group chats.
     

    Processing Steps

    • Telegram Trigger catches incoming messages.
     
    • AI Agent reads message and decides if reply or image needed.
     
    • OpenAI Chat Model (GPT-4) generates text answer when needed.
     
    • Window Buffer Memory keeps last 10 messages to remember conversation.
     
    • Dall-E 3 Tool detects image requests and triggers image creation.
     
    • Generate Image in Dall-E 3 HTTP Request calls OpenAI image API.
     
    • Telegram node sends text or photo responses back.
     
    • Correct errors node cleans special characters for Telegram display.
     

    Outputs

    • AI-generated text replies to user questions or chats.
     
    • AI-created images based on user prompts delivered inside Telegram.
     

    Common Edge Cases and Failures

    • If the Telegram bot does not receive messages, verify webhook URL is set and bot privacy settings allow message access.
       
    • Invalid OpenAI API keys cause message generation failures—renew or correct keys immediately.
     
    • Image generation may fail if Dall-E API quota is reached or prompt is empty.
     

    Customization Ideas

    • Change text model parameters inside OpenAI Chat Model node to adjust creativity or response style.
     
    • Modify Window Buffer Memory's number of stored messages to keep longer or shorter conversation history.
     
    • Add tools such as Wikipedia search or weather lookup nodes to widen user support.
     
    • Change Telegram message parsing mode from HTML to Markdown for different text formatting.
     
    • Translate system and human prompts inside AI Agent node to support multiple languages.
     

    Sample Prompt in AI Agent Node

    The following prompt directs AI response and when to create images.  
    
    System: You are a helpful assistant. Reply to users or generate images if asked.
    Human: {{$json.message.text}}
    
    Adjust this prompt inside the AI Agent node under parameters for message processing.  

    Sample Expression for Window Buffer Memory session key

    Use this to separate conversations per chat in memory node:  
    =chat_with_{{ $('Listen for incoming events').first().json.message.chat.id }}
    
    This prevents mixing histories from different Telegram chats.  

    Special Character Escaping in Telegram Messages

    Use this expression to fix AI reply message so Telegram shows it right in HTML mode:  
    {{ $('AI Agent').item.json.output.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """) }}

    Real-World Example: A Course Creator's Support Bot

    Rahul runs an online n8n automation course with 800 students in a Telegram group. Before this workflow, he spent 90 minutes daily answering the same questions: "How do I connect Gmail?", "Where is the webhook URL?", "Can n8n generate images?" After setting up this workflow with a custom system prompt trained on his course FAQ, the bot now handles 85% of student questions automatically — including generating example workflow diagrams on request via DALL-E 3. Setup time: 35 minutes. Daily time saved: 90 minutes. Student response time: dropped from hours to under 5 seconds.

    Summary of Results

    ✓ Full AI Telegram bot — text replies + image generation in one workflow ✓ GPT-4 powered — understands context, nuance, and complex questions ✓ DALL-E 3 integration — generates images on request inside Telegram ✓ Conversation memory — remembers last 10 messages per user ✓ Works in private chats and group chats ✓ No coding needed — set up in under 35 minutes ✓ Fully customizable — change model, memory size, system prompt, language ✓ Free to download — only pay for OpenAI API usage  

    Frequently Asked Questions

    How to import and configure the workflow in n8n?

    Download the workflow file. Open n8n editor and use Import from File. Add <a href="https://buldrr.com/workflows/build-ai-powered-telegram-assistant-n8n-openai/" title="Build AI-Powered Telegram Assistant with n8n &#038; OpenAI" data-wpil-monitor-id="2343">Telegram and OpenAI</a> API keys. Update any IDs as needed. Test with Telegram messages. Activate the workflow.

    What causes the Telegram Trigger node to not receive messages?

    If webhook URL is not registered properly or Telegram bot privacy settings block messages, the trigger will not fire.

    How to keep conversation context for each user chat?

    Set dynamic session keys in <a href="https://buldrr.com/workflows/build-ai-chatbot-long-term-memory-telegram-n8n/" title="Build an AI Chatbot with Long-Term Memory &#038; Telegram Integration using n8n" data-wpil-monitor-id="2344">Window Buffer Memory node</a> using chat IDs from incoming Telegram messages to isolate conversation history.

    Can the workflow use AI models other than GPT-4?

    Yes. Change the model parameter in OpenAI Chat Model node to use GPT-3.5 or other supported models.

    Vikash Kumar
    WRITTEN BY
    Vikash Kumar
    Founder, BULDRR AI
    Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.

    Related workflows.

    All 10,467+ templates →
    FREE 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. Open template → FREE 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. Open template → FREE 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. Open template → FREE 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. Open template → FREE Automate Archiving Spotify Discover Weekly with n8n This automation workflow solves the hassle of manually archiving your Spotify Discover Weekly playlist by automatically comparing and adding only unique tracks to an archive playlist every Monday. It saves time, avoids duplicates, and keeps your archived music collection organized effortlessly using n8n. Open template → FREE Automate Analyzing Sales Call Transcripts with n8n & AI Agents This n8n workflow automates the extraction of structured insights from sales call transcripts using AI agents focused on sales, marketing, and product teams. It streamlines data processing, enabling faster decision-making and team alignment. Open template → FREE Automated SSL Expiry Alert System with n8n & Google Sheets This n8n workflow automates SSL certificate expiry monitoring by fetching URLs from Google Sheets, checking their SSL status via SSL-Checker.io, updating the sheet with results, and sending targeted email and Telegram alerts for certificates that are invalid or near expiry. Open template → FREE Automate Task Creation in ClickUp with n8n Struggling to manually create tasks in ClickUp? This beginner-friendly n8n workflow automates task creation, saving you time and reducing errors. Learn how to create tasks automatically with a simple trigger and ClickUp integration. Open template → FREE Automate Todoist Task Snoozing with n8n Workflow Struggling to manage and snooze your Todoist tasks efficiently? This detailed n8n workflow automates moving tasks between Inbox and Snoozed projects based on due dates, saving you hours of manual task juggling and ensuring timely task returns. Open template → FREE Build OpenAI Assistant with Google Drive Using n8n Automation This workflow automates creating and updating an OpenAI-powered Travel Assistant using a Google Drive file for accurate, specific user replies. It saves time by streamlining assistant updates and chat interactions seamlessly. Open template → FREE Automate WooCommerce Product Announcements on Twitter & Telegram Save time and boost your WooCommerce store's visibility by automatically posting new product announcements on Twitter and Telegram with this n8n workflow. Avoid manual posting errors and reach your audience instantly when new products go live. Open template → FREE Automate Zendesk to Asana Task Creation with n8n This detailed guide shows how to automate task creation in Asana from new Zendesk tickets using n8n. It solves the common challenge of manually duplicating support requests into project management, saving time and reducing errors. Open template → FREE Automate Image Alt Text Auditing & Enhancement with n8n & OpenAI Discover how this n8n workflow automates auditing and enhancing image alt text from any webpage using OpenAI GPT-4. It helps fix poor or missing alt attributes quickly and accurately, saving hours of manual work and improving web accessibility. Open template → FREE Create OpenAI Citation Workflow in n8n for File Retrieval This n8n workflow automates citation and source retrieval from OpenAI's vector store files, ensuring accurate content referencing and formatted output. It solves the problem of incomplete or strange citation text generated by AI, providing reliable markdown or HTML-ready citations for file-based AI assistance. Open template → FREE Automate Squarespace Order Fulfillment with n8n Workflow This n8n workflow automates order fulfillment for Squarespace Commerce by fetching pending orders and fulfilling them automatically, saving hours of manual work. It ensures timely fulfillment and customer notifications with seamless API integration. Open template → FREE Phishing Analysis Automation with n8n, URLScan.io & VirusTotal Automate phishing URL analysis with n8n using URLScan.io and VirusTotal. This workflow extracts URLs from unread Outlook emails, scans for threats, and reports via Slack, saving hours on threat detection. Open template → FREE Automate Image Analysis with Local Ollama Vision Models in n8n Struggling to extract detailed insights from images for business or research? This n8n workflow automates exhaustive image analysis using multiple local Ollama Vision Models, delivering structured, markdown-formatted results saved directly to Google Docs for collaboration and ease of use. Open template → FREE Automate Website Change Alerts N8N Telegram — Complete Guide [2026] Learn how to automate website change alerts n8n telegram with this step-by-step guide. Includes workflow examples, tips, and best practices for 2026. Open template → FREE Automate Text-to-Speech with Elevenlabs & n8n Webhook Save hours in your content creation by automating text-to-speech generation using n8n's webhook and Elevenlabs API. This workflow ensures seamless audio generation from text inputs, eliminating manual conversion errors and delays. Open template → FREE Automate Jira Notifications to Telegram with n8n Workflow This detailed guide shows how to automate Jira issue notifications to Telegram using n8n. Save hours by instantly sending updates, creation alerts, and assignment notifications to the right Telegram users, improving team communication and tracking. Open template → FREE Automate Daily Berlin Weather Updates to LINE with n8n Save time and stay informed by automatically sending daily weather updates for Berlin via LINE using n8n automation. This workflow fetches weather data every morning and messages you directly, eliminating manual checking and keeping you updated efficiently. Open template → FREE n8n Twitter Thread Generator 2026: AI Writes & Posts Threads From Any Content This n8n workflow uses AI to automatically convert any content — blog posts, videos, articles — into ready-to-post Twitter/X threads, complete with hooks and formatting. Open template → FREE Backup n8n Workflows to Bitbucket with Rate Limit Handling Automate daily backups of your n8n workflows directly to Bitbucket, intelligently managing API rate limits to avoid errors. This workflow ensures your automation definitions are safely versioned with minimal manual effort. Open template → FREE Automate Member and Activity Sync from Google Sheets to Orbit This blog explains how to automate moving community member data and their activities from Google Sheets into Orbit using n8n, solving tedious manual updates and ensuring accurate data syncing. Open template → FREE Sync Outlook Calendar with Notion via n8n Automation This workflow automates syncing Microsoft Outlook Calendar events into a Notion database. It solves the problem of manual calendar updates, saving time and reducing errors by automatically creating or updating Notion pages for your events. Open template →
    ✦ WANT THIS RUNNING IN YOUR BUSINESS?

    We’ll set it up for you.

    Tell us what you want it to do. We’ll wire the workflow, connect the credentials, and hand it over running.

    Keep exploring.