Telegram Chatbot Powered by GPT-4o-mini AI Agent - n8n Workflow

Use this n8n workflow to create a conversational AI chatbot via Telegram. Integrates the Telegram n8n trigger with OpenAI's GPT-4o-mini using the specialized AI Agent n8n node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Individuals looking for accessible n8n templates to rapidly deploy custom AI chatbots.
Automation specialists needing a robust n8n node setup for managing conversational agents.
Developers seeking to integrate OpenAI GPT functionality directly into a messaging platform via a simple n8n workflow.
Users who want a practical example of how to combine an n8n trigger with LLM processing.

Overview

This useful n8n workflow demonstrates how to build a highly responsive AI assistant accessible directly through Telegram. By leveraging the flexibility of the n8n platform, users can quickly turn any Telegram chat into a direct interface for the powerful OpenAI GPT-4o-mini model. This specific n8n workflow uses the dedicated AI Agent n8n node to handle the conversation logic and context, while the Telegram n8n trigger manages the incoming messages. This eliminates the need for complex external server setups, allowing the user to manage both the communication layer and the processing layer entirely within n8n. This setup serves as one of the most practical n8n templates for rapid AI integration and deployment.

How it Works

The conversational process begins immediately upon receiving a message, initiated by the Telegram Trigger n8n trigger node. This n8n trigger listens for new user messages directed at the configured Telegram bot and starts the n8n workflow execution.


  1. Input Acquisition: The message content is extracted from the payload received by the Telegram n8n trigger and passed directly to the AI Agent n8n node.

  2. AI Processing: The AI Agent node is configured with a specific system prompt ("Respond to this as a helpful assistant with emojis") and connected to the OpenAI Chat Model n8n node, utilizing the efficient gpt-4o-mini model. The agent processes the user's query and generates a contextually appropriate response.

  3. Response Delivery: The output generated by the AI Agent is then routed to the final Telegram n8n node. This node uses an expression to dynamically retrieve the chatId from the original Telegram Trigger event, ensuring the generated AI response is sent back precisely to the user who initiated the conversation, completing the automated n8n workflow loop.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' function.

  2. Set up Telegram Credentials: You must configure credentials for the Telegram n8n trigger and the final Telegram n8n node. This requires a Telegram Bot Token.

Click on the Credentials field within the 'Telegram Trigger' and 'Telegram' nodes.
Create a new Telegram Api credential by providing your Bot Token.

  1. Set up OpenAI Credentials: Configure the credentials for the 'OpenAI Chat Model' n8n node.

* Provide your OpenAI API Key.

  1. Activate the Trigger: Ensure the 'Telegram Trigger' is set up with the correct webhook ID and that your bot is listening for the specified updates (messages).

  2. Activate the n8n workflow: Save and activate the n8n workflow to enable the chatbot functionality.

Node Details

Telegram Trigger (n8n trigger):
Function: Serves as the starting point of the n8n workflow, listening for incoming messages sent to the configured Telegram bot.
Key Configuration: Listens for message updates.
AI Agent (n8n node):
Function: Manages the conversational logic and applies a predefined persona (helpful assistant with emojis) to the incoming text before routing it to the Language Model.
Key Configuration: Input Text expression targets {{ $json.message.text }}; includes system instructions.
OpenAI Chat Model (n8n node):
Function: Provides the Large Language Model capabilities for the AI Agent.
Key Configuration: Uses the gpt-4o-mini model, ideal for fast and cost-effective responses within this n8n template.
Telegram (n8n node):
Function: Sends the AI-generated response back to the user.
Key Configuration: Retrieves the message content from the AI Agent output ({{ $json.output }}) and dynamically determines the recipient using the original chat ID ({{ $('Telegram Trigger').item.json.message.chat.id }}).

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by
Mike
Mike

Featured*