Save ids im Window Buffer Memory for next request

Hi community,

I’m using the AI Tools Agent in an n8n workflow to manage a chat. Here’s my setup:

  1. I retrieve a question from a database using the get_question tool. This response includes a page_id for the question.
  2. The question is displayed in the chat, and the user provides an answer.
  3. I then save the user’s answer back to the database using the save_answer tool, which requires the same page_id.

Problem:

I need to persist the page_id between interactions within the Window Buffer Memory so the save_answer tool can use it later. However, while Window Buffer Memory retains the chat history, it doesn’t seem to store additional metadata like page_id.

Questions:

  1. Can custom variables (like page_id) be stored in Window Buffer Memory when using the AI Tools Agent?
  2. If not, what would be the best way to persist such values across interactions with the AI Tools Agent?

Any help or recommendations on how to handle this would be greatly appreciated. Thanks! :blush:

1 Like

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Would need this too :raising_hand_man:

I can suggest the below solution as a quick mock-up to convey the idea. This however cannot be done with Buffer memory but rather some proper database like Postgres, for example.

Yoiu can extract and save the page_id together with the AI questions and the human answer in a dedicated table that could be queried by AI when needed. I did not provide any logic how to get page_id but rathef how to save it (once it is known somehow).

The Posgres DB could be also served as a tool for the AI agent.

Unfortunately I couldn’t paste the actual workflow as I was getting 403 error.