Build a Telegram AI Chatbot with Multi-Format Input & OpenAI
detail.loadingPreview
Create a powerful Telegram AI chatbot that handles text & voice messages. Leverages OpenAI GPT-4o and Langchain for intelligent responses. Automate conversations effortlessly.
🚀Ready to Deploy This Workflow?
About This Workflow
How it works
This n8n workflow enables you to build a sophisticated Telegram AI chatbot capable of processing both text and voice messages. It utilizes the @n8n/n8n-nodes-langchain nodes for AI capabilities and the base n8n-nodes-base.telegram nodes for Telegram integration.
- Listen for incoming events: The workflow starts with the
Listen for incoming events(Telegram Trigger) node, which waits for new messages on your Telegram bot. - Determine content type: A
Determine content type(Switch) node analyzes the incoming message to differentiate between text and voice inputs. - Handle text messages: If it's a text message, it proceeds to
Combine content and set properties. - Handle voice messages: If it's a voice message, it's downloaded by the
Download voice filenode and then transcribed to text using theConvert audio to textnode (OpenAI). - Combine and prepare message: The
Combine content and set properties(Set) node consolidates the message content (either direct text or transcribed voice) and identifies the message type (text/voice) and if it's a forwarded message. - Engage AI Agent: The
AI Agentnode, powered by Langchain's Agent and OpenAI's GPT-4o (OpenAI Chat Model), processes the combined message. It utilizesWindow Buffer Memoryto maintain conversation context. - Send final reply: The
Send final replynode formats the AI's response into HTML and sends it back to the user on Telegram. - Error Handling: If an unsupported message type is received,
Send error messageis triggered. ASend Typing actionprovides user feedback during processing.
Key Features
- Process both text and voice messages.
- Utilize OpenAI's GPT-4o for intelligent responses.
- Maintain conversation context with Langchain memory.
- Handle message formatting for Telegram HTML.
- Flexible message type detection (text/voice/forwarded).
- Robust error handling for unsupported inputs.
How To Use
- Set up Telegram Bot: Create a Telegram bot using BotFather and obtain your Bot Token.
- Configure Telegram Credentials: In n8n, set up your Telegram API credentials using the obtained Bot Token.
- Configure OpenAI Credentials: Obtain an OpenAI API key and set up your OpenAI API credentials in n8n.
- Connect Nodes: Ensure the
Listen for incoming eventsnode is connected to your Telegram bot. TheOpenAI Chat ModelandConvert audio to textnodes require your OpenAI API credentials. - Adjust Memory: Modify the
Window Buffer Memorynode'scontextWindowLengthif needed for longer conversation histories. - Activate Workflow: Enable the workflow in n8n.
Apps Used
Workflow JSON
{
"id": "fe4d61c3-961e-42a5-b9a7-b182588597df",
"name": "Build a Telegram AI Chatbot with Multi-Format Input & OpenAI",
"nodes": 0,
"category": "AI & LLM",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: fe4d61c3-961e...
About the Author
SaaS_Connector
Integration Guru
Connecting CRM, Notion, and Slack to automate your life.
Statistics
Related Integrations
- Telegram + Telegram Trigger(362 workflows)
- Gmail + Schedule Trigger(270 workflows)
- Gmail + Google Sheets(245 workflows)
- Schedule Trigger + Telegram(152 workflows)
- Gmail + Split Out(132 workflows)
- Gmail + Gmail Trigger(119 workflows)
- Google Sheets + Telegram(118 workflows)
- Form Trigger + Gmail(107 workflows)
- Gmail + Google Drive(93 workflows)
- Airtable + Schedule Trigger(86 workflows)
Related Workflows
Discover more workflows you might like
Build a Business WhatsApp AI RAG Chatbot with OpenAI & Qdrant
Automate customer service with a WhatsApp AI RAG chatbot. Integrates OpenAI, Qdrant, and Google Drive for intelligent responses. Save hours weekly!
Build an AI Travel Assistant with Google Drive & OpenAI
Create a custom OpenAI AI Assistant that leverages your Google Drive documents for travel planning. Automate travel advice and responses.
DeepSeek AI Agent: Build Long-Term Memory Telegram Bots with OpenAI API
Automate Telegram bots with DeepSeek AI, OpenAI API, and long-term memory. Build intelligent agents that learn and personalize interactions.
Dynamically Generate HTML Pages with OpenAI Structured Output & Tailwind
Instantly create custom HTML pages using OpenAI's structured output and Tailwind CSS. Ideal for developers and growth hackers seeking rapid UI generation.
AI-Powered WordPress Post Creation: Keywords to Draft Article & Featured Image
Automate WordPress post creation. Input keywords, generate AI content, draft articles, and add featured images with DALL-E. Boost your content workflow instantly.
Generate Speech from Text with OpenAI TTS via Webhook
Automate text-to-speech conversion using OpenAI's TTS API triggered by a webhook. Perfect for developers and growth hackers.