I’m using the AI Tools Agent in an n8n workflow to manage a chat. Here’s my setup:
I retrieve a question from a database using the get_question tool. This response includes a page_id for the question.
The question is displayed in the chat, and the user provides an answer.
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:
Can custom variables (like page_id) be stored in Window Buffer Memory when using the AI Tools Agent?
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!
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.
You 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 rather how to save it (once it is known somehow).
The Postgres 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.
Thank you very much for this idea, it seems like a very valid solution! In the meantime, I have switched to another project but will test the suggestion shortly. Many thanks!