Deploy a persistent, context-aware AI chatbot using this advanced n8n workflow. Integrate Telegram and Supabase memory with the OpenAI Assistant API. Find robust n8n templates for context-aware bots.
Download this n8n workflow template and start using it instantly.
Developers seeking robust n8n workflow examples for AI integration.
Businesses needing customer support chatbots with memory retention.
Users looking for advanced n8n templates utilizing Supabase for persistent data storage.
Automation specialists deploying production-ready AI services that require conversational context.
Many simple chatbots fail to maintain context across sessions. This robust n8n workflow solves that problem by implementing a durable memory layer. Every incoming Telegram message is managed through the initial n8n trigger. The subsequent n8n node sequence first checks Supabase to see if the user has an existing OpenAI thread ID. If they do, the conversation continues seamlessly, leveraging the history stored by the OpenAI Assistant. If they are new, this n8n workflow creates a new OpenAI thread and saves the necessary identifiers to the Supabase database. This architecture, built using powerful n8n templates, ensures that the OpenAI assistant maintains full conversational history, providing a superior, context-aware user experience directly within Telegram. This is a crucial n8n workflow for anyone building production-grade AI interfaces.
The automation begins with the Get New Message Telegram n8n trigger, which activates upon receiving a new message.
telegramusers) using the Telegram Chat ID to check for existing records.telegramid and the new openaithreadid.openaithreadid.openaithreadid is available for the next steps.To deploy this powerful n8n workflow, follow these setup steps:
telegramusers with the following columns to store the conversational memory:create table
public.telegramusers (
id uuid not null default genrandomuuid (),
datecreated timestamp with time zone not null default (now() at time zone 'utc'::text),
telegramid bigint null,
openaithreadid text null,
constraint telegramuserspkey primary key (id)
) tablespace pgdefault;assistantid (asst_b0QhuzySG6jofHFdzPZD7WEz) with your actual OpenAI Assistant ID. Get New Message (Telegram Trigger): This n8n trigger is the starting point of the n8n workflow, configured to listen for new 'message' updates from the linked Telegram bot.
Find User (Supabase node): Executes a getAll operation on the telegramusers table, filtering by the incoming user's telegramid to check for prior conversations.
If User exists (If node): A core n8n node for flow control. It checks if the id field from the Supabase output exists, determining if the user is new or returning.
OPENAI - Create thread (HTTP Request n8n node): Used only for new users. It sends a POST request to the OpenAI API (/v1/threads) to initialize a new persistent conversational thread.
Create User (Supabase node): Saves the new telegramid and the newly created openaithreadid into the database, establishing the user's conversational memory key for future runs of this n8n workflow.
Merge (Merge node): Combines the data streams from the 'New User' path and the 'Existing User' path, ensuring consistency before engaging the OpenAI Assistant.
OPENAI - Send message (HTTP Request n8n node): Sends the user's latest text message into the associated OpenAI thread, preparing it for processing.
OPENAI - Run assistant (HTTP Request n8n node): Executes the specific OpenAI Assistant (assistantid) on the thread, generating the AI response. Note the hardcoded assistant_id configuration within this n8n node.
OPENAI - Get messages (HTTP Request n8n node): Retrieves the final list of messages from the thread, extracting the assistant's response which is always the latest message in the list.
Send Message to User (Telegram node): The final n8n node, sending the resulting AI text back to the original Telegram chat ID.
Build an advanced, stateful Telegram bot using this n8n workflow template. Learn how to manage conversation state across multiple users and commands using n8n nodes and static data.

Find the best local restaurants instantly via Telegram. This n8n workflow uses a Telegram n8n trigger and SerpAPI to search Google Maps data, sort results by rating, and format a beautiful response.

Deploy an advanced Telegram bot using this n8n workflow template. Implement dynamic inline keyboards, multi-level navigation, and a 5-star feature rating system using custom n8n nodes and HTTP requests.

Use this powerful n8n workflow to create a smart Telegram bot that routes messages: images for GPT-4o-Mini/NVIDIA Vila analysis, or text for Stable Diffusion 3 image generation.

Use this powerful n8n workflow to create a Telegram bot that extracts TikTok and LinkedIn profile data using Dumpling AI, transcribes voice messages, and automatically stores results in Google Sheets. Get started with n8n templates for data mining.

I am a business analyst with a development background, dedicated to helping small businesses and entrepreneurs leverage cloud services for increased efficiency. My expertise lies in automating manual workflows, integrating data from multiple cloud service providers, creating insightful dashboards, and building custom CRM systems.







































