Empty the Window Buffer Memory attached to an AI Agent for a specific key

Hi!

Today I’ve set up a workflow in my self-hosted n8n environment that enables me to chat against GPT-4 using Telegram. For this I followed this tutorial: https://www.youtube.com/watch?v=ODdRXozldPw

Attached to the AI Agent Conversational Agent is a Window Buffer Memory that allows the bot to have a bit of context.

What I want to achieve is that I can send my Telegram bot a /clear message and then have the flow empty the Windows Buffer Memory that has a specific key. In this example, chat_history_<telegram-chat-id>.

The question is; how can I achieve this?

In N8N I cannot find an option to remove/empty the Window Buffer Memory for with a specific key.

Thank you!

Information about my n8n setup.

  • n8n version: 1.36.4
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Don’t know where to find this.
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Alpine

Hey @Jannick,

Welcome to the community :tada:

That is a very good question, It doens’t look like we have a way to clear the window buffer memory from inside the node. The best I can think of would be to use a different ID but I am not sure how long the window buffer memory actually lasts it could be that disabling and activating the workflow is enough as well, @oleg do you have any thoughts on this one?

1 Like

Another way to fully clear the memory(or just N last messages) would to use the Chat Memory Manager node and select Delete Messages Operation. If you connect a memory sub-node with the same session ID it would delete all(or some depending on the configuration) messages from it.