Build Your Smart Telegram AI Assistant with Persistent Conversations
detail.loadingPreview
Deploy a sophisticated Telegram AI chatbot that remembers past conversations with n8n. This workflow seamlessly integrates Telegram with OpenAI Assistants, using Supabase to store and retrieve unique conversation threads for each user, ensuring a personalized and continuous chat experience.
About This Workflow
Elevate your Telegram interactions with this powerful n8n workflow, designed to create an intelligent AI assistant that maintains context across conversations. It smartly detects new users, provisions a dedicated OpenAI thread for them, and stores this mapping in a Supabase database. For returning users, it fetches their existing thread ID, allowing the OpenAI Assistant to pick up exactly where it left off. This ensures every interaction is personalized and coherent, transforming your Telegram bot into a truly smart conversational partner capable of understanding and responding within the broader context of your ongoing dialogue.
Key Features
- Persistent Conversations: Automatically manages and retrieves unique OpenAI conversation threads for each Telegram user, enabling long-term memory.
- Seamless User Onboarding: Automatically creates new OpenAI threads and registers new users in Supabase upon their first interaction.
- Intelligent AI Responses: Leverages OpenAI's Assistant API to generate context-aware, human-like responses to user queries.
- Robust Data Storage: Utilizes Supabase to reliably store user data and their corresponding OpenAI thread IDs.
- Real-time Telegram Integration: Listens for new messages on Telegram and sends AI-generated replies directly back to the user.
How To Use
- Set up Telegram Trigger: Configure the
Get New Messagenode with your Telegram bot API token. - Configure Supabase: Set up the
Find UserandCreate Usernodes with your Supabase project URL and API key, ensuring atelegram_userstable exists withtelegram_idandopenai_thread_idcolumns. - Integrate OpenAI Assistant:
- Provide your OpenAI API key in the
httpRequestnodes. - Ensure an OpenAI Assistant is created and its ID is replaced in the
OPENAI - Run assistantnode (e.g.,asst_b0QhuzySG6jofHFdzPZD7WEz). - The workflow uses the
assistants=v2beta header for OpenAI API calls.
- Provide your OpenAI API key in the
- Connect Nodes: Ensure all nodes are connected as shown in the workflow diagram, particularly the
If User existsnode branching toOPENAI - Create thread(for new users) and directly toMerge(for existing users). - Activate Workflow: Once configured, activate the n8n workflow to start your smart Telegram AI Assistant.
Apps Used
Workflow JSON
{
"id": "92b0a7ab-11ac-4027-8f99-53bccda8933f",
"name": "Build Your Smart Telegram AI Assistant with Persistent Conversations",
"nodes": 20,
"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: 92b0a7ab-11ac...
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
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.
Google Sheets to Icypeas: Automated Bulk Domain Scanning
This workflow streamlines the process of performing bulk domain scans by integrating your Google Sheets data directly with the Icypeas platform. Automate the submission of company names from your spreadsheet to Icypeas for comprehensive domain information, saving valuable time and effort.
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.