How to Create an RAG Chatbot AI Agent with n8n (No Code, Step-by-Step Tutorial)

Dr. Violet Howard builds a no-code RAG chatbot in n8n that answers questions about an iOS 18 PDF. Two workflows handle data ingestion into Pinecone and a GPT-4 chat agent that retrieves relevant document chunks to answer queries like "What is iOS 18 Genmoji?"
Chapters
Today I'm gonna be walking through step by step how to build this super simple question and answer AI agent. Like it says right there, no code. Basically, this agent is going to take information you give it, so information about a company, large database, whatever it might be, and then you're gonna be able to chat with it to get the answers you need quicker than if you were to manually have to search through a document or multiple documents. So I wanted to start off here with just a quick demo so you guys know what it's gonna look like and what it's gonna do before we actually get into the process of building this thing. So here is the example that I'm using today. It's a PDF from Apple, new features available with iOS 18 that just came out. So it's got a ton of information here, and if you wanted to read all that, be my guest. But I'm going to just build an agent that is going to tell us the key highlights, basically. So we could ask for highlights, or we could ask for a specific question. So in this case, let's say, um, what is iOS Smart Reply? It's going to search through that exact PDF that I just showed you guys, and it's going to give us a nice concise answer. So let's see what we get here. The iOS Smart Reply feature assists users in quickly responding to emails, blah, blah, blah, blah, blah, in the Mail app, Messages app. So it's a really quick summary. It's very concise, and it's better than having to search through here to find what we were looking for, which actually, yeah. Anyways, so I just wanted to show you guys that, but let's just get into the rest of this video. Let's see how we're going to build this thing. So the resources needed today: N8N, obviously that's where we're going to be building the workflows to make this agent. Pinecone, this is the vector database tool that I've been using. Um, if you don't really understand vector databases, that's okay. Basically it is just a way for agents to search through large amount of data much quicker than with a traditional relational database or any other store that you might be pulling information from. So Google Drive, this is just where the PDF that I'm using is going to be pulled from. And then OpenAI API, obviously just to access that large language model of OpenAI in order to have the agent think and pull the right information that we need and make it concise. And then as always with everything in life, just have a good attitude. Okay, so push data to Pinecone. That's going to be the first workflow that we're doing today. And then the second one is going to be the actual agent that's able to pull that data from Pinecone and give us an answer. So let's not waste any more time. Let's just get straight into this one here. Um, so yeah, the first step here would be grab some sort of document that you want, a PDF, um, Word, anything, but just push it into your Google Drive so that we can access it. And then the next step is gonna be you need to set up a Pinecone index. This'll take 2 seconds. You're gonna go to Pinecone. You're going to click here, create new index. The name can be whatever, just make sure you understand what it was. So anything, mine is called sample. Really all we need to configure here is just going to be the model. So we're going to do text embedding 3 small, super simple. That's all we need to do. You can play around with stuff as you sort of understand more about these databases. But for everything I do so far, I've just left it all default. So you're going to create that index. I'm not going to do that because I already have one. Like I said, mine is called sample. And then we've got our namespaces here. So if you watched that last video about creating a simple email AI agent, that's what this contacts namespace is from. But we're going to be pushing it into a new one. We'll call it iOS or whatever. But that is basically going to be right here. So that's everything we really need to know about Pinecone for now. And setting up the database. Now we're going to get into actually building this thing. So the first workflow I said that we were going to be doing is pushing the data into Pinecone. So we're just going to call this one push data. You're going to want to do trigger manually is the, the event that we're going to use to trigger this workflow. As you can see, there's all these different options. Basically, you need to select what is going to start this workflow. So in this case, if we click test workflow, that's what's going to start the process of the data moving through. So we've got our trigger. Next, we want to go into these node selection and grab Google Drive. Lots of actions here. All we need to do for this one is download the file. So when we test workflow, it's going to download this file and then we'll be able to see it in an N8N. Okay, so a lot of these stuff you're going to have to configure, um, or sorry, get set up with credentials if you haven't done it yet. So here's mine. Basically, for this Google Drive tool, you're going to click on Create New Credential. Um, you need to basically enter a client ID and a client secret in order to let, um, NNN know that it has access to get into your Drive, or vice versa. But if you click Open Docs, it's going to be very super simple. It's going to walk you through exactly what you need to do to get these credentials. You'll go here, you'll create a cloud account. Right here is mine. You'll create a project and then really easy, you're just going to go into enabled API and services. As you can see, I have these ones down here, but you're just going to click into here and you'll grab like Google Drive, search for that, and then you'll see right here Google Drive API. And all you have to do is enable it. So mine is already enabled, but you'll click a button right here that says enable. Then you're going to go back into, into here. You'll see credentials. You're going to create credential OAuth client ID, and then that is how you're going to get your client ID and your secret. I'm not going to open up this right now, but that's basically where you'll find it. So you'll copy and paste that into here, but then with this URL, you have to make sure that you set up your OAuth consent screen. So make sure you go in here and set it up. This is just the one that I have right now. You're going to add yourself as a test user, otherwise you're not going to have permission to go back and forth basically. Or you can just publish the, the app. So any of these things, but when you're creating your OAuth consent screen, that is where you'll be prompted. It'll say like, where is your redirect URL? So that's exactly what we're going to do and copy this right here. But if I didn't explain that well enough, like I said, just click on Open Docs and you'll see step by step. So go ahead and get that set up, and then you'll be prompted to sign in. You should be good to go. Once you get all that set up, you'll be able to access your Google Drive from NNN. So right now we're going to be grabbing the file type as a resource. We want to download it, and then here we have a list URL or ID. That's how it's going to access the file. It's really nice that it has a list because you can come in here and just search for exactly what— oh, Exactly what file you want. So ours is the iOS one and we want the PDF version. So then you can just test the step here. You'll be able to see exactly like if it's working, what the data looks like as it's coming in. So as you can see, it's coming in right here as binary, and then we want to just view it to make sure that it's the right PDF. So this is exactly what we were looking at earlier. So we're good to go. This step is working. Next, we need to click on this plus button right here. And we want to add the Pinecone vector store. This is going to allow us to push it into the vector store so that we can later access it. So again, you're going to have to set up your credential. I'm just going to ask for an API key. I already have mine set up, so I'm just going to click on that. But super simple again in Pinecone right here, API keys, and you're just going to copy this value. So you'll just copy that, paste it into NNN, and again, you'll be good to go. So operation here, we don't want to retrieve a document. That might be a later step, but right now we want to insert documents because we're getting it from Drive to Pinecone. Again, we're able to choose from a list, which is super nice, and that shows us that we have been configured properly. So sample index right here, my index that we're using over here is called sample, so that's good to go. And then you have the option here to add a namespace. I am going to add one just because it is going to keep our data more organized and it's easier to call it. It also will help the agent figure out exactly what it's looking for once you start to add, you know, tons of different data into it. But make sure that it's actually connected from this node to this node. And then next we need to set up a couple more things with this vector store tool. So the first one we want to set up this default data loader, keep that as default. And then I'm going to do recursive character text splitter. I'm going to leave the chunk size as 1,000 because the PDF is pretty big. The chunk size is basically how many characters it's going to pull because it's going to be pulling in batches from the database. And then the overlap is just how many characters overlap between chunks. And I'm just going to leave that as 0. So good to go there. And then we just need to add the embedding to Pinecone. So OpenAI, and then this is where you'll set up this credential. I'm pretty sure this is the last one. So again, API key, you'll go into OpenAI and you'll have your API keys right over here on the side, and then you're just going to grab that key, copy it. But yeah, the nice thing about it is once you have everything set up, they'll stay set up. So yeah, you want to make sure that this embedding is 3 small because that's how we set up our Pinecone store. And then, um, save that. It should be good to go. So if we're gonna hit test workflow, it's gonna start running. We can see that it's going to Google Drive, it's grabbing our PDF, then it pushed it into Pinecone successfully, I hope. But we can go check right here, namespace. It should come through here as iOS since that's what I named it. Let's just refresh that here. Oh no, I know what happened. Important step. So, um, right here, default data loader, we had this as JSON and we need to change this to binary because if you remember over here, this data came through as binary. If you go to JSON, there's nothing showing up. So make sure that this— make sure you're aware of how your data is coming through because in this case nothing was being pushed into pinecone because we didn't set up this loader as binary data. So we can leave all that, save. Let's test it again. This should work. Otherwise, now I'm lost. So, okay, we're good to go. Namespace, it should push in here. There we go, iOS. Perfect. Okay, so we're done with this workflow. We're going to go back out, we're going to make a new one, and then this is going to be our Q&A agent. Okay, the first step is again what triggers this workflow. This time we're going to go on chat message because we want to chat with this agent to get it to work with us. Leave that blank for now. Okay, now we're going to add in the actual entity of the agent. So click on this plus and we're going to go down to Advanced AI. Now you could do a question and answer chain because that's essentially what we want this agent to do, but it's good to get in the habit of setting everything up through an AI agent because then you're able to give it access to more tools, more scenarios, that sort of thing. So tools agent, all of this can be the same. And eventually we need to add the system message prompt. I'm going to leave that blank. Blank for now. We'll prompt it near the end, but hopefully I don't forget because sometimes I forget. But that's the agent. The chat model we're going to use is OpenAI. We've already got that configured. I'm going to use 4.0. The memory we're going to give it is Windows buffer memory. We can leave everything there. It's going to have 5 messages of context that it's going to keep as we keep chatting. It'll keep saving the previous 5 messages in order to look back and see like how the conversation was going, but we don't have to touch anything really. And that's just a very simple, easy way to give the agent some sort of memory to have a conversational flow. And then tools. So we're going to go and add Pinecone or Vector Store. This is going to be our iOS information description. You want to call this tool to access information to answer The user's questions. Just leave it as simple as that. Okay. Model. OpenAI Chat model. We pretty much always do this and we always do 4.0. You don't have to always do 4.0. I think 4.0 mini is a little cheaper. 3.5 works. They all work, but 4.0 just is kind of the most consistent I found. So yeah. Then in the vector store, we want to add the pinecone. This is again our credential. This time we want to retrieve documents, we're not inserting. So we did that earlier, now we're retrieving. And then once again, from list sample, and make sure if you pushed it earlier, if you pushed your data into a namespace over here, so ours is in iOS, make sure that you call that namespace out again. Otherwise, you're agent will be a little lost. Okay. So we got that set up. We do need to add the embedding right here again though. And this is going to be 3 small because we've done 3 small throughout every step so far. Okay. Save that. Now, okay. I was about to say we're going to test it, but we need to prompt it because I always forget that. So this is, like I said, you're able to take a screenshot of your workspace and put that in the chat. And that's super useful in order to actually prompt stuff. So I'm dragging in this one over here. You can see I did this earlier, but let's just go ahead and do that again. So there's that screenshot. I'm going to say prompt this agent to answer questions from, from the user. We want to include— geez, I cannot type today— include background context and instructions. Also tell the agent to answer concisely. Okay. So if you guys know stuff about agents, or at least a little bit about agents, if you know about prompting, Prompting is super, super important to ensuring your agent is working consistently and working exactly the way you want it to. A lot of times if it's erroring, it might be an issue just with the prompting rather than an actual thing you set up in the tool. So this is not the way I would advise to prompt your agents, um, if they're complicated and if it's like a big high-stakes project. But when you're playing around with making agents, this quick way works super well. So background and context. We've got our models, we've got our tools. It's got instructions. So let's throw this into here and we'll test it out and see if we like it or not. Okay. And we'll save that. So let's see what we want to ask it about. Let's ask about what Genmoji is since we're in the AI. Space right now. What is iOS 18 Genmoji? Genmoji is a feature introduced in iOS 18 that enables users to create unique Genmoji-style stickers directly from the keyboard. Dog on a surfboard. Cool. Let's see, what else can we ask it? Let's go. Can you Give a summary of coolest features in iOS 18. This may not work because I don't know how it's gonna— well, it probably will, but it needs to think about what does coolest mean. So let's see what it gives us here. Oh wow, the iOS 18 introduces several cutting-edge features designed to enhance user convenience, accessibility, and overall experience. Here's a summary of the coolest features. Eye tracking, pretty cool. Music haptics, also pretty cool. Wow. Yeah. Genmoji is number 7 on the cool list. I would say that's probably top 5, but that's really not what this video is about. Okay, so that's all that this agent's going to be doing for us today. I know that it was pretty simple, but hopefully you understand all the aspects of what goes into it, all the tools, what they each do. It's super important to get that basic understanding down because then you can go in here and you can start adding more tools and you can start calling more workflows. And then you can start pushing data off of the agent or pushing data from agent to a different agent. So just wanted to help give you guys a basic understanding. And if you enjoyed, you know, please let me know what else you want to see. I'm going to try to be tailoring a lot of content, super step-by-step, super easy to follow and to beginners. So if that sounds like something that you enjoy, then definitely stick around. But besides that, thanks guys.










