Build DeepSeek AI Agent with Telegram & Long-Term Memory in n8n

Discover how to create a personalized AI assistant using DeepSeek, Telegram, and Google Docs for long-term memory storage. This workflow solves user interaction continuity by managing AI memory effectively with n8n automation.
webhook
agent
googleDocs
+8
Workflow Identifier: 2270
NODES in Use: webhook, set, if, switch, merge, telegram, agent, googleDocs, googleDocsTool, lmChatOpenAi, memoryBufferWindow

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow listens for Telegram messages, checks if the sender is allowed, and sorts message types like text, audio, or images.
It then fetches past chat memories from Google Docs and combines them with the new message.
An AI chat model from DeepSeek makes replies based on the full context.
New useful info found is saved back to Google Docs.
Users get smart answers that remember history and fit their needs.

This stops repeated questions and saves hours spent looking back at old chats.
Errors are handled with polite Telegram messages.


Who Should Use This Workflow

This workflow fits anyone managing Telegram groups or channels who wants quick, smart replies with remembered context.
It helps people tired of manual chat memory checks and wanting better personalization.


Tools and Services Used

  • Telegram Bot API: Receives user messages.
  • Google Docs API: Stores and retrieves chat memories.
  • DeepSeek AI Agent: Processes messages and generates replies using long-term memory.
  • n8n Automation Platform: Orchestrates the workflow nodes.

How The Workflow Works: Input → Process → Output

Input

  • Telegram messages sent to the bot.
  • User details to check authorization.

Processing Steps

  • Webhook nodes catch the Telegram messages.
  • Validation nodes check if user ID and name match authorized users.
  • Message Router separates text, audio, or images for handling.
  • Google Docs node reads stored memories.
  • Merge node adds memory content to current message.
  • AI Agent node runs DeepSeek model to create replies using full context.
  • Google Docs node appends new memory text with timestamps.
  • Telegram node sends the AI reply back.
  • Error handling nodes send polite messages if issues happen.

Output

  • Telegram messages with smart, personalized replies.
  • Updated Google Docs with new conversation memories.

Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Import the Workflow

  1. Download the workflow JSON file from this page.
  2. Open the n8n editor and choose “Import from File”.
  3. Select the downloaded workflow file and load it.

Step 2: Add Credentials

  1. Provide the Telegram Bot API token in the Telegram nodes.
  2. Connect Google Docs account in the Google Docs nodes with OAuth2.
  3. Set API key for DeepSeek AI Agent node.

Step 3: Update IDs and Settings

  1. Check and edit authorized user IDs and names in the Validation node.
  2. Change Google Docs document ID to your memory document.

Step 4: Test the Workflow

  1. Send a message to your Telegram bot and confirm it replies properly.
  2. Make sure memories load, responses are relevant, and errors handled politely.

Step 5: Activate for Production

  1. Turn on the workflow toggle in n8n editor.
  2. Ensure the webhook URL remains reachable for Telegram.
  3. If you self host n8n, keep the server running for reliable operation. See self-host n8n.

Edge Cases and Error Handling

  • If unauthorized users message the bot, a polite refusal reply is sent.
  • Messages types other than text, audio, and images are routed to error messages.
  • If Google Docs fails to load memory, AI replies without past context.
  • General errors trigger friendly Telegram notifications without technical details.

Customization Ideas

  • Allow more users by adding their IDs to the Validation node.
  • Add support for videos or documents in the Message Router node.
  • Switch AI models in the AI Agent node to DeepSeek “deepseek-reasoner” for different AI behavior.
  • Store memories in Google Sheets or a database instead of Google Docs.

Summary and Results

✓ The workflow gives clear, remembered responses on Telegram.
✓ It cuts down hours spent on manual chat checks.
✓ Users get replies that fit their conversation history.
→ More engagement and less repeated questions happen.
→ The AI keeps learning for future chats.


Frequently Asked Questions

The workflow uses the Validation node and an If node to compare incoming user data with stored authorized user details.
If Google Docs memory fails to load, the AI still replies but without past conversation context.
Yes, the workflow allows switching the AI Agent node to other OpenAI-compatible models like DeepSeek’s “deepseek-reasoner”.
Add their exact IDs and names in the Validation node and adjust the If node conditions accordingly.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free