Key parameter is empty error when using chat memory manager

Describe the problem/error/question

I am trying to load the previous session on a chat trigger node. the trigger node is embedded in our web app. I am also using a toolcall. it works just fine, I am able to call the tool call and display the previous messages. However. the data from google search is appended in the message when displayed in chat window. Makes the conversation messy. As solution to that, I hoped to insert the message manually using the chat memory manager node. However I am getting the issue: Key parameter is empty

Provide a key to use as session ID in the ‘Key’ parameter or use the ‘Connected Chat Trigger Node’ option to use the session ID from your Chat Trigger

Error Message:

Key parameter is empty

Provide a key to use as session ID in the ‘Key’ parameter or use the ‘Connected Chat Trigger Node’ option to use the session ID from your Chat Trigger

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

Hi @tamy.santos , thank you for the quick response, I really appreciate it.

As for this,

I’m really not sure how to do it can you point me to a resource or do you have an example I can follow?

using the sessionId is not really applicable on my usecase because the key that must be used is coming from my web app.

:slight_smile:

How to insert only clean messages into Chat Memory

This is handled through workflow logic, as described in docs.n8n.io.

Documented behavior:

  • Chat Memory Manager stores only what is sent to it
  • AI Agent tool outputs are normal node outputs
  • n8n does not auto-filter tool responses

(Docs sections: AI → Chat → Chat Memory and AI → AI Agent)

Supported solution:

Chat Trigger / Webhook
        ↓
   AI Agent (with tools)
        ↓
      IF / Switch
        ↓
Chat Memory Manager (Insert)

IF node example:

{{ $json.role === 'user' || $json.role === 'assistant' }}

or

{{ !$json.toolName }}

Only the true branch connects to Chat Memory Manager.


Using a key from your web app

This is fully supported.

  • Disable Connected Chat Trigger Node
  • Set Key manually:
{{ $json.chatKey }}

The key must exist on every execution and stay stable per conversation.
sessionId is optional and not required.

unfortunately, I am currently using this approach, and that is where the issue is coming from.

@Martin_De_Guzman

Thanks for sharing the screenshots — they make the root cause very clear.

The error happens because the Simple Memory node is receiving an empty or undefined Session ID (Key) at runtime. Your screenshots confirm this explicitly with the message:

“Key parameter is empty”

When this happens, n8n cannot create or retrieve chat memory, so the workflow fails immediately.

The expressions you tried (for example {{ $json.session.metadata.userId }} or {{ $json.chatKey }}) evaluate to undefined inside the Simple Memory node because that node does not automatically inherit the same JSON structure shown in the Chat Trigger UI output.


solution

Use the Connected Chat Trigger session ID and remove all manual expressions.

Steps

  1. Open Chat Memory Manager
  2. In Session ID:
  • Enable
    Use session ID from Connected Chat Trigger Node
  1. Clear the Session ID field completely (leave it empty)
  2. Save the workflow and re-run it

That’s it.

Hi @Martin_De_Guzman, welcome!

I think the error message is already very descriptive,

The issue is that the session ID is missing and since you’re using the embedded chat mode, you should double-check that the session key (or your metadata.userId) is correctly referenced and actually exists,

I’m not sure how your embedded chat is configured exactly, but according to the docs, these are the default settings:

So you should double-check and fix it so that it correctly points to your metadata.userId, and make sure to test it from the embedded chat interface UI, since this is where metadata.userId exists not from the n8n open chat test..