Reply to Telegram text and voice messages with an OpenAI GPT-4o-mini chatbot and memory

Go to Workflow
0 views
Built by TakatoYamada TakatoYamada
Created on May 30, 2026

Description

Quick Overview
This workflow listens for incoming Telegram messages, sends each message to an OpenAI chat model via an AI agent with per-chat memory, and replies in the same Telegram conversation with a concise, language-matched response.

How it works
Triggers when a new Telegram message is received by your bot.
Sends the message text to an AI chatbot agent configured with a system prompt to respond concisely in the user’s language.
Uses the OpenAI GPT-4o-mini chat model to generate the response and a per-chat memory buffer keyed by Telegram chat ID to retain recent context.
Posts the generated reply back to the originating Telegram chat.

Setup
Create a Telegram bot with BotFather, then add your Telegram bot credentials to the Telegram Trigger and Telegram reply nodes.
Add your OpenAI credentials and select the desired model in the OpenAI chat model node.
Ensure the workflow has access to store conversation context and adjust the memory window length or system message if needed.

Nodes Used (8)

AI Agent
@n8n/n8n-nodes-langchain.agent
Calculator
@n8n/n8n-nodes-langchain.toolCalculator
Google Sheets
n8n-nodes-base.googleSheets
OpenAI
@n8n/n8n-nodes-langchain.openAi
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow
Telegram
n8n-nodes-base.telegram
Wikipedia
@n8n/n8n-nodes-langchain.toolWikipedia