Get All Elements of a Redis List

Hi, I’m stuck with a problem in my n8n workflow.
I’m trying to retrieve all the messages stored in a Redis list (used by my chatbot), but with the Redis node i can only returns the last element of the list or SET.

What I need instead is to fetch all elements from that list, not just the most recent one.
I’ve read online that you can use the LRANGE command but it’s not available in the redis node.

How can I correctly retrieve the full list in n8n?
Am i doing something wrong?

(I’m not using the AI Agent Node, i’m using the Message a Model with a separate Redis memory)

Hi @AndraoCarloIntergea, welcome!

Because the built-in Redis node does not implement LRANGE, so, you can only get the last element of the list.

There are two ways to get the full list.

Set up a Redis community node, which supports list commands such as LRANGE/LLEN. Connect it to your already existing Redis connection. Call LRANGE your_list_key 0 -1 to get all items and pass them into Message a Model (or any next node).

In cases where the community nodes can’t be used, just attach a Code node that goes to Redis and runs something such as lrange(‘your:list:key’, 0, -1) and return the result as items for each list entry to be one n8n item for subsequent nodes.

When you use AI Agent–style flows, you can change the read step to LRANGE (either approach works) so that your bot can read all message history, not just the last message.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.