n8n Community Node

n8n Telegram AI Memory: Long-Term Memory for Telegram Bots

Telegram bots in n8n forget every user when the workflow execution ends. retainr adds long-term memory — your bot recalls every user across all past conversations. Install the community node in 30 seconds.

Why Telegram bots in n8n forget everything

The Telegram Trigger in n8n fires a separate workflow execution for each incoming message. When the execution ends, all state is discarded. The next message — even from the same user — starts fresh. retainr stores memories between executions so your bot builds a persistent understanding of each user.

Add Telegram memory to n8n in 3 steps

1

Install the retainr community node

Settings → Community Nodes → Install → n8n-nodes-retainr. Add your retainr API key as a credential. Create a Telegram bot via @BotFather if you have not already.

2

Search memory before each AI call

Add a retainr Search Memory node after the Telegram Trigger. Namespace: tg:{user_id} (the Telegram user ID). Query: the incoming message text. Inject results into your AI prompt.

3

Store memory after each AI response

Add a retainr Store Memory node after your AI step. Namespace: same tg:{user_id}. Content: user message + AI response. The bot now remembers every user permanently.

n8n Telegram memory — frequently asked questions

How do I create a Telegram bot to use with n8n?
Open Telegram and start a chat with @BotFather. Send /newbot and follow the prompts. BotFather gives you a token (format: 1234567890:AAFxyz...). Add this token as a Telegram credential in n8n. The Telegram Trigger node will start receiving messages from your bot.
Should I scope memory per user or per chat in group bots?
For personal assistants and support bots, scope by user ID: tg:{user_id}. For group bots where shared context matters, scope by chat ID: tg:group:{chat_id}. For bots in multiple groups where you want per-user memory within groups, use tg:{user_id}:{chat_id}.
Can I share Telegram memory with other channels like WhatsApp?
Yes. If the same user contacts you on both Telegram and WhatsApp, use a shared namespace like user:{email} and store memories from both channels under it. Both channels then draw from the same memory pool when searching.
How do I handle Telegram bot commands like /forget?
Add an IF node after the Telegram Trigger that checks if the message starts with /. Route commands to a separate branch. For /forget, call DELETE /v1/memories?namespace=tg:{user_id} via HTTP Request to clear the user memory. For /start, send a welcome message and skip the memory search.
Does the retainr community node work with n8n Cloud?
Yes, on n8n Cloud Starter and above. On n8n Cloud Free, use two HTTP Request nodes: GET /v1/memories/search?namespace=tg:{id}&q={message}&limit=5 before the AI step, and POST /v1/memories with namespace and content after.

Give your Telegram bot real memory

1,000 memory operations per month. Free forever. No credit card required.

Start free