Reading 'map'

Hi everyone!

I’m facing a problem with an AI agent flow for WhatsApp on n8n, using Redis along with Redis as the agent’s memory.

What the flow needs to do:

The expected behavior is:

The AI ​​agent responds normally while only the customer is chatting.

When a human (attendant) joins the conversation, the agent should completely stop responding.

After a period of inactivity from the human, the agent should automatically resume responding if the customer sends new messages.

How I implemented it:

I’m using Redis to identify:

Customer messages

Human/attendant messages

I used IFs and conditionals to interrupt or allow the AI ​​flow.

I followed the flow exactly as shown in this video:

:backhand_index_pointing_right: [video link]

The agent’s memory is Redis.

The problem:
The flow works correctly while only the customer is chatting with the bot.

The moment a human joins the conversation, the flow breaks.

The n8n agent is now returning the error:

Cannot read properties of undefined (reading ‘map’)

The error seems to be related to the AI ​​Memory/History node (Redis).

This only happens when the Redis nodes are active.

If I remove Redis, the agent works normally again.

Observations: The error occurs exactly when a human sends a message.

Apparently, at this point the Memory in Redis is in an invalid or unexpected state (e.g., empty history or different structure).

The interruption logic works, but the combined use of Redis + Redis Memory causes the flow to break.

Questions: Has anyone else experienced this problem using Redis + Redis Memory + AI Agent in n8n?

Is it necessary to clear/reset the memory in Redis when a human joins the conversation?

Is there a correct way to pause the agent without affecting the memory?

Could this error be related to human messages being written to Redis without valid content? Any help or guidance will be greatly appreciated :folded_hands:

1 Like

Hey @Zima_Blue Welcome to the n8n community!

This error is usually caused by the AI Agent trying to read invalid chat history from Redis. The agent tries to .map over previous messages, and if one of them does not have a proper content field the node fails with Cannot read properties of undefined (reading ‘map’).

Why it happens when a human joins
Human messages are likely being saved into Redis without the same structure the Redis Chat Memory node expects. When the agent loads memory and finds one of these malformed entries, it crashes.

What to try

  1. Make sure every entry you store in Redis that you plan to use as AI memory has a valid content (text) field before calling the Redis Memory node.

  2. Don’t save human messages to the same memory key the AI Agent uses. Keep a separate Redis key for handoff state so the memory node only reads valid chat history.

  3. Optionally clear or reset the memory key when the human joins so the agent does not attempt to load bad history.

If you fix how messages are written into Redis so the agent memory always has correctly structured items, the Redis memory + agent setup should stop crashing. Let me know if this works