Agentic Telegram Bot with DALL-E Image Generation - n8n Workflow

Build an advanced conversational Telegram bot using this powerful n8n workflow template. Integrates GPT-4o, persistent chat memory, and DALL-E for image generation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Markdown-formatted:
Automation specialists looking for advanced n8n templates integrating LangChain.
Developers wanting to deploy a feature-rich AI bot via Telegram.
Users seeking to implement contextual chat memory and external tools within an n8n workflow.
Anyone interested in seeing how the LangChain n8n node set enables complex AI agents.

Overview

This comprehensive n8n workflow provides a robust solution for deploying an intelligent, agentic AI assistant directly within Telegram. Unlike basic chatbots, this advanced system utilizes LangChain nodes to give the AI memory and external tool-use capability. The n8n workflow starts with a message from Telegram and routes it through a GPT-4o powered agent. When a user requests an image, the agent leverages a dedicated DALL-E generation tool configured within this n8n template, providing a seamless multi-modal experience. This is a crucial n8n workflow for showcasing the power of integrated AI services.

How it Works

Markdown-formatted:


  1. Trigger Event (n8n trigger): The process begins with the 'Listen for incoming events' Telegram n8n trigger, which activates the n8n workflow whenever a new message is received in the configured Telegram bot.

  2. Agent Activation: The incoming message is passed to the 'AI Agent' n8n node (LangChain Agent). This node is the brain, deciding whether to respond directly or use an external tool.

  3. Core Components: The agent utilizes the 'OpenAI Chat Model' (GPT-4o) for reasoning and the 'Window Buffer Memory' n8n node to maintain context throughout the conversation, ensuring the bot remembers past interactions using a session key derived from the chat ID.

  4. Tool Use (Image Generation): If the user asks for an image, the agent selects the 'Generate image in Dalle' n8n node. This specialized LangChain HTTP Request tool calls the OpenAI DALL-E-3 API to create the image.

  5. Tool Use (Image Sending): If DALL-E returns a URL, the agent forwards this URL to the 'Send back an image' Telegram tool n8n node, which handles sending the media file back to the chat.

  6. Final Reply: The 'AI Agent' output (either the text response or confirmation of the image generation) is sent via the 'Send final reply' Telegram n8n node back to the user, completing the n8n workflow execution.

Installation Guide

Markdown-formatted:


  1. Import the n8n template: Copy the provided JSON data and import it into your n8n instance via the 'Workflows' menu.

  2. Telegram Credentials: Set up credentials for the Telegram n8n trigger ('Listen for incoming events') and the two Telegram action n8n node instances. You will need a bot token.

  3. OpenAI Credentials: Configure the required OpenAI credentials for both the 'OpenAI Chat Model' and the 'Generate image in Dalle' n8n node. This API key must have access to GPT-4o and the DALL-E models.

  4. Activate the n8n workflow: Once credentials are set up, ensure the n8n workflow is marked as 'Active' and deployed via its webhook URL. The Telegram n8n trigger is now listening for messages.

Node Details

Markdown-formatted:
Listen for incoming events (Telegram Trigger): The starting n8n trigger. It listens for all updates () in the bot, initiating the n8n workflow upon receiving a user message.
OpenAI Chat Model (LangChain Node): Configured to use gpt-4o with a temperature of 0.7 and a slight frequencyPenalty of 0.2. It serves as the Large Language Model for the agent's core reasoning.
Window Buffer Memory (LangChain Node): Manages conversation history. It uses a dynamic sessionKey based on the Telegram chat.id to ensure unique, contextual memory for each user. It maintains a context window length of 10 messages.
AI Agent (LangChain Node): The orchestrator of this n8n workflow. It receives the user's message and the system message instructs it to address the user by their first name and to prioritize image generation if requested.
Generate image in Dalle (LangChain Tool): A crucial custom tool within the n8n workflow. It is configured as an HTTP POST request to the DALL-E API. The tool description explicitly guides the AI Agent to call this tool when the user asks to draw or generate an image.
Send back an image (Telegram Tool): Used specifically by the AI Agent to process the URL output from the DALL-E tool and send the resulting image document back to the user's chat ID.
Send final reply (Telegram Node): The concluding n8n node, responsible for sending the final text output (the conversation response or a notification) back to the user.

Related n8n Workflows

Free

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

Let's connect!

Featured*