How do I capture the chat memory from my simple storage of my IA Agent node?

Hello. You guys are doing a great job here.

How do I capture the chat_history memory object (returned below) from my AI Agent simple chat node and output it on my AI Agent Output?
I need to implement a PostqgresSQL to do it?

I tried to capture it from global {{ $vars }}, but I didnt found it.

the object output from chat I want to output on my Agent answer:

[
  {
    "action": "saveContext",
    "chatHistory": [
      {
        "lc": 1,
        "type": "constructor",
        "id": [
          "langchain_core",
          "messages",
          "HumanMessage"
        ],
        "kwargs": {
          "content": "fgdfgdfgdfgdgf\nfgdgdfgfdg",
          "additional_kwargs": {},
          "response_metadata": {}
        }
      },
      {
        "lc": 1,
        "type": "constructor",
        "id": [
          "langchain_core",
          "messages",
          "AIMessage"
        ],
        "kwargs": {
          "content": "It looks like you're typing some random letters. How can I assist you today?",
          "tool_calls": [],
          "invalid_tool_calls": [],
          "additional_kwargs": {},
          "response_metadata": {}
        }
      }
    ]
  }
]

Information on your n8n setup

1 Like

Hi @Anderson_Campolina

No, if you use simple memory it’s okay.

You probably need to use the Chat Memory Manager node to get the history…

1 Like

I’m so sorry but I can’t parse Simple Memory as Json

But you got Luck, i can show you another solution is read from Postgres DB

Leave me a like if you find this Helpful, and feel free to send me message, we are here to growth up together. :sparkles:

1 Like

On Postgres DB put same table name as Postgres Memory Tool

in mine workflow is n8n_chat_histories

1 Like

Thats great @mohamed3nan ! God bless you for your help. Thank you

Success!

1 Like

Hey @NangAnhIUH . Thank alot, its a great tip! when I need to use persistent memory will remember that!! Thanks!

I think it will cause error because Memory Node have to have a Trigger function.
But you can see there I no arrow from Trigger to Memory Node

ps: Look like you edited the photo, I think that OK.

You’re welcome
here is a working sample as a guide


Hi @NangAnhIUH you can use the Chat Memory Manager node with postgres as well, just link it instead of the simple memory in the sample above…

1 Like

This one looks simpler because need only one DB, and works for me:

the result on my frontend:

1 Like