Automated Telegram Chatbot with Advanced Session Management
detail.loadingPreview
This n8n workflow empowers you to build a sophisticated Telegram chatbot powered by OpenAI. It intelligently manages multiple user sessions, ensuring personalized and context-aware interactions for each user.
About This Workflow
Leverage the power of OpenAI's advanced language models to create a highly interactive Telegram chatbot. This workflow seamlessly handles multiple concurrent user sessions, allowing each user to have a distinct and personalized conversation. It intelligently captures user messages, routes them to the appropriate OpenAI model for natural language processing, and maintains conversation history using a robust session management system integrated with Google Sheets. The chatbot can initiate new sessions, track current conversations, resume past interactions, provide summaries, and answer specific questions, all driven by simple Telegram commands.
Key Features
- Multi-Session Support: Manages independent conversations for multiple users simultaneously.
- AI-Powered Responses: Utilizes OpenAI's GPT-4o-mini for intelligent and context-aware replies.
- Flexible Command Handling: Responds to commands like
/new,/current,/resume,/summary, and/question. - Session Persistence: Stores and retrieves session data using Google Sheets for continuity.
- Contextual Memory: Maintains conversation history within a defined window for more coherent interactions.
How To Use
- Set up Telegram Trigger: Configure the
Telegram Triggernode with your bot token to receive incoming messages. - Implement Command Logic: Use the
Switchnode to differentiate between commands like/new,/current,/resume,/summary, and general questions. - Manage Sessions with Google Sheets: Configure the
Get sessionnode to retrieve current session details from a Google Sheet. UseDisable previous sessionto mark sessions as expired. - Integrate OpenAI: Connect the
OpenAI Chat Modelnode to your OpenAI API, specifying your preferred model (e.g.,gpt-4o-mini). - Implement Memory: Utilize the
Simple Memorynode to store and recall conversation history for each session, dynamically setting thesessionKeybased on retrieved session data. - Configure Node Connections: Ensure nodes are connected sequentially, with the output of one feeding into the input of the next based on the desired workflow logic.
Apps Used
Workflow JSON
{
"id": "edfb4d64-b7ea-48f6-9123-cfe680b55086",
"name": "Automated Telegram Chatbot with Advanced Session Management",
"nodes": 13,
"category": "Operations",
"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: edfb4d64-b7ea...
About the Author
N8N_Community_Pick
Curator
Hand-picked high quality workflows from the global community.
Statistics
Related Workflows
Discover more workflows you might like
Universal CSV to JSON API Converter
Effortlessly transform CSV data into structured JSON with this versatile n8n workflow. Integrate it into any application as a custom API endpoint, supporting various input methods including file uploads and raw text.
Instant WooCommerce Order Notifications via Telegram
When a new order is placed on your WooCommerce store, instantly receive detailed notifications directly to your Telegram chat. Stay on top of your e-commerce operations with real-time alerts, including order specifics and a direct link to view the order.
On-Demand Microsoft SQL Query Execution
This workflow allows you to manually trigger and execute any SQL query against your Microsoft SQL Server database. Perfect for ad-hoc data lookups, administrative tasks, or quick tests, giving you direct control over your database operations.