Personal Telegram Assistant with GPT-4 and Conversation Memory - n8n Workflow

Use this powerful n8n workflow to build a personal AI assistant on Telegram that handles both text and voice messages using OpenAI transcription and GPT-4.1-mini, leveraging the LangChain n8n node for context.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers looking for complex n8n templates leveraging AI.
Users wanting a personal, context-aware AI assistant integrated directly into Telegram.
Automation specialists exploring multi-modal n8n workflow capabilities.
Teams needing robust n8n node configurations for natural language processing.

Overview

This sophisticated n8n workflow template solves the challenge of creating a multi-modal, stateful AI assistant within a messaging platform like Telegram. Instead of simple request-response actions, this n8n automation leverages the LangChain AI agent architecture combined with OpenAI's robust transcription capabilities. A critical feature is the inclusion of the Simple Memory n8n node, ensuring the AI remembers previous messages in the conversation—a key requirement for useful chatbots. Whether the user sends a text message or a voice note, this n8n workflow handles the input gracefully, processes it with a GPT-4.1-mini model, and returns a helpful, context-aware response directly to the user's Telegram chat. This complete n8n solution demonstrates the power of integrating communication platforms with advanced AI models.

How it Works

The operational sequence of this complex n8n workflow is meticulously designed to handle varying input types while maintaining conversational context:


  1. n8n Trigger Activation: The process begins with the Telegram Trigger n8n node, which immediately initiates the n8n workflow whenever a new message (text or voice) is received in the configured Telegram chat.

  2. Input Routing via Switch: A Switch n8n node determines the input type. It checks for the existence of either the message.text field (direct text input) or the message.voice.file_id field (voice note input).

  3. Voice Handling Path: If a voice file is detected, the n8n workflow uses the Telegram: Get a file n8n node to fetch the associated audio data. This file is then processed by the OpenAI: Transcribe a recording n8n node, converting the spoken words into a usable text string.

  4. Data Preparation and Normalization: Both the direct text path and the transcribed voice path converge on Edit Fields n8n nodes. These nodes normalize the data, extracting the cleaned text message and the chat ID (which serves as the session identifier).

  5. Core AI Processing: The standardized data flows into the AI Agent n8n node. This agent utilizes the powerful OpenAI Chat Model (configured as GPT-4.1-mini) for generating the sophisticated response.

  6. Memory Integration: Crucially, the Simple Memory n8n node is connected to the AI Agent. It uses the user's chat ID as a session key, enabling the n8n workflow to maintain context across multiple turns, simulating a true conversation.

  7. Final Action: The resulting AI output is then automatically sent back to the user via the Telegram: Send a text message n8n node, completing the execution of this robust n8n template.

Installation Guide

To set up this comprehensive n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and import it into your n8n instance using the 'New' menu and selecting 'Import from JSON'.

  2. Telegram Credentials: You must configure the required Telegram API credentials for the Telegram Trigger and the two subsequent Telegram n8n nodes (Get a file and Send a text message). This typically requires a Bot Token from BotFather.

  3. OpenAI Credentials: Set up credentials for the two OpenAI n8n nodes (Transcribe a recording and OpenAI Chat Model). Ensure you use an API key capable of utilizing the specified model (GPT-4.1-mini).

  4. Activate the Trigger: The Telegram Trigger n8n node must be activated and configured to listen for messages in your target chat or group.

  5. Testing: Send a text message or a voice note to your Telegram bot to test the full range of functionality provided by this n8n template.

Node Details

This n8n workflow utilizes several specialized n8n nodes to achieve its multi-modal functionality:

Telegram Trigger (n8n trigger):
Function: Serves as the starting point of the n8n workflow, initiating execution upon receiving a message update in Telegram.
Key Configuration: Listens specifically for 'message' updates.
Switch (n8n node):
Function: Directs the flow based on whether the incoming Telegram message contains message.text or message.voice.fileid.
Telegram: Get a file (n8n node):
Function: Executes on the voice path, downloading the actual audio file data using the provided fileid.
OpenAI: Transcribe a recording (n8n node):
Function: Converts the received voice recording into text, enabling the AI agent to process the user's request. This uses the OpenAI API.
Edit Fields / Edit Fields1 (n8n node):
Function: Standardizes the input format, extracting the cleaned text and setting the sessionId based on the Telegram chat ID, which is essential for session management in the n8n workflow.
AI Agent (n8n node):
Function: The core orchestration engine, combining the Language Model and Memory for contextual responses. It uses a defined system message to guide its personality.
OpenAI Chat Model (n8n node):
Function: The Large Language Model (GPT-4.1-mini) used by the AI Agent to generate responses to user queries within this n8n workflow.
Simple Memory (n8n node):
Function: Maintains conversational history for the AI Agent, using a buffer window length of 7 and the chat ID as the session key to ensure context persistence across multiple turns.
Telegram: Send a text message (n8n node):
* Function: The final action, sending the AI Agent's generated output back to the user's Telegram chat ID.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by
Balakrishnan C
Balakrishnan C

Featured*