Telegram Bot for AI Chat and Image Generation - n8n Workflow

Deploy a powerful n8n workflow to run a Telegram AI chatbot using OpenAI. Supports conversational chat, /start greetings, and DALL-E image generation. Get this n8n template now.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers and Automation Experts: Seeking ready-made n8n templates for conversational AI interfaces.
Community Managers: Needing an automated, engaging bot for Telegram groups.


  • Anyone looking to integrate advanced OpenAI capabilities (GPT-4 chat and DALL-E image generation) directly into a social messaging platform using an n8n workflow.

Overview

This powerful n8n workflow transforms a standard Telegram bot into a sophisticated AI assistant. It provides three core functions: general chat, a welcome message via the /start command, and image generation using the /image command.

By leveraging the flexibility of the n8n node structure, the automation first captures user input, optimizes the user experience by sending a 'typing' status, and then intelligently routes the request. This entire n8n workflow is designed for high efficiency and seamless integration with the OpenAI API, making it one of the most useful n8n templates for AI deployment. The initial setup includes a complex system command within an n8n node to ensure the AI responds appropriately, detects the user's language, and maintains a friendly persona, enhancing the overall quality of this specific n8n workflow.

How it Works


  1. Incoming Message: The n8n workflow starts with the Telegram Trigger n8n node, which acts as the primary n8n trigger, listening for all updates from the configured bot.

  2. Preparation and Settings: The PreProcessing and Settings n8n nodes prepare the data. The Settings node is crucial, defining system instructions for the GPT model and dynamically setting the Telegram chat action (e.g., typing for chat or uploadphoto for image requests) based on the user's message.

  3. UX Enhancement: The Send Typing action n8n node sends the calculated chat action immediately back to Telegram, ensuring the user sees the bot is 'thinking.'

  4. Command Routing: The CheckCommand Switch n8n node analyzes the message text to determine the flow path:

Path 0 (Default Chat): If no command is detected, the message is sent to the Chatmode OpenAI n8n node (GPT-4) for a conversational response.
Path 1 (/start): If /start is detected, the Greeting OpenAI n8n node generates a welcome message tailored to the user's language.
Path 2 (/image): If /image is detected, the Create an image OpenAI n8n node (DALL-E) generates an image.
Path 3 (Error): Any other unsupported command is routed to the Send error message n8n node.

  1. Final Response: Based on the executed path, either the Text reply n8n node sends the AI-generated text or the Send image n8n node posts the generated image back to the user via the Telegram API. This comprehensive n8n workflow ensures a smooth, intelligent interaction.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' button and selecting 'Import from JSON'. This is one of the easiest ways to utilize pre-built n8n templates.

  2. Set up Telegram Credentials: The Telegram Trigger n8n node requires a Telegram API credential. You must have an existing Telegram bot token configured in your n8n credentials.

  3. Set up OpenAI Credentials: The Chat_mode, Greeting, and Create an image n8n nodes all require OpenAI API credentials. Ensure you have a valid API key with access to GPT-4 and DALL-E models.

  4. Activate the n8n Workflow: Once all credentials are set and saved, activate the n8n workflow. The Telegram Trigger n8n node will automatically register its webhook with your Telegram bot, making the n8n trigger live.

Node Details

Telegram Trigger (n8n trigger):
Function: Starts the n8n workflow upon any message or update sent to the connected Telegram bot.
Key Configuration: Listens for all update types (). Requires Telegram API credentials.
Settings (Set n8n node):
Function: Initializes configuration variables, including the systemcommand (AI persona), modeltemperature, and dynamically sets the bottyping action for improved UX.
Send Typing action (Telegram n8n node):
Function: Sends a chat action (like 'typing' or 'uploading photo') to Telegram immediately, providing crucial user feedback before the AI processing completes.
CheckCommand (Switch n8n node):
Function: The central routing mechanism that analyzes the input message text, directing the flow to conversational AI, image generation, or a welcome message based on commands like /start and /image.
Chatmode (OpenAi n8n node):
Function: Handles general conversational input using GPT-4, utilizing context provided by the system_command defined earlier in the n8n workflow.
Create an image (OpenAi n8n node):
Function: Executes DALL-E image generation based on the text following the /image command. This demonstrates advanced use of this n8n node.
Text reply / Send image (Telegram n8n nodes):
Function: These nodes handle the final output, sending the AI-generated text or the image URL back to the user's Telegram chat ID, completing the n8n workflow cycle.

Related n8n Workflows

Free

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

Featured*