Telegram AI Chatbot with Long-Term Memory and Note Storage
detail.loadingPreview
Build a sophisticated Telegram chatbot powered by AI, capable of maintaining long-term memory and storing notes using Google Docs. This workflow leverages Langchain and n8n nodes to create an intelligent conversational agent.
🚀Ready to Deploy This Workflow?
About This Workflow
Overview
This n8n workflow enables you to create an advanced AI chatbot for Telegram that goes beyond simple conversational responses. It utilizes Langchain to process user messages and integrate with LLMs, offering a sophisticated approach to AI interaction.
The core functionality revolves around two key memory management strategies:
- Long-Term Memory: User-provided information that is deemed noteworthy and personal (preferences, habits, goals) is stored in Google Docs for future reference. This allows the AI to recall and use this information in subsequent conversations, personalizing the user experience.
- Note Storage: Specific instructions, reminders, or standalone pieces of information that the user wishes to store are also managed, potentially via Google Docs or another designated method. This separates actionable items from general personal memories.
The workflow starts with a When chat message received trigger on Telegram, processes the input through an AI Tools Agent (which uses an LLM like GPT-4o-mini or DeepSeek-V3), and then decides whether to save information as memory or as a note. It also incorporates a Window Buffer Memory for short-term context and can optionally send responses back to Telegram.
This workflow is ideal for developers looking to build personalized AI assistants, customer support bots with extensive knowledge bases, or any application requiring an AI to remember and act upon user-provided information over time.
Key Features
- Telegram Integration: Seamlessly receive and respond to messages via the Telegram platform.
- AI-Powered Agent: Leverages Langchain and LLMs (e.g., GPT-4o-mini, DeepSeek-V3) for intelligent message processing and response generation.
- Long-Term Memory Storage: Utilizes Google Docs to store and retrieve important user information, enabling personalized conversations.
- Note Management: Dedicated functionality to store specific notes and reminders, separate from general memories.
- Contextual Awareness: Maintains conversation history using Window Buffer Memory for more coherent interactions.
- Customizable System Messages: Define the AI's persona, rules, and available tools through a detailed system prompt.
How To Use
- Set up Telegram Trigger: Configure the
When chat message receivednode with your Telegram bot token and webhook settings. - Configure AI Agent: Set up the
AI Tools Agentnode. This involves:- Providing the user's chat input.
- Defining a detailed
systemMessagethat outlines the AI's role, rules, and the tools it can use (e.g., 'Save Memory', 'Save Note'). - Integrating an LLM like
gpt-4o-miniorDeepSeek-V3by configuring thelmChatOpenAior similar nodes with your API credentials.
- Configure Memory Nodes:
- Set up
Window Buffer Memoryto manage short-term conversational context. - Integrate
Google Docsnodes forRetrieve Long Term MemoriesandSave Long Term Memories. Ensure you provide the correct Google Doc URLs and have the Google Docs API credential set up.
- Set up
- Configure Note Storage: Utilize the
Google DocsToolnode (or a similar mechanism) to implement the 'Save Note' functionality as defined in your AI agent's system message. - Configure Telegram Response: Use the
Telegram Responsenode to send the AI's final output back to the user on Telegram. Ensure thechatIdis correctly set. - Map Data: Ensure that data flows correctly between nodes, especially the output from the AI agent and the memory/note storage tools. Use expressions like
={{ $json.output }}or={{ $fromAI('memory') }}as needed. - Test Thoroughly: Send various messages to your Telegram bot to test memory recall, note-taking, and response accuracy.
Apps Used
Workflow JSON
{
"id": "db1e97d0-d699-4650-bcc6-d88cef23637b",
"name": "Telegram AI Chatbot with Long-Term Memory and Note Storage",
"nodes": 0,
"category": "AI & Machine Learning",
"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: db1e97d0-d699...
About the Author
Free n8n Workflows Official
System Admin
The official repository for verified enterprise-grade workflows.
Statistics
Verification Info
Related Workflows
Discover more workflows you might like
Telegram AI Langchain Bot with DALL-E 3 Image Generation
An n8n workflow that acts as a Telegram bot, powered by Langchain, for AI chat interactions and image generation using DALL-E 3.
NeurochainAI Basic API Integration for Telegram
Integrates NeurochainAI's text and image generation APIs with a Telegram bot.
Chat with Local LLMs via Ollama
Integrate and chat with your local Large Language Models using Ollama and n8n.