π¬ Reply to Telegram text and voice messages with an OpenAI GPT-4o-mini chatbot and memory
β‘ 346 views Β· π¬ Support Chatbots
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
Google Sheets, Telegram, Telegram Trigger, AI Agent, OpenAI Chat Model, Simple Memory
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File