
Telegram Bot integrated with Supabase storage and OpenAI assistant functionality
Integrates Supabase for long-term memory into a Telegram bot, combined with OpenAI to enable rich, contextually aware dialogues.
How it works
The workflow begins with a Telegram Trigger node that listens for incoming messages from users in a specified Telegram bot. When a user sends a message, this node captures the message content and user information, initiating the workflow. The captured data is then passed to a Function node, which processes the message to extract relevant information and prepare it for further actions.
Next, the workflow utilizes a Supabase node to store and retrieve long-term memory data. The Function node sends a request to Supabase to check if there is any existing context related to the user's previous interactions. If context exists, it is retrieved and combined with the new message to create a more informed response.
Following this, the workflow integrates with OpenAI through an OpenAI node. The combined message, which includes both the new user input and the retrieved context, is sent to OpenAI's API to generate a response. The OpenAI node processes the request and returns a response based on the input provided.
Once the response is generated, the workflow proceeds to another Function node that formats the response appropriately for Telegram. This formatted response is then sent back to the user via a Telegram node, completing the interaction.
Throughout this process, the workflow ensures that user interactions are stored in Supabase for future reference, allowing for a more personalized and contextually aware dialogue in subsequent interactions.
Key Features
1. Contextual Awareness:
The integration with Supabase allows the bot to remember previous interactions, providing users with a more personalized experience.
2. Rich Dialogues:
By leveraging OpenAI's capabilities, the bot can generate sophisticated responses that are contextually relevant, enhancing user engagement.
3. Real-Time Interaction:
The workflow is designed to handle real-time messages from users, ensuring prompt responses and maintaining an active conversation flow.
4. Data Storage:
Supabase serves as a long-term memory storage solution, enabling the bot to retain user data and context over time.
5. Modular Design:
The use of various nodes in n8n allows for easy modifications and scalability of the workflow, accommodating future enhancements or integrations.
Tools Integration
- Telegram Trigger Node:
Captures incoming messages from the Telegram bot.
- Function Node:
Processes and formats data as needed throughout the workflow.
- Supabase Node:
Interacts with Supabase for storing and retrieving user context and memory.
- OpenAI Node:
Sends user input and context to OpenAI's API to generate responses.
- Telegram Node:
Sends the generated response back to the user in the Telegram chat.
API Keys Required
1. OpenAI API Key:
Required for authenticating requests to the OpenAI API.
2. Supabase API Key:
Necessary for accessing and interacting with the Supabase database.
3. Telegram Bot Token:
Required to authenticate the Telegram bot and enable message handling.
No additional API keys or credentials are needed beyond those specified above for the workflow to function correctly.










