Transcript for:
N8N Masterclass: From Beginner to Builder

All right, today we've got a very exciting one. This is the N8N Masterclass, where ideally I'm taking you from a beginner in N8N all the way to an AI agent builder by the end of this, or even just someone who wants to implement AI automations into their daily life or into their work. So I was about to say grab a pen and a piece of paper, but more realistically, since you're here, grab some sort of AI note taker and let's dive into this one. This is a masterclass, so we're going to start at the bottom, start with the basics, and we'll continuously work our way up. But just want to start off here with what is N8N? So at this point I'm sure you guys have been hearing the term low-code no-code tools and N8N is a low-code no-code automation tool. So that just basically means that N8N allows users to automate processes, build workflows with minimal coding knowledge. And the key idea behind this is that low-code means it's very easy to develop things with a very user-friendly interface where people can just go in there and drag and drop different components, different nodes is what they're called in N8N. to create these flows without having to come in here and type a bunch of JavaScript or Python. This is so significant because it's going to allow anyone to be able to get NNN and get up and running with building automations, even if you don't have, you know, a background in computer science or programming. The barrier to entry to this is so low it's very very accessible for anyone to get in here and start playing around with stuff. But even though it's very simple, it also retains a lot of flexibility for more advanced users who do have coding background and they're able to come in here and take some of the basic principles and also come on top of that with custom code or different type of logic and integrations. And it's a very, very powerful tool. You can build tools directly in N8N as you see here. And that's a little bit different from other things like Maker Zapier because you can build, let's say, an agent that's able to call four or five tools and these tools you built within N8N itself, which is just super, super cool stuff. What about the importance of automating workflows? So we've got five points here I'll touch on real quick. Increasing efficiency and productivity. automation is going to eliminate repetitive tasks, it's going to reduce human error, and it's going to allow you and your team to focus on higher value work. It's also going to save time and money, of course. Automating workflows is going to reduce operational risk, free up time by completing tasks faster than manual. Scalability and adaptability, you can scale a lot more effortlessly. You can focus on your growth as a business, and these solutions, these automation solutions, can be customized or adjusted to meet your changing needs. You've also got improved data handling. Automation is going to integrate data from various sources. It's going to provide real-time insights for better decision making. And then the last benefit I wanted to hit on here was enhanced customer experience. You're going to be able to respond faster to your clients or automatically to your clients, personalized interactions through automated workflows, and all of this is just going to lead to better customer satisfaction and customer loyalty. Moving on here, we've got why should you learn NANN? So when I was building this slide, I had so many thoughts and I tried to put them all under three main bullets. And so this first one is, first one here is N8N empowers non-developers with automation. And I know we've touched on this a little bit with the whole low code, no code stuff, but it's just so powerful that anyone can pretty much come into N8N and start building things in 15, 20 minutes that's actually going to automate real work that they would do on a daily basis. So even if you're not a programmer, you can come in here, create workflows, it's going to save you time, make your life easier. For example, you could very easily get up a workflow that is going to automatically move data from one app to another, like manually copying contacts from one spreadsheet to another without having to do it every time. It's like having a digital assistant that can handle these repetitive tasks for you, and you don't really need the technical skills to set it up. So super cool stuff. The second one we've got access to over 300 built-in integrations which is insane. NADN comes with a ton of integrations, ton of connections to popular tools that you probably use every day like Gmail, Google Sheets, Slack, Twitter. We got Microsoft stuff too if you want to connect to Teams or Outlook. It's super cool what you can do. These integrations lets you connect quickly to these tools and you can connect tools to other tools without needing to like code in between that. For example, you could set up a workflow where every time you receive an email, it's gonna automatically add that information to some sort of spreadsheet. And then it's gonna send you a notification on Slack or Teams. And all of that will take place without you needing to be in there and doing it manually. Then this last one, you can connect to almost any tool. So kind of similar to the second point, but if there's something- that you want to connect to that there's not a built-in integration to, you can still pretty much connect to it. Whether that's through an API or a webhook, these ones are a little more technical but for the most part, you know, a quick YouTube video or using ChatGPT even, you'll be able to get them up and running and connect almost anything you want, a little bit of custom code, and really when you realize you can connect to almost anything, then you have almost endless possibilities of what you want to automate. Alright, we're gonna be moving into part one of this master class here which is just very very simple. Getting started with NNN. We're going to talk about how you set it up, the different ways you can set it up, and then we'll just get into the interface and start actually learning what it looks like and what everything does. The first thing I think that we should talk about when it comes to setting up your NNN is if you want to set it up self-hosted or if you want to cloud host. And I'm going to run through a few features of each of these two different options and then we'll talk about which one you should choose. So first with self-hosted, some of the things that it's going to offer you are control and flexibility. You're going to have full control over your environment. You can customize your... server integrate with any internal system you have the ability to adjust your configurations as needed we've got data ownership so all the data and workflows are gonna stay on your private server so this is ideal if you need to comply with privacy regulations or you want to keep sensitive data in-house cost self hosting can be more cost effective in the long run it depends on the server and maintenance costs but there's no ongoing subscription fee to any then like if you were to do cloud hosted but with the cost aspect you may need to account for infrastructure with like database management or server hosting and you also may need to have some sort of team that will help you maintain it but who knows. Fourth with self hosting is installation and maintenance. You are going to be responsible for setting up and managing and updating your instance. This also includes backups and scaling so this is going to require more technical knowledge. Then finally we've got customization so you can modify the source code, you can add custom features that might not be available in the cloud environment. So this is cool if you want complete freedom to modify the system as you want. And now moving on to the cloud environment Here's some features of cloud. It's gonna be easier to use because it's managed by N8n itself So there's no need to worry about setup updates scaling maintenance stuff like that. So good for beginners You've also got availability and reliability. So the N8n cloud is hosted on a scalable and reliable infrastructure It's gonna be maintained by N8n's team So they're always gonna keep stuff up to date with the latest features and bug fixes The security is a little different. It's going to be managed security, so SSL certificates or secure API handling, and that's going to be done by the NNN team. And then also, this is going to be more suitable for users who don't want to handle server security. Now, when it comes to cost of NNN, it's really not that bad either way. The cloud version comes with a subscription model that's going to be based on usage tiers, how many products you want, how many seats you want on your NNN environment. And so you'll be basically paying based on that. So in the long run, it could be more. more expensive if you have a ton of users and a ton of projects going on. But if that's the case, then hopefully you're either saving a ton of money or you're making a ton of money. So balance is out. Then finally, we have data handling different than self-hosted data is going to be stored and processed in the cloud. So like I said, if you're a business dealing with highly sensitive data, this may be a limitation due to the server dependencies. Okay. So at this point, you may already have an idea of which one you're going to choose, but if you don't real quick, you should go with self-hosted. If you need full control over your data and your infrastructure, if you want to integrate NNN deeply with other on-premise systems and if you're technically comfortable handling server maintenance and management or you have a dedicated team that will do that for you. And then you're gonna want to go with cloud if you prefer simplicity and you don't want to handle infrastructure or server maintenance, you want a quick setup and reliable hosting, it's gonna be managed by the NNN team and you're okay with paying for a subscription for a managed service and you don't mind being handled by a third-party provider. Okay so before we actually hop into NNN and we look around at the the interface, probably important to understand the difference between workflows, nodes, and executions. So I'm going to break this down as simple as I can. Pretend you're in a restaurant, we've got workflows, which are going to be the recipes. Nodes are going to be the ingredients, the steps within each recipe. And then executions are going to be every time someone sits down and orders that specific recipe or workflow. So the workflow, think of it as like a set of instructions that you're going to be giving to N8N in order to automate a task. So for this example, we'll say that... the workflow is a chocolate cake. Then we'll move down to nodes. Nodes are like the building blocks of the workflow. Each node is going to represent a single step, a single action within a workflow. So one node might send an email, one might update a spreadsheet, one might pull data, and then you can kind of link those together in order to make the chocolate cake. So, you know, eggs, flour, baking soda, we're going to put those together. Then we have the execution, which is simply just running your workflow in NNN. This can happen by different triggers whether you want to do that manually or whether you want the automation to take place every time you update a row and a spreadsheet but in the example like I said just picture someone coming to the restaurant and ordering a piece of chocolate cake and then you kind of start that process of making the cake and delivering the cake all right now that we've covered the three main building blocks that go into pretty much every automation let's actually get into any then look around a little bit at the user interface see what I'm talking about when I say drag-and-drop we'll talk about accessing community resources community templates, stuff like that. And. it'll really start to make more sense. All right, so we're in NNN. As you can see, what we're looking at right now is we're just on my homepage. So it's going to show me a ton of the different workflows that I've been working on. We've got our projects right here. So I only have the one right now. It's called Nate Testing. So in here, it's pretty much just everything I have. But if you had a specific project for a specific client or a specific project for an actual specific project at work, you could add them here so you can keep everything organized. Honestly, my stuff is not too organized, but here's what it looks like. We've got stuff on the left-hand side. We can see we have an admin panel. We have templates. We have variables. We can see executions of each workflow. We've got some help. And then you have your profile down here as well as, you know, I'm cloud-hosted, so I can see that there's some updates here with some bug fixes that I'm going to be able to just go in and install real quick. Let's just add a new workflow right here and see what the interface sort of looks like. So this is the canvas that I was talking about where I said it was a very user-friendly drag-and-drop interface. the first thing you're going to see is that you have an add first step button. So we'll get into different types of nodes after this, and we'll talk about triggers and all that. But the first step is always going to be a trigger. So you'll click on that and it will list up some triggers. Trigger manually just means that you'll be hitting a test workflow button down here in order to run the workflow, execute the workflow every single time. You can schedule it. You can do on chat message. You can call it by another workflow. So that's where all of a sudden super powerful. We'll just add a manual one so you guys can see what it looks like. This is where you would hit test workflow in order to run it. And, you know, obviously nothing's coming through, but it didn't fail. So that's good. Then from here, you would want to add different nodes to connect to. So you could do that from either clicking on this plus button where it says click to add node or drag to connect. Or up in the top right, you can click up here and it will pull up this panel for you to search through nodes, you know, by category, or you can just search for them if you want. Another cool thing with the triggers is there's not just those triggers. There's different triggers for each app. So. Let's say that you wanted to run a workflow every time you got an email. You could click on Gmail, down at the bottom you'd see different triggers and this one says on message received. So this would execute the workflow every time you get an email and you can tell the trigger if it has this little lightning bolt. So that's a trigger node. But anyways let's just say that we wanted to put some fake data in here so I would just come in here and I could either type for the node that I want or I know I'm looking for an edit fields node so I could come to data transformation and I would see edit fields right here. This is where I could configure stuff so let me just quickly pretend we're gonna make a field called name and we'll just put in my name and what's really cool about NNN is that you can test each step individually as you're going through and automating something so rather than having to run the whole workflow you could just test step right here we'll see that what's coming out of this node is Nate in the field called name so we have that information running through but it's nice to know because you'll always see on the left of this configuration panel you'll see data that's coming in and then you'll see data that's coming out. So it makes it really easy to troubleshoot and test each step individually which is really cool. But you have to make sure that your nodes are connected because let's say you know I didn't drag this one right here and connect it to the edit fields. If I was to run this nothing would come through the edit fields there's no output as you can see. It says wire me up this node can only receive input data if you connect it to another node. And yeah so that's how that's going to work. I say this is probably all we'll do for now in here. We'll get into some community templates and just show you how that all works, but as far as just basic setting up a workflow and seeing what the interface looks like, how easy it is to just drag and drop stuff, that's what we've got. So back in the home page we've got workflows, you can also look at your credentials, so this is just different things that you've connected to. Like I said there's so many integrations so it can easily access my Google Drive, my Telegram, my Google Sheets, all that kind of stuff. So that's where you can sort of see and manage your credentials. And then down here the only thing I'll touch on real quick will be the templates. You can click into templates and it will pull up NNN's website where there's sort of like this community where people can upload cool things they're building. Or you can search for specific use cases, specific tools that you want to use. So it's a really great place to get in here and learn. But as you can see, we have learn by doing. So you can download these templates, which is really cool. Sometimes it's nice to watch a tutorial on YouTube, but being able to really learn, you have to just get in there and you have to let things fail in order to figure out why they're failing. So right here we have, you know... AI agent chat we can download from N8N. We can click here, we can look at it, and we can see what's going on. We could click this button here to download it and start playing around with it in our own N8N. We have this one where you can click in here and a lot of times people will annotate like what's going on so you can see how to set it up. You can see which you know what's taking place in each scenario so that's super super useful. And then I'll just show you real quick, let's say you wanted to use this one, we could just import the template to my cloud environment. And as that loads up, it's pretty much going to put it right into my workspace. So I've got this information here. Now test this data. I can look at what's going through each step. We can see right here we've got, you know, this information is coming through and then it comes out as, you know, flour, eggs, milk, which is interesting because I just did a, you know. a little example about cake so it seems like it's meant to be but either way you can start to see actual data moving through which is how you're really going to be able to wrap your head around what's going on another great thing about nnn is there's so much documentation it's super easy to get help so if you come down here you can see help we've got a lot of stuff here they even have a course that you can go through but documentation if you click on here you can see pretty much anything you need to find like there's quick starts there is concepts about flow logic concepts about data so like i said Super easy to learn about all this kind of stuff. You can look at what each node is doing specifically. So let's say you were confused about the loop node. You could come in here, read about looping. You could see how the node works. You could maybe see some examples of how people are using it. And yeah, like at the bottom, it's probably going to throw you in some templates of actual workflows with loops, but super easy to get help within NNN. Part two of the masterclass, we're going to be talking about some core concepts. So we just saw what the interface looks like. we saw a few nodes but now we actually need to dive into different types of nodes and what they do and then we're gonna end this section of the master class with an actual example where we'll get into N8n I'll do a live build of a really quick automation and then we'll talk about the different type of nodes and how data is moving through so it should be pretty cool to see. So before we hop in N8n and we build out our first automation we really need to understand these sort of four main types of nodes. So we've got trigger, action, data transformation, and logic. So So let's just break these down real quick. Starting off here with trigger nodes, because a trigger node is pretty much going to be what starts every workflow. We just saw these in NNN. They were the ones with the little lightning bolt next to them. Anyways, different types of trigger nodes. We can look at something like a webhook trigger, an email trigger, like I showed you. Anything that's going to start the workflow, whether that's going to be manual or on a chat or on an event, or I have called by another workflow, bolded here, because it's sort of the power of NNN. You can build a workflow. workflow that will be called by another workflow. And then you can build an agent that can call that workflow as well as maybe this agent can call like 10 other workflows. So super powerful stuff here. Next, we've got action nodes. These are the actual doers. They're going to perform a very specific task within your workflow. So it's like an assembly line. This guy is going to, you know, put the present in the box. This guy's going to wrap the present. This guy's going to put the bow on the present, all that sort of stuff. But they can do different things like, you know, send email, create a record, make an API. request, they can get a text message, they can set your calendar, almost anything that you could do on your computer, on your phone manually, you could have some sort of action node to do this thing. Third, we have data transformation nodes. These are going to help you change or process your data in some way so that it flows through the whole process and you get the end result as you want it. So these type of nodes can do things like set, that can add fields, change values within fields, it can do some sort of processing your data. We've got something like an aggregate where you can combine. a ton of data into a single output or something like a merge where you can combine data from two different sources and put them into one. The last type I'm going to touch on real quick are logic nodes. These are sort of the decision makers. They're going to help NNN figure out what path to take, how to handle a different situation. So we've got something like an if node. It's going to check if a specific condition is true or false. Is this value higher than 10? It's going to go this way. Otherwise, it's going to go this way. We've got a switch node, which is going to allow you to put multiple conditions in there. And it's going to to be checked and direct the workflow to a specific action based on that conditional check and then something like a wait node which is going to pause the workflow let's say you wanted to pause the workflow until you come back and respond like yes that's good to go then it will continue to move on through the rest of the process or you could have it like wait for 20 seconds whatever you wanted to do all right now it's time to finally hop back and end it in hopefully these slides weren't too boring but we're going to be building an example workflow here it's going to be really simple it's just going to automatically process customer orders and then it's going to summarize it and send us a report automatically every time we get a new order. So super cool stuff. Let's hop into how we're going to build this thing. All right, we are in a Google Sheet. This is going to be the customer order data that we'll be using for this example. So I had ChatGBT make up some data for us. We've got stuff like order ID, customer name, product, quantity, price, order date, and the status of that order. So every time a new row is put into this Google Sheet, it's going to run through N8N automatically. It's going to get summarized by some sort of large language model. like ChatGPT or Claude. And then that summarization is going to be emailed off back to us or back to our team automatically. So this will be a nice simple example, but it's going to feature different types of nodes and we'll be able to see the data move through real time. So it'll give us a really good base. We are now in N8n. This is the canvas we'll be working on. And this is the workflow that we'll be building here and in a master class customer orders so we know the first step that we always need to do is add some sort of trigger we'll click in here and we can see different triggers like manual on app event called by another workflow we talked about this but in this case we want to make this one automatic so we're gonna be doing a Google sheets trigger Google sheets has three triggers it's got on row added on row updated or on row added or updated so we'll do this one because that way If you have to go in there and change some sort of information about an order, like let's say one goes from, you know, the status is pending to shipped or something, we'll also get an email about that. So we have to set up the Google Sheets account. This is where you're going to have to set up a credential and I'll walk you guys through how to do this. So you're going to click create new credential and you'll see the screen pop up where we need to grab a client ID and a client secret. This looks a little confusing and I was definitely confused when I first saw the screen. So what we need to do is right here. I talked about how N8n is really good at having documentation that explains stuff. So we'll click on open docs right here. We will see that the prerequisite we need is a Google Cloud account. So we'll go in here and make a Google Cloud account. And then we can see that it's going to walk you through step by step. So if my explanation isn't good enough, you can come in here and grab the docs. But hopefully I'll show you real quick how to do this. So we'll come into Google Cloud. This is what it's going to look like. You'll have to sign and make an account. Then you want to go to your console. Once you're in your console, you'll see this screen. You might not know what to look at, but all we want to do is we're going to create a project. So mine right here is just called My First Project. Make sure you're in your project, and then you want to come in this left-hand side to APIs and Services. We're going to click on Enabled APIs and Services. And at this point, you just need to search for a Google Sheets. So we're going to type in Google. Okay, we need to do Sheets, be more specific. So Google Sheets, we can see Google Sheets API. We'll click in here. And then all you need to do is just enable this API. So we've got ours enabled already. There'll be a button right here. It's just as simple as that. So get that enabled. And then you're going to come in here, go back to your APIs and services, and then we want to go to credentials. Once we're in credentials, this is where you can set up your client IDs to get an ID and a secret. So I'll just walk you guys through how we're going to do this one. You're going to click create credentials up here. You'll go to OAuth client ID. Once that loads up, you want to choose the application type. This is going to be a web app. You can name it whatever you want. We'll call this one demo for the sake of this video. And then all you need to do here is add a redirect URI. So this is where you see in N8n, you've got this redirect URL. We're just going to click here to copy, go back into Google Cloud, and we're going to add this right in here. Just paste it in and then you'll hit create. You'll get the screen pop up. with your client ID and your client secret. So it's as simple as copying the ID, pasting that into the ID field in NNN, going back to cloud, grabbing your secret, and pasting it into the secret. Then you want to sign in with Google. So this screen is going to pop up. It's just going to be a simple prompt to sign in with Google like you would normally have. So I'll drag this in right here. And now it says that Google hasn't verified this app. So this is where you need to set up your OAuth consent screen. So back in here, you've got your ID and your secret. Now you need to go back in your credentials right here, OAuth consent screen. All you need to do here is either make sure that your app is published. So you need to make sure the app is published so that it has access to actually go through and grab information out of your Google Sheets, your drive, your email, whatever it is. Or you can add yourself as a test user. So I've got my emails down here as test users. This also will allow these emails to sign in and go through. But if you're getting blocked for some reason. It's probably because you didn't set this up right, so just make sure it's published or that you're in there as a test user. So back in NNN, we've got the sign-in field. We'll hit continue. Just make sure you give this email access to everything. Give NNN access, and then you'll hit continue, and then pretty much you'll be good to go. You'll see we got this account created right here. It's green. We're good. So we will come out, and now we're connected. So now that we're connected, we can configure the rest of this node. It's going to be running every minute and that's when it's going to be checking for if a row was added or updated. Now we can select the document that we want. So it's really nice. You can choose from a list. You can enter the URL or the ID of your document, but list is so much easier. It's just going to access your Google Drive and see what sheets you've got. So we're going to do customer orders. There's only one sheet in this document, so we'll grab that sheet. And it's going to trigger on row added or updated. So if we can fetch a test event here we'll see some of our sample data coming through. So as you can see we've got five items, we've got the columns up here and then we have all of these orders that we just had right here in Google Sheets. So we've got John, Jane, Mike, Emily, Robert Brown and in here you can see we've got John, Jane, Mike, Emily and Robert Brown. So this node is working, we've got our information coming through into NNN. Now we want to add an OpenAI node. So we'll just click on this plus right here or click on the plus up in this top right corner and you can search for a new node. We're gonna grab OpenAI. You could use a different large language model if you wanted to but I'm gonna be using OpenAI. You can see we've got 15 different actions within this node. What we want to do here is message a model. Basically just means that we're gonna be talking to chat GPT. Just call this node summarize and now we need to hook up this node with our credentials. So at this point if you don't have an open AI account you need to do so and then once you do that you can come in here and click create new credential. This time all we need is a single API key. So Once you have your OpenAI account, you'll come into it. On the left-hand side, you'll see all this stuff, but we just want to go to API keys. Up in the top right, you can click create new key, give it a name, and then it will give you a value to copy. So pretty simple, same thing. You just want to come in here and copy that information in, or sorry, paste that information in, hit save, and it will go green once you're all good. So that is all you got to do. But pretty much every time that you need to configure a node, you're going to have to grab some sort of key. So just keep that in mind. So as you can see the resource is text, the operation is messaging a model, and now we need to choose what model we want to message. So I'm going to come in here and grab GPT-4-0 right there. And now we need to configure the rest of this node. So this is the message that we're sending to GPT-4.0 You have a couple options here You can have it be a user message and assistant message or a system message You can see the difference is right here usually when you're gonna be prompting the node how to act we're gonna choose system so in here I'm gonna type a quick prompt and I'll be right back to explain it all right here is the system prompt that I came up with just type this out really quick so I said you are in charge of client orders your job is to take incoming information regarding new orders and give a nice summary that will be emailed to the team the email should be signed off from customer success team and then we want to give it the information from the previous Google sheets trigger that's coming in here on the left we need to actually give it the information to summarize so So it's going to be getting order ID, customer name, product, quantity, price, order date, and status. And so all we need to do is come in here and drag and drop each of the fields into the prompt, and it will be a variable. So it will change for each one. So I'll just show you guys. Order ID, we drag this in. And I don't know why it does that. We want to make sure that it's right here with order ID. So first of all, first thing to note, this is a green variable with the two curly brackets around it. That just means that it's a JavaScript variable. So this doesn't involve any coding. It's as simple as dragging and dropping. But this just means that it's going to change based on whatever value is in this field. So as you can see in the result tab right here, we've got the JSON.orderIDs coming through as 101 because that's the first order. And you can see similar things when we drag in. in customer name. We'll get in the results. We got John Doe. We'll drag in everything else, and then I'll show you guys. So we're just going to drag in product quantity, price, order date, and status. So that's assigned wherever it needs to be. And then as you can see in the result, we've got, here's the information on client orders. We've got the correct order ID, name. price, quantity, all this kind of stuff. We have the actual information coming through as you can see. And then the last thing that we wanted to say was please output the following parameters. So based on this information that it's getting right here that it's going to summarize, it's going to output an email subject for us. and an email body for us. So we can go ahead here and hit test step. And I'll show you one thing about how we want to output this content as JSON. So I didn't check this yet. And so that means that this is going to execute and it's going to all come out in one. sort of like large string. So as you can see, we've got for the first order, email subject, new order confirmation, order ID 101. Here, actually, let me make this a little bigger. So it says, hello team, we have a new order that has been successfully processed and shipped, below are the details. So it's gonna summarize that for us, and then it signs off, thank you for your attention, best regards, customer success team. But this is coming through as one big chunk of text called content. So what we wanna do is output the content as JSON, we'll test the step again, and now it's going to come. through as two separate fields one will be the email subject and then one will be the email body and this is just important so that we can drag and drop the next fields later when we want to configure the actual gmail node so as you can see right here we've got the subject and then we've got the body and we've got the subject and the body we'll read one more real quick so order 103 you've got the subject and then the body says we have a new order summary order id 103 mike johnson you got headphones at 200 just one pair please let us know if you need further details so as you can see these are all coming through as an email subject in the email body and this will be important when we set up this next node here which is going to be a Gmail node this time we're going to add the node by clicking the plus up here it's the same thing as this plus but just wanted to show you guys different ways We're going to grab a Gmail node and there's 25 actions within Gmail. As you can see there's a lot of stuff you can do which is just awesome but here we're going to be sending a message so we'll click on send a message. Real quick let's just make sure we wire this one up otherwise it's not going to work and then we'll come back to the node and we can configure it. So first thing got to do is obviously set up your new credential. You'll come in here, just got to grab that same client ID and secret from the previous one. So we'll come back into our enabled APIs and services. I want to go to credentials and then you can click into that client ID that we just made. And then all you got to do once again is copy and paste that information in. So let me just do this real quick. We'll grab the secret, paste that in there. And then once again, just sign in with Gmail. It's again going to make you verify the app. We'll go through, give access to everything, and then we go green because we're good to go. So we've got that set up now. All we need to do is configure the rest of this node. So as you can see, the resource is a message. The operation is that we're sending a message. Now you can see why it's so important that we set up the email subject and the email body as two separate fields because we output it as JSON. So all we got to do is drag in the subject right here where it says subject. So the subject of this Gmail being sent off will be order confirmation. 101 for John Doe. And then same thing with body. You're going to grab that and put that in the message field where this is the actual message that's going to be sent in the email. We want to make the email type as text. That's just how I usually like to do it. And then for the sake of this example, we will just put in my email so we can see this email coming through. And you could make this variable. You could make this change based on the order if you wanted to. But right now, let's keep it simple. We're just going to send it to nateherk88 at gmail.com every time. And finally, you've got some options here. could attach things, you could cc people, you could change the sender name variably, whatever you want to do here. I usually just will come in here and click append N8N attribution and make sure I turn that off. Otherwise at the bottom of the email it'll just say this email was generated by N8N or sent by N8N. So this looks good to go. We can test this step and it will it should be firing off five emails because we have five emails in the sample data. So you can see these came through it's just giving us a message ID and a thread ID which which right now we don't need, but you can see that all of these got sent. So let's hop over to the email. I will refresh, and we should see five new emails in my inbox. So yeah, we've got order 101, 102, 103, 104, and 105. So this is information from all the orders. As you can see, this one says, new order from Robert Brown. He got a tablet, three of them actually, 600 per unit. So the total price was 1,800. It was on August 28th, and the status is still pending. So thank you, best regards. customer success team. So all that came through exactly how we wanted it. So that's good to see. Now we're back in N8N and we're pretty much done with this workflow. We've got three nodes in here and we can save it. And now what we want to do is check this box to inactive or sorry, to active. So all this means is that now that the workflow is activated, it will regularly check Google Sheets for events and then it will trigger executions each time that a row is added. added or updated and they won't show immediately in the editor so that means like We won't be seeing like these turn green every time it actually is going through, but they will be going through. So let's hop into the Google Sheets real quick, add a new row, and then let's wait for the email. Okay, so I've got this information I'm about to paste into here. We've got order 106 for Phil Dunphy. He ordered 500 crayons, five dollars for each one. We've got the date and we've got the status. So now we're just going to hop into our email and I'll just refresh and we should see the new email coming through. Okay, so I just refreshed and we can see this new order. We've received the new order from Phil Dunphy. Here are the details. 106, Phil Dunphy, 500 crans, $5 per unit. We've got the date and then we have the status. So as you can see, the date is actually coming through as January. January 20, 2025. And we did not put January 2025. So what you can do here is because there's a discrepancy, we will go back and end it. And we will go to our executions over here or right here. So executions, we can see this is the most recent execution. We'll click into here and we can see what's actually taking place. So as you can see, the trigger went off. It grabbed one new item. We'll open up this message model node. So we can see the information coming through and you can see the date come through here as 45585. So that's not what we want. That's why it's coming through as January, 2020, 2025. So what we need to do is come in here and fix this specific node because we see exactly where the issue is happening. I think the issue here was just weird formatting with numbers coming through as far as dates. So let's just try this one again. I just added this row, so it should be working right now to fire off. this email to us but we kept this one as just plain text so hopefully it reads through an NNN as plain text but let's take a look at the email and then we'll take a look at the actual execution okay just refresh got this new order it's coming through order 106 and we got the date correctly as October 20th 2024 which is what we put right here so let's go back into NNN let's refresh this page so we can get the most recent execution and making sure all the is coming through exactly how we want it and it's a great thing to keep in mind that you're able to go into the executions you can see exactly how stuff's coming through so from the google sheets trigger we're getting this information and the date's now coming through correctly how we want it previously it was coming through as just like four or five five for whatever, sometimes in sheets. It can be weird with date formatting. And then it's being able to come through correctly, order date, and it's giving us a nice summarization right here. We've received new order with the following details, order ID 106 for Phil Dunphy, crayons 500, all this kind of stuff. And then it's just going to take that subject and body and put it into a Gmail node, which is being sent over to natherk88 at gmail.com, which is what we see right here. So that was it. for this first example, I know that it was very simple. We just utilized three nodes to build this workflow that automatically takes data every time a row is added in your Google Sheets. It's going to summarize it with a large language model of ChatGPT 4.0. And then it's going to move into the Gmail node, which actually sends it off. And this was one execution of this workflow. Okay, now we're moving into part three of this masterclass, which is going to be talking about RAG and vector databases. I'm sure you've heard these terms, but maybe you don't completely understand them. So I'm here to break it down for you. And then we're going to end this part with going back into N8N, building out a simple RAG AI agent. And this will include actually uploading information into a vector database and then being able to use an agent and RAG in order to go talk to that PDF or file and get answers back. Okay, so what is RAG? RAG stands for Retrieval Augmented Generation. And it's a very powerful technique that's going to combine two different approaches. The first part is retrieval, and then the second part is generation. So this... technique really helps AI models provide accurate and relevant answers, especially when you need up-to-date or specialized information. So the first part here is retrieval. When you ask the AI a question, instead of it making up answers based on its training data, it's going to retrieve relevant information from external sources. So in this case, the Pinecone vector database that we're going to be setting up. So this is obviously going to be the database, but it could be other documents or it could be websites. And then the generation aspect of it, is after it retrieves back this information that's relevant and accurate and up to date, then the AI model will use this information to generate an answer. So this is where the AI actually crafts a human readable response with the information. If you don't already understand from that previous slide why RAG matters, let's break it down real quick. Let's say for this example, you're using an AI assistant that needs to answer questions about your company's internal policies. You don't want this thing to just guess. answers based on its training data. It might be out of date because you're going to update policies, stuff like that. So in this case the AI system will use RAG to retrieve the most relevant information from the system. It's going to generate an answer based on that specific information, which makes the AI far more reliable and up-to-date for your needs. Okay, RAG is a pretty simple concept to wrap your head around. Now we're going to move into vector databases, which I think are a little more complicated, but once you really break them down, not that bad. So in order to make RAG work, The system needs a way to store and retrieve data efficiently. This is where the vector databases are going to come into play. So in simple terms, vector databases store data in the form of vectors, which are just numbers that represent the meanings of words or text or whatever it is. And it's going to store these vectors into a multi-dimensional database. So these vectors are going to help us find similar or related information much quicker than sort of like a relational structured database. This one's going to be using a lot more unstructured data so even if the words are not the exact same. For example, you're asking about cars, the vector database might also help you find related information about vehicles or automobiles. As you can see in this picture down here, we've got wolf, dog, cat, and then the query is a kitten, so it's going to be searching for a kitten, information about kittens, and it will kind of be in this three-dimensional database store, it'll be seeing like similarities based on characteristics of these things. And as you can see, like we've got fruits over here, and then you might have vehicles down here. and you might have information related to certain types of products up here. So that's kind of how this works just from a visual perspective. So if you're wondering how vector databases work in relation to RAG, the AI is going to convert documents or text into vector stores and it's going to put them in the vector database where they need to be. Then when a question is asked, the system is going to look for similar vectors and sort of search out the... right area to pull information back, you know, relevant documents or data. And then once it finds these most relevant vectors, it's going to retrieve that information. And then finally, it's going to generate an answer for the human. Once you understand what a vector database is, what vector stores are, you need to understand how can you actually get information into a vector store. So this next slide is going to talk about sort of embeddings and stuff like that. Alright so embedding data into a vector database. This slide is going to be kind of tailored towards doing this in NNN. There's other ways too but is the way I do it. So real quick, let's just break down this picture. So what's going on here is we're testing the workflow. It's going to be searching a Google Drive for a specific file. It's going to pull that file, and then we need to embed it into the Pinecone Vector Store. Pinecone is just a vector store database that we use. It just seems to be very cheap, very easy to use. So this is the one we're using, but there's other vector databases out there. You might have heard of something like Supabase, but this one's really simple. Then what it's going to do is it needs to load the information. So the type of file that we're going to be using is going to be type of information coming through, whether it's JSON or binary, it's going to load that. It needs to be able to split it up. You know, it's going to chunk it up and then it's going to use the OpenAI model to embed it. into the actual vector store. So I know that this stuff may not make sense yet. We'll get into an actual example in NNN. We're building this out and we're getting real PDFs from our Google Drive up into Pinecone and we'll see all that take place. But we just wanted to give you a quick visual real quick so you can understand what's going through. The first thing I'll touch on real quick is the default data loader aspect of this. So in NNN, when we connect to vector store, we have to load the data. This node is basically just going to allow us to load data from a previous step flowing through, you know, right here. here and then we need to load it into here so that we can actually chunk it up and get it embedded into the vector store. So this node is pretty much just going to be looking at what kind of data we're loading in, if it's like JSON or if it's binary, that sort of stuff, and then we can just you know configure how much we want to pass through, stuff like that. And then we move into actually text splitting. So right here I have a recursive character text splitter. As you can see right here the three options in NNN will be character, recursive character, or by tokens. So the first option is is Character Text Splitter. This is just going to split the text into chunks based on a set number of characters. So you might want to use this when you want to break down text into equally sized pieces, regardless of where sentences or paragraphs end. And then the next one we have is Recursive Character Text Splitter, which I seem to use the most because this one is going to split text by characters, but it does so intelligently because it's going to break down at logical points, like after a sentence or in between paragraphs, stuff like that. But same concept of just chunking stuff down. So this is recommended. when you want to keep the text meaningful instead of cutting off a sentence in the middle, it's going to split at natural breaks like after you know a period or a comma something like that. And then finally the token splitter. This is going to split text based on tokens which are usually words or subwords that the model understands. And you kind of want to use this when you're working directly with a language model like ChatGBT because it's going to process text in terms of tokens and you know it's going to chunk it down based on how the AI model reads the text. So you know if you're processing data from model it's going to split the text accordingly. Hopefully I didn't confuse you guys too much, maybe I went into too much detail, but just wanted to break down those different types of splitting. But best practice is a lot of times you can just use recursive characters so the information stays meaningful. But just a quick summary here, so the RAG is going to be retrieving information from documents right here that we're putting into a vector store in order to give us intelligent answers. Then the vector database is going to store text in a way that allows us to quickly and efficiently search based on meaning, not just exact words that are hard-coded in. We're looking at stuff that's related to specific meanings of words. And then we're going to use a text splitter to help break down the large documents into manageable pieces in order to put them into the vector database. And then OpenAI here in this case is just going to embed it into the vector store. So that is basically how it's going to work and we'll hop into NNN and actually show you guys this. As you can see what we're gonna do here is build an RAG. RAG, AI Agent. And in this workflow, we'll be using a Nike earnings PDF. And we're going to put that into Pinecone, which is the vector database that we'll be using. And then we can chat with the agent in order for it to retrieve information about Nike's earnings so that we don't have to read through the PDF. We can just ask questions about it. All right. Like I said, we're going to be looking at this PDF of Nike earnings reports. So we're going to see this is the PDF that we're looking for. It's 10 pages. We don't want to really have to read this thing. we want to be able to just chat with an agent and it can pull the information for us. So first up here, get some sort of document that you want to put into Pinecone Vector Store. Then as you can see, I have this in my Google Drive right here so that we're able to actually, you know, call this information and push it into Pinecone through NNN. And then you want to go into Pinecone. It's just type in pinecone. It's free to get started. You want to set one up. You'll come into here and all you want to do is you're gonna create an index so you can name it whatever you want. I'm pretty much just going to keep everything as is. The only thing that you want to make sure that you set up here is right here you want to set it up by model and you want to choose text embedding 3small. So set that configuration and then you'll just hit create index. Your index is gonna pop up right here. If you click into it you can see that there's no information. You can see that there's no namespaces in here. Just a really quick explanation of namespaces. You can have different namespaces within each index. Like let's say I was in here and I had one for internal documents and I had one for client A and then I had one for client B. That's just going to help your agent be able to. Search for the information quicker because it can sort of break it down by, okay, I need to go to this index and I need to go to this namespace. And then here's all relevant information regarding this project or client. Once you've got all that information set up, we are good to hop into N8N and start. pushing information into that Pinecone Vector Store. So the first thing that we're going to do here is I'm just going to make this a manual trigger. In the future, you could have this where every time you upload a document to a certain drive, it would do a Google Drive trigger, and then it would automatically push that information. into Pinecone, which is super cool, because then your database is going to stay up to date every single day, every single time you add more information. But right now, we're just going to be doing a manual trigger. Next thing we need to do is add a Google Drive node, because we need to get that information from Google Drive into NNN. So we're going to click on this plus button. I'm going to type in Google, and we will see Google Drive right here. Once again, lots of actions. The integrations are awesome. But what we're going to do here is download a file. So if you haven't got this node configured yet, it should be... super easy because you've already set up your consent screen and your client ID and secret and all that. But in here, you just need to go and make sure that you have enabled the right APIs. So as you can see here, I've got Google Sheets, Google Drive, Gmail, Google Docs, Custom Search, all this different APIs that I can use within N8N. So set that up, make sure you're connected to the right account. And then we're going to be downloading is the operation and we're grabbing a file, the resource. And once again, we can choose from a list, which is awesome. We're going to come in here and look for the Nike press release. PDF so I'll grab that and then what we're gonna do is just hit test step because then we can see the information coming back. So on the output you can see that we're getting this information. One thing that's really important to know is that it's not coming through as JSON, there's no information here, it's coming through as binary. So we don't have to get too technical on what exactly that means but we have to just make sure we know how this information is coming through so that later when we want to embed it into the vector store we can make sure it's getting loaded correctly and I'll show you guys that later. But for now now just remember that this PDF is coming through as binary. So we can view this PDF, make sure it's the right one. As you can see it's Nike earnings so we're going to go here and we can move on to the next step. We've got our file. Next we need to add the actual Pinecone vector store so we can push the information into Pinecone. So we're going to add this. We've got four actions within Pinecone. Right now we're just going to be adding documents to a vector store but as you can see you could also retrieve, you could update, all that sort of stuff and we will be retrieving later in order to actually chat with our agent about this PDF. Once again, it's a little annoying to have to set up the credentials for everything, but once you have them, you're good to go. So in here, we need to set up the Pinecone. I'm going to create a new credential. And as you can see, we need to grab an API key. Once you hop back into Pinecone, you can see, obviously, if you get your indexes on the left hand side, you can go down to API keys. And then all you're going to do is just copy this value with this button right here, copy that. And then you're just going to really quickly paste that into the API key, hit save, and it should go green because our connection is successful. Speaker 1 05.15 Now we're actually able able to insert documents to the index. So the index that we want to insert to is called sample. And for the sake of this video, let's add it to a namespace. So click on add option, find code namespace, and we will just call this one Nike. And now we're going to go with this node. But what we need to do is we need to set up, like I talked about earlier, the default document loader, how we're going to chunk up the text, and then the actual embedding. So first we will do the embedding. to use OpenAI, you should have your credential already set up. And then we need to choose the model. So if you remember when we set up our pinecone index, we set up the model of text embedding 3small. So we don't want to do ADA002, we want to come in here and grab 3small so that it's being embedded properly. Then we need to choose this plus button and we're going to do the default data loader like we mentioned. Now here is what I talked about with we need to remember how the information is coming through this Google Drive. So remember we came in here, we see the output is binary, not JSON. So binary. is how we want the information to come through. So in the data loader, we need to make sure we're selecting the type of data that's going to be binary. Otherwise, you're probably not going to get any information put into Pinecone. So we're good to go here. The last step is just to set up the text splitter. Like I talked about the differences between these three, as you can see there's also a short little description here. So if you forget you can always come in here and read what they do. But we're going to choose recursive character text splitter. The chunk size like we talked about is just how many characters are going to be within each chunk and the overlap. We don't want to have any overlap and chunk size 1000. I'm sure that's fine for now. The PDF is pretty big but we can see how this works. So let's just hit save and then we... will test out this workflow. So it's a manual trigger. So we're going to hit test workflow. It's going to grab the file, download the PDF. As you can see, it went through the data loader. It went in here and then it had to embed it until it came into the actual vector store. So let's hop. back over to Pinecone, let's go to our database, let's go to the index called sample. We can see that we have information in here now and if we click on namespaces we will see that we just created a namespace called Nike and there are 29 vectors in here and as you can see 29 items left the Pinecone vector store node. Alright our information has been successfully put from Google Drive into Pinecone. Now we need to build an agent workflow that we will be able to chat with in order to get answers from this PDF. Alright we're in a new workflow here and once again we got to add a trigger so the first step is going to be a chat message because we want to talk to the agent in order for the workflow to start execution so we'll click on chat message we can leave this as is because we'll be using this button down here to actually you know talk to the agent and that's how it's going to work but we have our chat message trigger now we're going to add a new node we can come in here to advanced ai and we see there's a ton of different ai things we can do there's even some templates up here to see you know what's possible and you can download those and start playing with them, but we're just going to come in here and grab an AI agent. Now within this AI agent, you have different types of agents you can use. You've got tool, conversational, or open AI functions agent. You can read a little bit about what each of these do, but because we're giving these agents different tools, I think that we'll just keep this one as a tools agent. Come in here and call this guy our Nike agent. And then you can also do things like add a system message. You can return immediate steps. You can have him have a max amount of of iterations. We will add a system message. Right now, it's just going to say you're a helpful assistant. We can set this up in a sec once we get all the tools configured, but this is where we sort of tell the agent, you know, this is your job. Here's background information. Here are the tools that you have. Here's how you use them. Here's like an example flow. So we'll talk about all that after we get the rest of this workflow configured. We've got our Nike agent, and then you can see there's different things we need to set up. So the first one is going to be the chat model. I'm going to grab an open AI chat model. and connect our credential once again and then we choose the type of model we want since this is going to be pretty conversational I think I'm going to use 4-0 it just seems to be the most consistent it's kind of the one that I'm pretty loyal to but sometimes for smaller things like if you're just labeling emails or if you're doing some sort of classifier where you just need to parse the information and see like a category maybe then you could come in here and grab you know 3-5 or 4-0 mini but don't get too caught up on what each models good at but right now 4-0 is kind of the most expensive but it is the most powerful. So we set that up with 4.0. Now let's really quickly add a memory. So this is super super easy. We just want to grab a window buffer memory. This is super easy because that's all we have to do. We don't have to set anything up. You could change the context window length but five chats is how many the model is going to remember so I'm fine with that. But this is a really easy way to give the agent some context of what's going on. Otherwise when you're chatting with it let's say you asked what was Nike's his earnings in, you know, quarter three. And then if it came back with the information and then you said, okay, what about quarter four? It would be like, what are you talking about? Quarter four for what? So that's going to give context of, oh, he just asked about earnings. Now he wants to know about quarter, the next quarter. So just going to give context to your agent. Super easy way to add that memory. Then finally, this is where all the magic happens. This is where you can add different tools. So within here, we have, you know, different things that we can give our agent access to. Of course, we've looked at all the different nodes and the actions they can take but we can see here that this is where it's really powerful because we can call an nnn tool or an nnn workflow as a tool so that workflow that we just made about you know getting information into pinecone we could call that as a tool here but that's not exactly what we're going to do we're just going to call sorry a vector store tool and this is the one that's going to be getting our nike information so we will just call this database and then you need to give it a description of when to use this tool so we'll say call this tool to read to get get information about nike's earnings to answer the user's question okay so that is the description for this tool now we need to set this up with the actual vector store because we need to connect this to pinecone and then a model of course so let's add the model real quick pretty much same exact thing we're just connecting the credential we are adding a model I'll just do for a mini here And then we can see we need to grab the vector store. So we have in memory, we have different options here, Supabase that I talked about. But this is how we actually want to work with data within our Pinecone vector store. So we're going to click on that. I'm going to set this up real quick. And now we see. see there's different operations. This is the time we want to actually retrieve documents. We don't want to put anything in there right now. We're just trying to get information. So we'll click retrieve. We need to choose the index that we want, which is just sample. And then here's another option where we can add the namespace for this agent to go search through. So we called ours Nike. So make sure you put the right namespace in here and make sure it's spelled correctly too. So now we have that set up. So we're almost done with this agent. Last thing we need to do here is add the embedding, which once again, we did three small. So we need to set up three small once again. Okay. So this is pretty much it for this agent. We should be able to talk to it and have a conversation with it now. So let's hit save and let's just give it a shot. So real quick, let's go to the PDF and ask about something. So we can see the gross margin for the fourth quarter increased 110 basis points to 44.7%. So let's ask about the gross margin for the fourth quarter. So I will come back into NNN. We'll chat with this agent. We'll just say how was Nike's gross margin for the fourth quarter. See what he says. Nike's gross margin for the fourth quarter was 44.7%. So that was right. That's the information we're getting. But we maybe don't like the way that this agent's talking to us. So that's where we need to actually come back into the agent and prompt it. So let me just type out a real simple prompt. And then we will. we'll take another look. All right, I went into chat GBT and I said, hey, can you help me prompt this agent? It needs to understand its role, some context, instructions. I want to give it some example flows of how it should operate. And we got a pretty good prompt out of it. Let's just read through it real quick. We said, you are a friendly and helpful Nike representative tasked with answering any questions users may have about Nike's earnings. You have access to a vector database with all the relevant data on Nike's financial performance, including revenue, profits, other earnings-related info. When a user asks a question, you should search this database to find the most accurate and up-to-date information and respond in a friendly, approachable tone. Be sure to add humor and use emojis to make the conversation fun and engaging. Then we gave it instructions for an interaction flow. So basically we said to you, user asks a question, you're going to search the database, you're going to respond. And then we gave it some information or some examples of a friendly tone, greeting the user, throwing emojis, using jokes, all that kind of stuff. And then we wanted to give it a sample flow, sort of like more exact. The more examples that you can give an agent about, you know, what it might run into different situations, the better. And then finally we said the actual tools that it has. So vector database is really the only tool we hooked up. And we said to use this to retrieve specific earnings information and financial performance. Remember, your goal is to provide accurate data while keeping the user engaged with humor, emojis, and a conversational tone. All right, so let's give this a save and ask another question. Let's just come in here and say, who is Matthew Friend? Because he's the executive vice president and CFO of Nike. So we'll say, who is Matthew Friend? And like, what did he say? I guess. Let's see what we get from that. Who is Matthew Friend and what are his thoughts? Okay, so here's what we got from the agent. Matthew Friend is the executive VP and CFO of Nike. He's the financial maestro ensuring the switch stays profitable and innovative. And then we have two emojis there. Let's see. The agent gives us the quote that he said. And then at the end it says if you have any more specific aspects you're curious about, I can dig up his latest commentary for you. So good emojis, very friendly. Let's just say, sure, can we get some more info? And this is important because it's going to remember what we were just talking about, which was Matthew Friend. And we can see if there's anything else in this PDF that he said. So here's a slice of wisdom from Matthew Friend, the CFO. He recently highlighted that while Nike is driving a better balance across his portfolio, the fourth quarter brought some challenges. But no worries, he's on it. Matthew emphasized that Nike is taking strategic actions to reposition itself for sustainable, profitable, long-term growth. Okay, so we're seeing a conversation with his agent. Right here in the log, you can see... exactly what's happening. So you can see our agent, it updated the memory, it went to the chat model, it read through its prompt, and then it basically is like making sure it knows what to do. Then go to the vector store tool and we have the query which is Matthew's friend Matthew friend's recent statements or comments and then it got an output from the pinecone database. So if you don't understand what's going on here basically it's just being able to see the flow of what's going on so that you can you know troubleshoot if need be. But this is super cool and it just shows you how you can connect different tools. So we can even come in here and add a Wikipedia. So this is going to let it search in Wikipedia. So if there's information maybe that's not on this PDF. it could also access this tool and we'd have to obviously prompt it a little bit to do that but let's just see if this is going to work we can say what is the capital of florida and it should be searching through wikipedia to answer that question so the capital of florida is tallahassee it's not just about beaches and theme parks parks nice and friendly but you know this information the capital of Florida I doubt that it was on this earnings report from Nike so that just shows you that it actually went and searched through this tool and you know you can also add like a calculator in case you want to make sure it's doing you know math accurately So we got a calculator tool here now too. So we would prompt in that. But it's super cool because like I said, you can connect different workflows that you build within any of these tools. So let's say we have this agent here and we give it a tool that can send emails. we're going to build a workflow of automatically sending an email. And then we would just give the agent this tool so that if we wanted to chat with the agent and say, hey, by the way, could you send this information to Matthew Friend in an email? And it would actually be able to go to do that as long as it had... Matthew Friend's email, which we would give it in some sort of vector store as well. So I hope that that, you know, is a breaks down the concept of RAG, vector databases, Pinecone vector store, how you can link all these together when it comes to giving an agent access to all these different things in order to do what you want it to. So at the end of that last build, we saw we started expanding on that agent and giving it access to, you know, Wikipedia and a calculator tool. And so I wanted to talk a little bit more about how you can actually expand on these agents to make them easier. even more powerful and scalable. You know, like giving an agent access to more tools, giving an agent. access to agents to call on. It's super powerful, the stuff you can do. So in this part, I just wanted to quickly talk about building workflows as tools, how that all works, how that all comes together and the importance of it. And then we'll just go through a couple of examples in NNN of some agents that I've built and you can just see the way that they use different tools. All right. The power of being able to build custom tools in NNN. It's honestly insane. So first we have the fact that agents can use these tools, obviously. You can build a tool and have an agent call on it. Like, isn't it? In this example down here, you can see I have get email tool, send email tool, update database, summarize database, set calendar event, and get calendar. All of these are tools that I built within NNN. So these are workflows. I'll show you guys them once we hop back into NNN. But these are all different tasks that I built out in NNN. And then the agent is able to decide based on what I tell it, texting it on Telegram, based on what I tell it to do, it will decide which tool to use. in order to go complete that task. And then it will either tell me that it did the task or it will give me... you know, the summary of a database or my calendar, that sort of stuff. So agents can use these tools, you know, like a smart agent or a smart AI assistant that can call these workflows. So this is a great example right here of a personal agent. We also have the fact that tools can be reused and recombined. So now that I have these tools built out, I have a send email tool. If I ever need to build a different type of agent to send emails, I can just give it this tool. I've already built it. So it's already there in my workflow and I can call on it in multiple different agents. It won't really matter. So that is super helpful. super cool. They can be reused anytime and they can be combined with other tools. And now for scaling. So this is what I talk about. The fact that as you build out tools, you just have more and more tasks that you can complete, more things that you can give your agent to do. And then it gets even more powerful because let's say you want to not just have a send email tool, but you want to have an agent that can do everything within email. So you would have an agent and you would give it a ton of different tasks in email. So you'd have an agent with get emails, send emails. label emails, draft emails, delete emails, all this kind of stuff. And then you could give your overarching like larger agent access to the agent that does email stuff. So this agent would be able to decipher, okay, do I need to go into Outlook or Calendar or Teams or Slack? And then you would down here have one agent that does everything in Slack, one agent that does everything in Teams, one agent that does everything in your calendar. And then you can just build on top of each other. And also that's going to make your workflows more efficient rather than trying to, you know, send a prompt through with like giving this agent you know 50 to 60 tools like that would be way too much even I think like 20 is probably too much but that way you could give the agent other agents and it's just like you know the hierarchy of it's gonna go through this guy then it's gonna go to these agents and then it's going to come back. So it's just, you can get really creative here with how you can get stuff done. And all you have to do is break it down by tasks. So take a task and combine these with a larger workflow of getting all these tasks done. And then you know, larger, just scale up pretty much. So now let's just hop into NNN and we can take a look at, you know, this assistant and a couple other ones. All right. So this is the personal assistant that we were just kind of taking a look at back in the slides. But as you can see, it's got just pretty much seven. tools it's got database information so for something like getting or sorry sending emails it needs you know contact data information who to actually send it to what's their email address and then we have these different tools get emails send email get calendar set calendar and then update or summarize the database so real quick I'll just show you guys how I talked about these were all tools within my nnn so if I go back here we can see here's the update database tool here's the calendar email so we can like click into one of these so let's do summarize database. As you can see it's just a very simple workflow. We've got different nodes, we've got the actual database. It's going to call on this database, it's going to summarize it, aggregate everything into one clean field, and then it's going to send the response of the information back to the agent. So it's going to go through this process, then it's going to have a summarization right here. Once we get that information summarized, it's going to go back to the agent and then it knows its job is done. So then it's going to output a telegram message back to me. So real quick, let's take a look at this database. This is the project database that I'm summarizing in this case. So we've got different tools or sorry, different projects. We've got notes about the project and then we have the different statuses. So I know it's a very simple example. But that's just, you know, I was testing out this personal assistant and trying to make a video about it. So here's the assistant. Let me just pull up my telegram with my that I talked to for my assistant. As you can see, there's different information that I've been testing out with other workflows and other executions. But let's just come in here and say, can you summarize our database? And so this is going through Telegram. The agent is getting this prompt right here. Can you summarize our database? It's figuring out which tool it needs to call in order to do that. And then it's going to summarize the database. As you can see, we just got this message back. Here's a summary of the current status and contents. The AI project is complete. The marketing campaign is pending. It involves drafting content that is ready and awaiting review by the marketing head. Mobile app project. This project involves developing a user authentication module, which is currently ongoing. Beta testing. has been scheduled indicating progress is in the works so as you can see it's you know summarizing all this information for us it could be super useful if you were on the road and you need to send a quick email so you just have to text this agent real quick or you know on your way to a meeting and you need to summarize get some quick information summarized it could even summarize all the emails you've gotten from a certain day so that is a cool example of building an agent and giving an example giving it access to different tools that you've built in an end by the way if you if you want to know more about what this agent can do please go watch the video i'll tag it right here i made a whole video about you know building this personal assistant and sort of like the capabilities of it and how you can expand on it so definitely go watch that video if you want a more in-depth look at what this agent does here's another quick example of a different way you can structure an agent this one is being triggered by a gmail so every time i get a new email it's going to come through here it's going to classify the email give it a label of high priority customer support promotion finance and billing and it will actually give it a label on gmail And then for each of those types of email, it's going to come through here. And so like for high priority one, it's going to create a draft and then it's going to have the draft sitting in our email. And then what I would do is, actually, I made a video about this one too. So if you haven't seen it, I'll tag this one too. And you want to go look and see how this works and how to build it. But then what I did in the video is we hooked it up to a send text message node right here in Telegram. So I configured this. And then. It was able to let me know, hey, we made a high priority draft for you based on this email from Kevin and now it's like there for you and then I did the same thing with all these other ones so like for customer support we let it actually create an email and reply to it so it actually sends off an email and then the telegram message says we sent off an email for you based on you know it was a customer support email same thing with these two down here and you know if I pull up telegram we can actually see these past interactions I've had so like for a finance and billing one down here we wanted it to summarize the information and then send it to the finance department so right here we see you receive the finance and billing inquiry from Angela from the accounts department we've notified your finance department of this email right here it's like a promotional one so here are details regarding a promotional email from Nate it gives us a summary of the promotion and then it gives us a recommendation so that's something that we crafted out right here and all of these were linked up to different telegram nodes to let us know notify us of what's coming through and what the agent had done so like I said go Watch that video if you want a more in-depth run-through of what this agent does. But the purpose of me just showing you guys this real quick was just to open your eyes about how you can expand, how you can build off of different ways you can structure agents and how you can make them do exactly what you want to do. remove yourself out of that process to automate things. So just super cool stuff. Moving on to part five, which is going to be talking about APIs and HTTP requests. This kind of stuff can sort of get a little technical and seem confusing, but I'm here to make sure we just sort of break it down. down as simple as possible. So before we really get into the content of this part, I wanted to just stress that, you know, we've already been working with API calls and API tools, whether you've known it or not. All of the pre-configured nodes in NAN are pretty much just HTTP requests in some way or another. So when you're using these nodes, NAN is doing all that hard work of making the API call for you, you know, either fetching or getting some data, like in that previous example, when we were using that Google Drive node to get information to put it into our Pinecone vector store that was pretty much an api call to google drive looking in our google drive grabbing the file and then we got the information back in nnn so we're pretty much already doing that you only really need to use apis and http requests in nnn if you want to connect to something that there's not an integration for which is kind of rare but it's good to go over just in case you do need to do this so yeah the nodes in nnn they know exactly what to do exactly where to go where to send the request and how to get the information you need or or put information somewhere that you need to. So now we can move into talking about APIs. So what is an API? It stands for Application Programming Interface. So basically just think of it as the bridge that is gonna allow two different softwares to talk to each other like and Google Drive, whatever it may be. So here's a concise summary about API endpoints, calls, and HTTP requests. So the endpoint is just basically going to be a specific URL or address within the API where a certain service or piece of data can be accessed. So it's like the exact path that you need to take. Once you access that API, you have that endpoint, so it's going to specify where you need to go. Then the API call is just that request that you're making. to the API asking it to perform some sort of task or provide some sort of data, so it's like you're placing an order. And then the HTTP request is the actual method that you use to send that API call over on the internet. So it's sort of just the messenger that's going to carry your request to the API endpoint and then it's going to bring the response back. In a nutshell, you're going to be making an API call using an HTTP request, which is going to be sent to a specific API endpoint, and then we'll get the information back. from the API and then the HTTP request is going to return the information to us. Okay, so what is an HTTP request? Think of this as just the way that your computer or NNN is going to be talking to the other service. So you can do things like get data, which will be sort of a get HTTP request, or you can send data which will be a post HTTP request, which you'll see once we hop into NNN and actually look at some examples, but just as simple as either asking for information or Sending information somewhere. I remember when I first heard about all these different terms. I thought to myself like that sounds so similar How do you really distinguish? So let's just quickly talk about how they actually work together So like we said an HTTP request is how you actually make an API call. It's the messenger That's going to carry your API call to the server. So we've got a quick restaurant analogy. Let's think about it like this So we have the API. This is like the restaurant itself So this is the service that you're talking to the restaurant is going to provide different services to its customers Just like an API, the restaurant offers a menu of things that you can request, different actions or different data. Then we have the API endpoint. The API endpoint is like this specific kitchen station that you're talking to. So it's going to handle a particular dish. There are different stations for each task, cooking pasta, making pizza. So the endpoint is like going to the correct station in order to get the specific dish that you ordered. Then we have API call. An API call is like placing the order. It's the actual order. So in this case, we wanted spaghetti. That's how we know to get it to the right spot. But you'd order the specific meal, and that's just making the request for data or for a specific service from the API. And then finally, we have the HTTP request, which like we said, is pretty much just the mechanism that's being used to deliver the request. So in this analogy, it's going to be a waiter who's going to take your order, bring it to the kitchen staff, and then when they're done, when they bring the dish, the waiter is going to bring back that food to you, bring back that information that you were looking for. So hopefully that was simple enough. API call is the concept. HTTP request is the tool. So you're asking for something with an API call, and then the request is going to be how you're delivering it over the internet. All right, now let's just get into NNN real quick and just look at a few examples of... an HTTP request node and sort of what it looks like to configure something like that. We're now back in N8n. As you can see, I've got three different HTTP request nodes in here. So you can just come in here and grab HTTP request, as you can see right here. But these first two, we've got two gets. So we'll be asking for information in one way or another. And then this last one will show a post where we're actually sending information somewhere. So let's just go into this first example here. So this one's going to be a really simple one where making a get request like I said so we're asking for information. Here would be like sort of that API endpoint like we talked about so we're going to be going to openweathermap.org. We're going to be asking for weather you can see here's some parameters q equals New York so we're looking for weather from New York and then we have a little credential here we had to set up an API key to actually be able to access the API of open weather map and get into you know that's my API key so it knows that we have permission. And we'll hit test up here so we can just see that this request is working. We can see information coming through on the right-hand side. We've got clouds, we've got temperatures, we've got wind. And as you can see, it came back for the name, the city of New York. So we know that this request was working. I won't go too much right now into setting up parameters and headers and body for your request. But usually when you want to connect to a certain API, they're going to have documentation on it. So in this example for OpenWeatherMap, they have exactly like... the endpoints that you need to find or they'll give you what you need to type in and how to specify parameters it's not like you have to know how to just find this stuff because that seems pretty technical so yeah most of the things that you want to connect to if there's not an integration in nnn already will have documentation on their website of how to connect to different things how to request for different things how to send different things so you'll just have to read through documentation but another cool thing obviously like we were getting weather from open weather map but as you can see like open ai already or sorry nnn has integrations for this where it's a lot easier because this is basically setting up that API call. They just did all the coding, the technical stuff on the back end of that. So we have this basically the exact same thing. Okay, so this next one is another get request. This one is, as you can see, we're going to be searching Google. So we have the endpoint right here of google.com slash search. But we did want to set up some parameters here. So we have Q, like we saw that last one, Q equals New York. This time Q is equaling site colon linkedin.com. slash in slash. Okay, so this is the URL that we're basically trying to access. So if we've pasted this into Google right here, we would see like it brings us up Google. So that's what we're searching on. And then within Google, we want to be searching for site colon linkedin.com slash in. So go back to Google, paste that in there. And you can see what's coming back is actual LinkedIn, just LinkedIn profile. So that's sort of how this parameter is working. And we can go ahead and test this step real quick. We can see exactly what's coming back which is going to be a nasty chunk of HTML. A lot of information in here. Your next step here would be to parse through this information with a different node that would grab you just LinkedIn profiles. So like if I come in here and search linkedin.com, you can see like, I'm sorry, we've got a lot of hits, 173 hits. And we can sort of go down until we find actual profiles. So that's what you have to be parsing out. But right here we have Robert W. Livingston. So if we go back to the actual Google search, we can see that first profile coming through is Robert Livingston. And then if we were to continue to go down and look through all the different results, we'd see all these different profiles coming through into our NADN. So that is the way that this request is asking for information from site colon linkedin.com slash in. And then we're actually getting back the parameters from, or sorry, the information from Google through that request. And for this final one, we're making a post request, as you can see right here. So by clicking to this, we'll see what's going on in this node. This is a post request and I was able to go to Google APIs in order to see how to access my calendar. There's going to be different API endpoints in their documentation of like, you know, copy this URL if you want to create an event. Copy this URL if you want to update an event. Copy this URL if you want to get information back on your events. So that's all I did. I hooked up that API endpoint in here. Obviously, I had to set up my credentials. And then in this example, we have to send a body because we're posting data, sending information. And so this is really simple. It's just JSON. Sort of setting up the criteria for the event. You could go into ChatGPT and say, hey, I'm accessing a Google API for my calendar. Can you help me set up a body? And it should work with you there. But in this case, the summary of the event that it's going to be making is meeting with team. We have a start date, noon. We have an end date of 1 o'clock. And we can add attendees and different emails. And real quick, I'll show you. This is the calendar that I'm accessing right here. So there's nothing going on today. And we're going to make the event for noon. So I hit Test Step. It'll come through. it'll say that worked and we can see on here we just got our meeting with team from noon to 1 p.m and the information coming back here is just going to be like a meeting link it's just going to basically tell you that that post request went through successfully all this kind of stuff But another case where that would just be overcomplicating things, you've got Google Calendar right in here. Where is it? Right here. We can get availability. We can create an event. So all we did right here was create an event. This is going to make it a much easier way to actually send that request because you just have to fill in different parameters, and you don't have to worry about the API endpoint putting that in. You don't have to worry about the JSON sending over the data in that post request. You could just do that right here as well. Now that that concept of just how you access endpoints and how you actually send or receive data makes more sense, what you would want to do from here is like the more realistic use case when you're building stuff like this and you need to integrate with something is going to be a webhook trigger. So you can see like you've got your URL here, you have an HTTP method, and this is the kind of stuff that you'd be more familiar with setting up once you understand the basics of sort of these nodes. But these are going to be really powerful tools because these will let you trigger a workflow based on information coming through from another site. So if you wanted, if you had some sort of form on your website and you wanted to hook up to that and then every time someone filled out the form you could have this go through where it's gonna you know notify you that someone filled out the form, it's gonna send them an email sort of welcoming them, it's going to throw them into a database and then it's gonna send a slack message to your team, something like that. So these web hooks can be very powerful when it comes to automating other processes as well and getting pretty customized. But before you get in here and you want to start configuring stuff I think it's just important that you understand the framework and the basics of APIs, endpoints, HTTP requests, and how all that stuff is going to work in NNN. And then you can really explore with stuff like webhook triggers, which are very cool and offer a lot of flexibility. All right, we have now made it to part six, which is going to be the final part of this masterclass. We've covered a lot of ground. We've started the basics of NNN, building your first workflow. We created an AI-powered agent using RAG, RAG, and vector databases. We made API calls and HTTP requests. We talked about extending your workflows with custom tools and webhooks. So you're no longer a beginner. You have the tools and knowledge to create powerful automations that are going to transform your productivity, the way you approach your automation projects. And I just wanted to close off with talking about error workflows, just sort of best practices when it comes to creating workflows in NNN and sort of how you can do that most optimally. And then just some final next steps and just closing thoughts. All right, back in NNN here. we have a error demo workflow which is just an error workflow that I just created real quick. As you can see it's going to start off with an error trigger. So this workflow is going to execute whenever there's an error in another workflow that we're hooking up this one to so that'll make more sense once we actually configure it. But as you can see it'll get triggered and then it will come to my telegram which will be sending me a message. So it's going to notify me that there's an error, it's going to tell me the workflow that's erroring, it's going to tell me the error message that happened. And then it will give me a link to the actual execution of the error. So that would all just pop up on my telegram. I could click on the link and come in and see what's going on. But in this case, this is going to be a personal assistant. I showed this a little bit earlier. So this is the workflow we want to hook up to that error workflow. We come in here up top right, grab that three dots, click on settings. And then right here, you can see error workflow. So a second workflow to run if the current one fails. The second workflow should... have an error trigger node. So we saw the error trigger node, we saw that this workflow is called error demo, so we've hooked that up as this error workflow. And now we just need to make sure that this workflow is going to error. So let's just delete the brain of the assistant. So this one should error for sure, as you can see it already is. And it's going to be calling this and then it's going to be filling in the information when it errors. So let me just pull up my telegram real quick. As you can see this telegram, this is my AI personal assistant. So this is how we talk to it and this is how it talks to us back right here. You can see this flow. Let's just ask it to do something like, can you get my emails? This should error. And as you can see, we got the error notification. The workflow is personal assistant, which is right up here. The message is that a chat model sub node must be connected. So that's the error that's going on right here. And then we have a link to that execution. I can click on that link and it should bring me into what exactly just happened. And we can see why it's erroring. So as you can see this is the most recent execution that just happened. It's going to take a second to load up but basically the error is just happening because a chat model sub node must be connected. That's why it aired and as you can see that's exactly what it told us in here. Okay so that's kind of how this works. You know you could even go you could expand off of this so let's say you want to get notified but then let's say that we want to you know send an email to the team that says hey this isn't working right now. We're working on this to get fixed. So let's just come in here and let's send a message. I was meaning to set up all this information. So let me do this real quick. Really quickly configure this node. Obviously we're sending a message, put who you want to send it to. This could be you know a ton of different emails. We've got the subject which is going to be error and then it's going to tell us the error message and then the message of the email is going to say hey team we received an error in blank workflow we're working to resolve the issue thanks. So if I just you know test this step we would see that that came through. Let me pull up the email real quick. So here you can see we got the error example error message hey team we received an error and example workflow we're working to resolve the issue. So let's just quickly go back to NNN, turn off the append attribution, and we'll save this. And then we can pull up Telegram. We will ask it to get the emails again, and we will get an error notification in our Telegram right here. But then we should also get a new email with that information coming through. So we'll just give this one a sec here. Okay, now we've got an error. A chat model subnode must be connected. Hey, team, we received an error in personal assistant. We're working to resolve the issue. So obviously that's just a very... quick example email you could configure the subject and the message however you want but that's just goes to show how quick error workflow you can set that up you can hook it up to multiple different agents multiple different workflows that you have that when they when they error this logic will take place and you'll get notified right away so that's just another cool feature of it in it alright if you guys have made it this far really appreciate you sticking it through all the way hopefully this has been a really helpful session But before we close out, let's quickly go over some best practices for workflow optimization to ensure that your workflows are staying efficient, maintainable, scalable, and all this kind of stuff as you build out more complex automations. So the first thing I wanted to touch on real quick is just keeping your workflows organized. As they grow, you got to keep them well organized. It's going to save you a ton of time down the road when you realize, oh, like we have to redo this or there's a problem and now we are all confused about what's going on here. So make sure you use, you know, descriptive node names. You can throw in comments really easy with a little sticky note. You can make notes in your workflow so that if anyone else wants to come in and look at what's going on or wants to help you out in the future, they can quickly understand what the workflow is doing, what each part of the workflow is doing. Then we want to be able to use sub-workflows for reusability. You don't need to reinvent the wheel every single time you want to do a similar task in these different workflows. Consider creating sub-workflows like we talked about with maybe one for sending email, one for creating calendar events and then you can hook that up to a bunch of different agents or even have an agent that's you know a specialist in one certain type of platform So that's gonna make it save you a ton of time later down the road when you want to make more complex automations You don't have to build out the same, you know five nodes They're gonna be the same staple for every single thing that you need to do in that space So that's just gonna save you a lot of time and avoid redundancy then the third thing we want to do is implement error handling so already talked about that a little bit but You can even take it a step further. So, you know, errors are going to happen. It's no workflows immune to issues like an API failing or something like that. So if you build in some of these issues or error handling issues, it's going to ensure that your workflows remain robust. You can be notified if something goes wrong. You have like a safety net behind each of your automations. And then finally, just you want to optimize for scalability. So as your workflows get bigger, efficiency is going to be super important. So you want to use features like batch processing or pagination. You want to have a lot of conditional logic in there in order to handle larger data sets, more complex branching workflows. So scaling doesn't just mean bigger workflows, it also means making them smarter workflows. And next steps, now that you've made it through this master class, you've built a solid foundation, I encourage you to keep pushing your boundaries. There's so much more that you can explore in N8N, and your next steps should be about expanding your skills and experimenting with sort of more advanced templates. So in order to do this, to continue growing and learning, I definitely want to invite you all to join my free school community where we all share ideas, workflows, cool things that we've built using NNN. It's all about collaboration and inspiration. So whether you're looking for feedback or you just want to brainstorm new ideas or get some questions answered, it's nice to have a very supportive community to share your progress with. And it's going to make the experience a lot better. So please hop in. The link for that is going to be in the description. And I'll also be sharing a lot of resources in there that I use in each of the videos and stuff like that. So. I'd love to talk to you guys and I'll see you in there. The first thing here is going to be just to get in and start building. You know, the power of learning by doing is insane. Automation, but really anything that involves tools like NNN, it's best to just learn by getting your hands dirty. You know, as you build workflows, experiment with things, push the boundaries of what you can automate, you're going to run into challenges and you're going to have some failures. But that's definitely a good thing. Like, it's just part of the process. And when you fail and you can go in and figure out what happened and actually solve that problem. You're going to just understand the process way more than someone who, you know, is not actually getting in there and doing things, just watching YouTube videos, stuff like that. You know, even every time I build out any sort of agent, any sort of workflow, it always fails and it's just going to happen. But that's how you really understand, you know, the law. I could stop moving through so these moments are where you're gonna gain the deepest understanding of how NNN works and how you're able to Actually improve on your skills. So, you know, don't be afraid to make mistakes It's just gonna happen then I would say you want to get in and start exploring some advanced templates So at the beginning of this master we looked at sort of the community in NNN and the template gallery which is just a goldmine of ideas and pre-built workflows so you can dive into those you can see how people are building things you know there's no one right way to build an automation so you can see different ideas and it will really help you expand your skills there too. The third thing I would say would be to experiment with new integrations. Don't be afraid to try out new ones, even though NAN supports over 300 integrations for popular CRM systems, social media platforms, databases. It's really important to just get in there, play around with HTTP requests, different webhooks, and see all the possibilities of how you can automate stuff. And it's really just going to expand your capabilities. And then you can always start to build and share your own templates once you really get experience with it. with building out different things and you start to get more creative with your workflows. So that'll be really cool. You can share them with the community. It's a great way to inspire others and also get feedback on the sort of builds that you're doing and how to optimize them. So yeah, that is going to be it for the masterclass. Those of you that made it this far, I really appreciate you taking the time to sit down for however long this video was and just listen through all this kind of information. And I really tried to structure it in a way where you'd really be able to come from a beginner and really understand what goes on in NAN and how to... just get in there and start building some simple agents and then just make them more more complex as you learn but like i said that's the end so congratulations for making it this far thank you guys so much for your time and i will see you in that school community