Stop picking the wrong memory node in n8n (full set up guide)

Rory Ridgers walks through every memory node in n8n: buffer memory, Zep, Redis via Upstash, Postgres via Supabase, and MongoDB Atlas. He shows credential setup and configuration for each, then recommends buffer for testing, Postgres for production storage, and Zep for long-term memory.
Chapters
What's up guys, in this video I'm going to be teaching you what all of the databases actually do in NAN, which ones you should be using, and how to set all of them up. Because I know when I first started using NAN, I saw all of these different memory options for your AI agents, and I had literally no clue what any of them meant, when to use each of them. Um, so I want to make this video to anyone who's new to NAN, or even if you've been using it for a while, and basically break down what all of the databases and the memory nodes actually do and when you should use each of them. Okay, so we're in NAN now, and these are all of the memory options you have in NAN for your AI agents. If we go to memory here, you can see these are all the memory. I've just laid them all out so you can see them properly. So what we're going to do is we're going to break down each of them, and I'm going to teach you how to set them up, when and why to use them. And we're just going to do it in order from easiest to hardest to set up. None of them are too hard to set up, but some of them are really, really simple to set up. So we're just going to do it from, like I said, in order from easiest to hardest to set up. So just to kick things off, At the beginning, the most simple one to set up is of course going to be this simple buffer memory that we probably all know, and we all use regularly. I know I do. So if we just connect this up, we can give this a quick little demo. If I just say, hey, you can see it stores it to the memory. If we have a look in here, you can see our original message there, hey, and then the reply from our AI agent, hello, how can I assist you today? You see, use that tool, really, really easy. There's no credentials you've got set up, nothing like that. All you do is you put in your session ID from the original input up here. And basically this works as a buffer memory. So all this does is it stores the last couple messages in your, uh, AI agent's memory. You can see here you have a context window length, and this is basically going to be how far back your AI agent can remember. So if you set it to 5, it can remember the last 5 messages. If you set it to 10, it'll be 10. 20 is 20. Um, this is primarily used just for testing, and I would recommend you only really use this for testing and demoing because that's when it works best, because it's really easy to set up, no credentials. And the reason you'd use it just for testing rather than actually in production is mainly because this all works right now. So right now I can just say to it, uh, what was my last message? So I can say, what was my last message? And it says, your last message was hey, which works good. But then all I have to do is just refresh this like this, and then if I say What was my last message? It thinks my last message was, what was my last message, which is obviously just the message here. So basically what I'm getting at is that it isn't persistent over different executions. So it works inside of one execution if you're talking to it in NAN and it's through one execution, you're just talking to it, then it's going to remember your chats. But if you just refresh it or you're calling upon this from somewhere else and you're doing multiple different executions it's not going to remember it basically. So yeah, that's the main downside of this is it's very good for testing, really quick and easy to set up. But actually in production, if you want your agents to have long-term persistent memory across different executions, this isn't the way to go with this. So that's that one out of the way. We probably all know how that one works already and probably all use that. Just quickly, I want to say the Motorhead and Xator, I think that's how you pronounce it. I can't find how you actually set these up. I can't find a single YouTube video on how to set these up. I can't find any docs really, apart from the ones NAN provide, on how to actually set these up. For both of these, the links that are given in the docs from NAN to go and get your API key or go and make an account, um, they're all broken links, so they don't work, or they link to things that are completely unrelated to this. So I've got a feeling maybe since NAN introduced these, the companies have changed slightly, or they're not around anymore. Not too sure what's going on with them. But yeah, these Xator and Motorhead, never even see anyone use them, don't know how they work. And yeah, the NAA docs are either outdated or the companies just don't exist anymore. So if you do know how to set these up, let me know in the comments. But, um, yeah, with all of these other memory options, it's really not a big issue if we don't know how to set these up. So next on the list is going to be ZEP, and this is a fairly new one. We're going to demo this out again quickly. We're just going to say, hey, how you doing? And you can see, uses Zep, saves that memory. If we come in here, hey, how are you doing? Hello, I'm great, thanks for asking. How can I assist you today? And I'm going to teach you how you can actually set up your Zep account because it's really, really simple. All you need is an API key. So if we go over to the credentials, hit create new credentials, like I said, all you need is an API key. So if we come over to Zep and I'm just going to hit sign up, I've already got an account but I'm going to make a new one. To this so you can see. Okay, so you're going to be met with— okay, so you're going to make— okay, so you're going to be met with this after you make an account. You can just hit I'm using for personal use, means you can skip entering a domain name and stuff like that if you don't have one. And here you'll see you've got an account ID, a project name, and a project description. We're just going to skip that. And right now you're in demo project. I'm just going to create a new project just because it's a little bit easier. We're going to call this NAN demo, hit create project. We can leave description blank, doesn't matter. Name your project key. Let's just say NAN demo again. Hit create. And you can see we get this project key here. So what we do is we copy that, come back over to NAN, paste that into there. And then you're gonna have to click on cloud because we're not locally hosting ZEP. We're using it through their servers. So if you click on cloud because we're using the cloud version of ZEP, and then you just hit save, you can see connection tested successfully. So absolutely perfect. We're now linked up to that Zap account. And if I say something again, I'm going to say, what's up? Save to Zap. And then if we come back over to Zap, if we go to users, and then this user ID, which would be me, you can see down here we have the sessions. If we hit on that, what's up? Hey, not much, just here ready to help. What's up with you? So in here, you can see all of your chat messages. And the other cool thing that you can do with Zap is if you hit view graph like this, right now because there's only one message in there. This graph looks pretty underwhelming. But when you start to have lots and lots of different messages, basically what this will do is it's going to map all of the messages that you've sent and it's kind of going to associate them based on their relevance to each other. So all the different messages, it's going to associate them in this graph. And then when you talk about particular topics, it can all link them together in this same graph. So if you're talking about one thing, the next day you're talking about another thing, and the third day you start talking a little bit about that first thing, it'll be able to remember that stuff you said about that first thing on the first day, for example, because in here it's going to associate all of that data and make relationships between the inputs that you put into it. But yeah, like I said, right now looks a little bit underwhelming because there's only one message in there. But that is how you connect Zep up. And when you would use Zep compared to one of these other, um, memory stores is if you want a really, really quick and easy way to set up a persistent memory storage And also ZEP is kind of used for more like long-term persistent memory. So if you want your AI agent to be able to remember stuff that you said a month ago, it might be the best option to use ZEP maybe over some of these other methods. The other methods will still work for that. They're a little bit harder to set up and ZEP just makes it much, much nicer to sort of visualize and actually use with these graphs that it generates. So yeah, if you're looking for an easy way to give your AI agent long-term memory rather than just good short-term memory, like I said, having it be able to remember stuff that you said like 2 months ago or something, then Zep is a really, really good option for that. Okay, so now we're going to move on to Redis. And again, we're just going to test this out. We're going to say, how you doing? How you doing? You can see uses Redis. Absolutely perfect. Same thing as always, stores our message there. How you doing? I'm doing great, thank you. How about you? How can I assist you today? Perfect. So I'm going to teach you how to set up a Redis account. If we go to Credentials, hit Create New Credential, you can see for this we need a password, a user, a host, a port, and a database number. So the way we're going to do that is by using a platform called Upstash. And with Redis, you can self-host Redis, but it's way easier to use a self-hosted version of Redis if you're self-hosting NAN. So for me, I'm using the community version, self-hosted version of NAN. but I'm hosting it on Hostinger, which is what a lot of you guys would be doing. You're hosting on Hostinger or Railway or Render, these hosting platforms, which means it's not actually self-hosted. So it's not actually running on your machine. If I had NAN running in Docker, and it was actually all running on my machine, then it would make more sense to use the self-hosted version of Redis. But I'm not. So for this, instead, we're going to use something called Upstash, which basically hosts Redis for you, same way that Hostinger hosts NAN for me. Upstash is just going to host Redis for me, and I can connect them up really, really easy. So we're going to make a new account, and you can see up here we have all these different database options, but we're going to be using Redis. So right now we don't have a Redis database set up, so we're just going to hit create database. For name, we can just say na10-demo, and then region, I'm going to try and find— yeah, London, obviously, because I'm based in the UK, makes more sense to just use London. And then we can just hit next, select a plan, This one's going to be free. Also, ZEP's free, by the way. I didn't mention that in the last thing, but yeah, ZEP's free to use. You can pay for it, but they have a free plan, the exact same as Upstash. So we're going to select the free plan, hit create, give this a second to create our database. You can see this is what we get. So we get our endpoint, we get a token, we get a port, and then we get the SSL enabled if it's enabled or not. For this case, it is enabled. So what we're going to do is we're going to grab our token We hit token, copy that, come back over. That's going to go into our password. And then user, we can leave this blank. It says leave blank for password-only auth. And if we come back over, you can see we only have a password or a token. We don't actually have a username. So if we go to host, the host is going to be this endpoint here. So if you copy this, paste it into here, check the port, uh, we come back over, port is 6379. Ours is already on 6379. By the way, with the endpoint here, you have to make sure to get rid of the HTTPS. Uh, Upstash make it kind of annoying because it doesn't just let you like highlight this and copy it, but that is what you actually need. If you just hit, uh, HTTPS and then paste that in like this, you'll just have to get rid of that HTTPS and you want to get just this. It should look, it should look something like this, like a random jumble of words and then a number and then.upstash.io. Make sure you also hit on SSL enabled because we come back over it says the SSL is enabled, so make sure to turn that on. And then now that's all you have to do. Now it's all connected up. Now, so if we just say again, hey, it's going to use the memory. And if we come back over to Upstash, go to data browser, and then in here you can see the messages that we just sent. So that was the one that we received, and then this is what we sent. And one of the best things about Redis is, um, how quick it is. So it is super quick. I don't know if you realize when I was just demoing this out here. But if I refresh this so you can see it again, if I just say, hey, how you doing? If you watch how quick it saves this to memory, it's, uh, pretty cool. So if I hit send, you can see instantly, it's like instantly saves it to memory, both messages. Um, yes, yeah, really, really quick. And that's probably one of the main reasons to use this Redis memory node over something else. Of course, you might just prefer to have the messages laid out like this. This is a nice way to see all of the different messages. But one of the best things about it is how blazingly fast it is compared to the other ones. So yeah, it's super, super quick, and I'd recommend doing this for something like voice agents, for example, if it really needs to quickly check memory or update stuff into your memory. But I mean, apart from that, Redis is good, but it's kind of just a preference. And also it has the hosting thing on its side. So if you want to self-host, then Redis is something you can self-host, which is really, really cool. So it can be private and secure. and it's also really, really quick. So that's kind of when I would use Redis over some of these other ones. Okay, so now we have the Postgres chat memory. So again, I'm going to demo this out, just say hey, and you can see it saves to the memory. Absolutely perfect, just like all the other ones. Hey, hello, how can I assist you today? And for this Postgres memory, we're going to be using Supabase because Supabase is kind of built on top of Postgres, so it has Postgres built in, which means you can use Supabase to easily connect up any kind of a Postgres database. Okay, so we're in Supabase now, and I've already got some organization organizations and projects. But what we're going to do is we're going to come up here and go to New Organization, and then we're just going to name this something like N8N Demo, like that. Perfect. Personal, and then the free plan. If we hit Create Organization, give this a second to create the organization, and then we're gonna have to create a project inside of this new organization. Okay, perfect. Now it's just taking us to the new project screen, so it's inside this organization. And the project name, we'll just call it the same kind of thing, so, uh na10-demo. Database password, make sure you remember this database password because you'll need it later on, and it's just annoying to like reset it and try and grab it again. So type it in and then remember it. I'm just going to say something like, uh, na10-demo123. So I've just typed one in, I'm going to remember it. And then the region, I'm just going to do London again because it makes the most sense for me. Hit create new project, and then this will take a second to create. Okay, so sometimes that takes a little bit longer, but you see right now I've got this little green dot up here, which means I'm all connected up. And then all we have to do is go to Connect up here, change the type to Postgres. And if we scroll down to Transaction Pooler, in here we get the URL. We just basically need to take the variables out of this and put this into NAN. But if we hit View Parameters, I think this is a new thing. I don't think they had used to have the View Parameters thing, which is nice. You can see all the different parameters that we need to add into NAN, which is really, really nice. So we just need the host, the database, the user, the password, max number of connections, and then the SSL, and then the port number. So if we come back over to Supabase, we got the host here. We copy this and then go up to host, just paste that in there. Database is just going to be Postgres, you can see here, and then the port is 6543. So if we copy that, come back down, paste that into there, and then user Go over to Supabase, use this, so we copy that, put that into there. Password, this is going to be the one that you set up a minute ago. So I've put in my password now, and then we have pretty much everything we need. So we can just hit save. You can see it says connection tested successfully, so perfect. Uh, if we come back over to the chat here and just say, hey, how you doing? Okay, perfect. So it saved that in the memory. If we come over to Supabase, if you're wondering where this actually saves, if we go to table editor and then hit refresh in here, I can see it popped up. Uh, there's one called nan_chat_history. So all of the content is just in here. So, hey, how are you doing? And then, hey, I'm doing great, thanks for asking, how about you? So perfect. Uh, so that's how you set up a Postgres memory using Supabase. And the scenarios where I would use this, primarily where I use this, is if I want a really easy RAG system. So if I'm putting all of the information into a database, and I want it so maybe the AI agent can learn over time. So it puts all of its interactions into a database, and then it can call upon that database and get specific information back. Um, that's kind of how I would use this majority of the time. Supabase is also usually, uh, the backend for like a lot of apps and a lot of web apps you might be building. So if you're ever building like a frontend or a web app around one of your N8N automations and you have Supabase as your backend, It makes it really, really nice to be able to store all of your AI agents' memories because your AI agent's probably going to be used in those web apps. It's just nice for it to automatically store into, uh, Supabase. And of course this stores into nan chat histories. You can change this if you want, so you can have it to store in other places in Supabase. You can see here the table name, nan chat histories. You can just change this to whatever you want. You can make a new table with a different layout and, um, store it in there. But yeah, that's kind of when I would use this. Is if I want AI Agent to store its memory into a place that I can basically retrieve that information from for other stuff, whether that's for web app, for a different agent, the same agent to learn, that kind of thing, is when I would use this Postgres memory and connect it up to Supabase. And now we have the last one, which is MongoDB. So I'm going to connect this up again, just test it so you know it's working. So just like normal, hey, hey, how can I help you today? Perfect. So to connect this up, you're just going to type in MongoDB into Google, click on the first one, and then just quickly make an account. Okay, so I just made a new account and I've got to accept the, uh, privacy policy stuff, hit submit, and then welcome to MongoDB Atlas, the modern database for every use case. Cool. So just ask us some random questions. You can just put whatever in here, it doesn't actually affect anything. And then once you're logged in, you can just select the free plan. Of course, you can select one of these paid plans if you want to, but the free plan works absolutely fine. And then you can give your cluster a name, which is just like your database. I'm just going to say n8n-demo, all one word. Provider AWS. And then for me, I'm pretty sure Ireland is the closest place I can get to England. Yeah, so Ireland. And then hit create deployment. Sorry, reCAPTCHA stuff. Cool. Verify. Perfect. Then you'll get this pop-up up here. Um, and for now we're just going to click off of that and we're just going to do this ourselves. So if you go to Network Access, first thing you need to do is add an IP address. So if you click Add IP Address and then Allow Access from Anywhere, it's the easiest way to do it, and then hit Confirm. You should see it's pending. It's this one that we want, they're just a bunch of zeros. Okay, so you can see now that one's active. Now we have to give database access. So if we go to Database Access, Add New Database User, And then here we're going to create a username and a password. And again, you have to remember this password, so make sure you do something that you're actually going to remember. She's going to say nan-demo for the username, and then password, it's just going to be the same as my Supabase one, 123. Perfect. And then you can skip past all of this, and then we want to go to built-in roles. So if you click add built-in role, select role, and then we're going to do read and write to any database. This just means it can get data from the database, and it can also add data to the database, which is how the memory feature is of course going to work. So now we just hit Add User. Okay, so perfect, we've got that new, uh, user in there that has database access. And now we need to actually make the database. So if we go to Clusters, and then you can see in here we have this cluster that we made when, uh, signing up. So we'll just give this a second to load. Okay, so it's gone green now. So if you just hit Connect, and then you'll get a pop-up like this, and you're going to go to Drivers and then you can leave all of this stuff, and then you want to scroll down to this URL here. And here you're just going to copy this over, take this over to naan.mongodb, create new credential, and then you're going to change the configuration type to connection string from values. And then we just have this connection string in here, and database password, this variable here, you're of course going to replace that with the password that you just made. Okay, then it's also going to ask for your database name, and to get that you come back over to Mongo Go to Browse Collections and then just hit Create Database. Enter a database name, which is going to say na10_demo. Collection name, we're just again going to say na10_demo. Additional preferences, you can just leave that as it is. Hit Create and it's going to create us a new database here. So you can see na10_demo. Perfect. If we copy this, come back over to Mongo, paste that in there. And connection tested successfully. So perfect. Okay, so now it's all connected up. We can make sure we're connected up to the right account. Yep. And then just say again like, hey. And that saves. And if we come back over to Mongo, you can see in here under nan_demo there's a new table that's called nan_chat_histories. And if we go to messages, you can see type human sent hey. And if we click on this object TypeAI said, hello, how can I assist you today? So in here it's just basically a JSON summary of the conversation. All your messages will go into here. And when I would recommend to use MongoDB, I mean, compared to like the Postgres and Redis, there's no real reason to use it over them apart from preference. And if you're already— you might have a client that's already built stuff on MongoDB and, um, you know, has their backend in it, or they have some kind of vector store in there or something. But apart from that, there's not really much benefit over using, uh, something like Redis or just the Postgres memory of Supabase. Um, yeah, it's kind of just personal preference if you want to use that one. There's no real benefit, I'd say, to, um, using that over one of the other ones. So yeah, that is it for the video, guys. I hope you learned something, and I hope this kind of enlightened you onto all of these databases or these memory nodes that are in NAM. Because like I said at the start of the video, when I first started using NAM, I had no idea what each of them did and what the differences were between each of them. So I hope this kind of clears it up for you and now you can kind of decide, um, which memory storage to actually use when you're building these AI agents. To be honest, I would recommend sticking with pretty much just the simple memory for testing and then either the Postgres memory or ZEP for actual production. ZEP, if you're looking for like really long-term stuff and like I said, you wanted to remember stuff from like 2 months ago or whatever, or just Postgres if you're looking for just a very, very good consistent storage that's always going to work. And it's really, really easy to retrieve that data from other places. Like you can connect other nodes up to the Supabase storage and you can connect other agents up to that same storage. You can have different tables, you can do lots of stuff with it. So yeah, I pretty much recommend sticking to just the Postgres with Supabase, the simple buffer memory for testing, and then ZEP if you, um, need it for your specific use case. I wouldn't really worry too much about the other ones, but of course If you want to use them, then go for it, and I hope this video helps you decide which of those you actually need. Yeah, that is it for the video, guys. If you've got any video suggestions you'd like to see, please do just drop in the comments or just shoot me over an email, and I'll try my best to get around to doing them.
More from Rory

Dynamic Workflows are crazy. This is how to actually use them (beginner's guide)










