Command-Based Telegram Bot for AI Article Summarization and Image Prompt Handling - n8n Workflow

Deploy a versatile n8n workflow using a Telegram trigger and OpenAI. This n8n template handles dynamic command routing for automated article summarization and image prompt processing.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • AI Service Developers: Users looking to expose OpenAI services (summarization, image generation) through a simple messaging interface.

  • Content Curators: Individuals needing quick, bulleted summaries of articles found online.

  • n8n Automation Specialists: Those seeking advanced examples of conversational interface design using command-based routing (IF n8n node logic).

  • Bot Builders: Anyone interested in creating multi-functional bots without proprietary tools.

Overview

This robust n8n workflow solves the challenge of consolidating multiple AI functions into a single user-friendly interface. By leveraging the Telegram Trigger n8n node, users can interact with powerful AI models simply by sending command-prefixed messages (like /summary or /img ). This specific n8n template demonstrates effective command parsing using sequential IF logic nodes, ensuring that the correct sequence of actions—from fetching external data via an n8n node to processing it with the OpenAI n8n node—is executed accurately. This architecture allows the n8n automation to be easily scaled by adding more commands and subsequent specialized n8n node paths, making it a key example of how to build sophisticated, conversational AI agents using the n8n platform.

How it Works

The entire flow begins instantly with the Trigger: Telegram Webhook n8n trigger node, which listens for new messages sent to the bot. The message content is immediately passed through a cascaded series of IF nodes for dynamic command routing:


  1. Help Command Routing: The first IF n8n node checks if the message starts with /help. If true, the n8n workflow sends a predefined help menu back to the user via a Telegram n8n node.

  2. Summary Command Routing: If not /help, the flow checks for the /summary command. If matched, the n8n automation executes the web scraping and summarization path:

An HTTP Request n8n node fetches the raw HTML content from the provided URL.
The HTML n8n node (Parse: Extract Text from HTML) cleans the content, extracting only usable text.
The OpenAI n8n node (AI: Generate Article Summary) uses a specific prompt to summarize the extracted text into 10–12 concise bullet points.
The resulting summary is then sent back to the user via the Telegram n8n node.

  1. Image Command Routing: If neither of the previous commands matched, the flow checks for the /img command. This path routes the prompt to the second OpenAI n8n node (AI: Process Image Generation Request). Currently, this n8n workflow sends a notification back to the user confirming the prompt was received, demonstrating where a full image generation API call (like Stability AI) would be integrated.

Installation Guide

To utilize this highly functional n8n workflow, follow these steps:


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. Telegram Setup: Configure the Trigger: Telegram Webhook n8n trigger node by selecting your Telegram API credential. This will automatically generate a webhook URL.

  3. OpenAI Credentials: Update the AI: Generate Article Summary and AI: Process Image Generation Request n8n nodes with your personal OpenAI API Key credential. Ensure the correct credential is selected for the OpenAI n8n node.

  4. Activate: Save the n8n workflow and toggle the activation switch to 'Active'. Your Telegram bot is now ready to process commands.

  5. Testing: Send commands like /help or /summary to your Telegram bot to test the full n8n automation.

Node Details

Trigger: Telegram Webhook (n8n trigger node): The starting point of the n8n workflow. It listens for message updates from the configured Telegram bot, initiating the command-based logic flow.
Route: Check for Help Command / Summary Command / Image Command (IF n8n node): These core logic nodes perform sequential command routing. They check if the input message text starts with specific strings (/help, /summary, /img). This is essential for directing the n8n workflow to the correct processing path.
Fetch: Download Article Content (HTTP Request n8n node): Used in the summarization path. It dynamically fetches the content of the URL provided in the Telegram message, using a specific User-Agent header to ensure successful extraction.
Parse: Extract Text from HTML (HTML n8n node): Cleans the raw HTML content received from the HTTP Request n8n node, isolating clean body text while skipping non-essential elements like links and images.
AI: Generate Article Summary (OpenAI n8n node): The central processing step for summarization. It sends the clean extracted text to OpenAI, instructing it to produce a structured summary of 10–12 bullet points. This powerful n8n node handles the complex AI interaction.
Response: Send Article Summary / Help Menu / Image Generation Notice (Telegram n8n node): These nodes handle the final output, sending formatted text or notifications back to the user's specific Telegram chat ID, completing the n8n automation cycle.

Related n8n Workflows

Free

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

Building AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host

Featured*