Automate Telegram Chatbot: AI, Multi-Format & Contextual Replies
Automate Telegram interactions with AI, reducing manual response time to zero and enhancing user satisfaction through instant, personalized replies.
Managing diverse Telegram messages (text, voice) and providing consistent, intelligent, and personalized responses manually is time-consuming and inefficient. This n8n workflow leverages AI to automatically process text and voice messages, maintain conversation context, and deliver instant, personalized replies in proper HTML format on Telegram.

Documentation
Telegram AI Multi-Format Chatbot
This workflow creates an advanced Telegram chatbot that can understand both text and voice messages, remember past conversations, and provide intelligent, personalized responses using cutting-edge AI.
Key Features
- Multi-Format Input: Seamlessly process and respond to both text and voice messages from Telegram users.
- AI-Powered Understanding: Leverage OpenAI's advanced models (GPT-4o) for intelligent comprehension and generation of human-like replies.
- Contextual Memory: Maintain conversation history with a window buffer, enabling more relevant and coherent AI interactions.
- Personalized Responses: Address users by their name and tailor replies based on conversation context and message origin.
- HTML Formatting: Ensure professional and readable replies by automatically formatting AI output into Telegram-supported HTML.
- Error Handling: Gracefully manage unsupported message types, sending friendly error messages to users.
How It Works
The workflow activates upon receiving any Telegram message, immediately sending a 'typing' action for a smooth user experience. It intelligently determines if the incoming message is text, voice, or an unsupported type. For voice messages, it downloads and transcribes the audio using OpenAI's speech-to-text. The original text or transcribed voice message, along with its type and origin, is then prepared for the AI agent. This agent, powered by OpenAI's GPT-4o and equipped with a 10-turn memory buffer, generates a personalized and context-aware response, formatted in Telegram-compatible HTML. Finally, the AI's reply, including a thank you note, is delivered to the user, with a fallback mechanism for HTML entity correction.