N8N Tutorial: Building N8N Ai Agents (Beginner to Pro) 🤖✨

13.86k views9285 WordsCopy TextShare
Productive Dude
✨Join Ai Pioneers: https://www.skool.com/ai-pioneers 🚀Join Ai Foundations: https://www.skool.com/ai...
Video Transcript:
[Music] hello and welcome to the ultimate n8n tutorial for 2025 in today's video I'm going to take you from being a complete beginner at building AI agents all the way up to an AI agent building Pro we're going to start with the basics and the foundations of building agents using n8n and we're going to work our way up to the more complex topics I've sectioned this video out in chapters so you can find exactly what you're needing help with so I suggest that you use them if you're interested in early access to my YouTube videos
and bonuses when when it comes to AI I highly recommend joining AI Pioneers this is our free community we do one call per week here there's a massive community of 2,000 plus members and when you're ready to get serious about AI you can also upgrade to AI foundations where we have three weekly calls a more tight-knit community and a structured course curriculum I'm going to leave both of those links below so you can decide if you want to join one of our communities now let's dive into n8n first things first I'm going to talk about
the two versions of n8n that you can use the first is the cloud version this is going to be running in the background for you 24/7 but there is a cost to the cloud version to figure this out you can go to pricing and then you can see their Cloud pricing right here but what I'm interested in and what I'm going to show you guys how to do is how to run n8n on your local machine so that you don't have to run it on the cloud for these expensive fees you can self-host n8n in
a matter of 5 minutes or less to do this I'm going to go to docs from here I'll go to hosting n8n and then you'll see installation types here you can set up whatever installation type you want but I'm going to be showing you the npm version okay so npm is the quick way you must have nodejs installed so make sure to go through that process of installing node.js and then once you're done installing nodejs by following the install guide over on nodejs.org you can go back over and you can start installing nadn so to
install n8n globally you're just going to use this Command right here I'm going to copy it I'll open up my terminal and I will paste that first command and now this is installing naden once naden is done being installed and you're at the next dialogue you're just going to copy n8n or you can just type it in and once you hit enter it's going to start up nadn on a server locally for you so from here you can just hit o and it's going to open up anaden from your Local Host as you can see
right here here in your browser I'm going to go to full screen and then I can create my first workflow here I'll just hit start from scratch and it's going to load in this canvas right here where I can create my workflows up here you can set this workflow to active or inactive you can share the flow with collaborators if you upgrade to a team plan even on the local version they do have a version that is for teams so you're going to need to upgrade to that if you want to access that here's obviously
the save button if you want to save your progress as as you go and then up here in the right hand corner you can download this or duplicate it if you want to use this workflow elsewhere if you hover over the right hand side here you'll see add sticky note so if I click add sticky note it allows me to create this nice sticky note that's just drag and drop and I can put these sticky notes throughout my Automation and this would just help me keep track of what's going on in the automation I can
even drag them over a certain module so I can say uh you know this is the starting point of of our Automation and then I could resize it down and it's kind of nice and you can change the color here so maybe you have different colors for different parts of your flow but this is just a good way to stay organized I'm going to click on my sticky note and delete it for now now you'll notice that there's the editor Tab and there's the executions tab so the executions is just going to show what executions
are going to be happening in what order the editor is where you're going to spend a lot of your time though if you want to access predefined templates you can go to the templates tab right here in the corner this is going to bring you over to nad's website where you can search through their database of automations there's already so many in here I'm going to head back over to my local version of NN which is just in another tab here I'm just going to close this side panel for now so we have a bit
more space to see what we're working on in our canvas and you can give your workflow a name up here I'm just going to call mine basic agent example if you want extra organization you can tag your workflow close as well just by hitting add tag I'm going to tag this one as tutorial so I know that this is part of a tutorial series on nadn next we have to choose how we want our automation or our agent to start so we can click this button in the middle to add our first step there's tons
of different triggers for workflows but in this case I'm just going to start with the basic native chat message this allows us to interact with our agent and test it out to see how it's working and we can chat with it right here inside of nadn so let's click on chat message if you click into settings here it just gives you a basic place to add notes to your automation so I could just say this is how my agent starts a conversation and if I want it to be displayed in the flow I can turn
this button on right here whenever I'm ready to go back to the canvas and get out of these modals that are going to be popping up throughout this training I can just hit back to canvas in the upper leftand corner now I can see my note right here if I click on these three dots right here and I hit re name I can change the name of my note I'll just call this chat input and then I'll hit rename next is the fun part this is where we get to start defining our agent so if
I click on this plus right here and then I click on Advanced AI I can just click on AI agent if I want to use an agent right out of the gate The Prompt source as you can see is already connected to the chat trigger node this is the trigger node that we just set up where we can chat with it locally here in nadn if I wanted to change the source that prompts this agent then I can select from the list right here or I can Define it below using an expression let's head back
over to the canvas and now we'll see that we have these three new options here we have the chat model we have the memory and we have the tool so these are the different things that you can add to your agent I'm going to start with the chat model and we can select from any of these models here we'll just go with the most popular open AI once you get to this point you're going to see that you don't have your credentials attached yet click on select credentials create new credential and this is where you're
going to enter your API key to get this create an account on platform. open.com this is openai's developer dashboard this is where you can access your API key and you can load up credits to charge you when this is being used just go to settings and you'll want to go to billing and set up your billing details there and maybe load in5 or $10 worth of credits to test with and then once you've set up billing you can go over to a API keys from here you can hit create new secret key in the upper
right hand corner so I'm just going to call it n8n agent and where it says select project I'll go ahead and select default project and that's going to allow me to create my secret key I'll just hit create secret key and now you should see your API key here you're going to copy it head back over to nadn and enter that API key in the open AI account section I'll just rename this n8n agent so so that I remember exactly what it's named over in open aai and now I'm going to hit save from here
let's go ahead and close this window and now I can select my model so open AI allows so many different models but we'll just start with the GPT 40 mini to save on costs let's go back to Canvas and now we're going to give this agent some memory so that it can remember the context of the conversation and the past chats and the thread so I'll click on memory and we're going to select this first option window buffer memory this is the easiest way to get started with n8n and to get started with agents so
select window buffer memory and it's fine to keep this context window length on five right now this is how many past interactions the model receives as context and it needs to know where to pull that context from so we're using the session ID of that connected chat trigger node that we created in the very beginning I'll click back to Canvas and this is all set and ready to go we almost have our first agent created now comes the fun part we get give it tools that it can decide if it wants to use let's just
add the most basic tool that we can use I'll just hit plus here and I'll type in calculator calculator is really easy because it doesn't have any parameters to change and by default it's just the simplest test to see if your agent is working I'll go back to the canvas now we can start testing our agent so I can save this to make sure it's all good to go and then we can hit chat so let's just start with a basic question that doesn't require the calculator tool I'll try what's your favorite color and as
you can see I can slide this down to see the flow and see how everything happened we can see that it went and used the Open aai chat model it looked at the previous memory which there wasn't any and then it had an output right here with this AI agent that ended up back in our chat but you'll notice that the tool is still blank it didn't decide to use the tool for any of this calculation if I wanted it to use the calculator though I could give it a different instruction here like what is
2 + 2 and then I could hit enter and obviously the model is going to know that it's equal to four but just to see how it worked and how it kind of came to this conclusion we can click through this tree right here and we can see exactly what's going on inside of the system we can see that it queried the calculator with 2+ 2 it got a response of four and then it knew to come back and reply with uh 2 + 2 = 4 from there the window buffer memory saved the context
of the conversation that just happened I'll go ahead and close this chat and if we click on executions now we're going to see the two executions that we just completed we'll see the first one right here and as you can see I can kind of look back at what it did in that interaction let's head back over to the editor for now and I'll go ahead and clear the chat this is going to delete all of the current execution data under executions so now we're starting fresh so that's been creating a basic agent with naden
but what if we wanted to create something a little bit more advanced something that could really help us in our everyday life and at work maybe you're starting to understand the mechanism but now you're trying to figure out how you can actually use this thing and trust me that's the battle that we all face over at AI foundations if you're interested in joining a community of like-minded people AI foundations is the place to go we're building agents we're using nadn we're using make.com we're learning about all of the different models and prompting and if you're
a sucker for networking and Community you're going to love this space especially if you're a little bit more interested in AI than the rest of your family and friends think of AI foundations as your AI family we have weekly calls an active Community Feed and advanced course content and templates from my brother Drake and I you can join using the link below but here's the deal I'm not going to leave you hanging I'm going to show you how to build an advanced agent right now and the people that get this are going to be miles
ahead of their competitor so listen up because the back half of this tutorial is where the winners are going to be made or our example we'll be creating an agent that has access to my calendar so that it can read my calendar and create new events this agent will literally be able to schedule my meetings for me and it can answer questions about when I'm busy and when I have some more free time to set aside for myself we'll start by deleting the calculator tool if you haven't already and then I'll click on the tools
right here and we'll go down to the Google Calendar tool I can just click on this one and then same thing we're going to have to generate some credentials for Google Calendar so that it can access our own personal Google Calendar so we're just going to click on select credential create new credential and it's going to walk us right through doing this it needs a client ID and a client secret I'm going to hit open docs and let's go with the oo method so I see here that it wants me to go to the Google
Cloud console and create a project so I'll just copy that and I'll paste that search it on Google and as you can see here we have the console. cloud.google.com that's how I found it I can just click on that and if you aren't already signed up or if you haven't used this before what you're going to do is sign up get all signed in and then click on this button up here it might say create project or something like that mine just is in my current project but I'm going to hit new project and from
here I can call this n8n agent so I know exactly what this is for I can hit create so I've created my project the next step is to enable apis to do this I can click on my project make sure it's selected here then we'll click on apis and services from here I'm going to hit enable apis and services and I'm just going to search for calendar and there's two apis here there's the Google Calendar API and the caldav API we're going to select the Google Calendar API hit enable and now it's going to load
up this screen right here the type is a public API and I can hit create credentials we'll select user data hit next I'm going to give my app a name and an agent I'll add a support email and I'll also add a developer contact email then I'll hit save and continue from here you can Define Scopes if you want to I'm just going to hit save and continue next we need to give it an ooth client ID so for the application type I'll go with web application we'll name it an8 an agent for the authorized
redirect URI we're going to hit add URI go back into n8n and copy your redirect URL paste it here and hit create now it's going to give us our client ID just hit copy to clipboard paste that into client ID then we'll hit done go to credentials hit the edit oo client button and then you can copy the client secret right here we're going to paste that in and now we can hit sign in with Google from here we can sign into whatever Google Calendar account we've given access to through our Google cloud service allow
and here perfect it says got connected the window can be closed now so I'll just go back to this window here and it says account connected I can just click out of this let's just exit this and now if I click on my credentials here I can see that I'm connected to my Google Calendar account through ooth 2 for the tool description we can set it automatically or you can click on this and hit set manually and you can give actual instructions about the Google Calendar API maybe this tool is just intended for creating calendar
events so so I'm going to say this is the tool you use to create calendar events we're going to click on this resource right here and we're going to select event because this is for creating new events and for the operation I'm going to stick with create then let's go ahead and select a calendar I'll just select my personal calendar and for the start and end date we can go in and add an expression and this expression is really simple you can just copy and paste it from up here but this is going to allow
the agent to enter a start date for us so that it doesn't have to follow any predefined rules with that that's really what makes the agent so magical is that it can actually do a lot of this stuff for us so this is the startor date that's just what I'm going to type in there for that variable then I'll copy this expression once more and we'll go down to end change the expression here to end date and I just pasted in the one that I copied from up here it's start date and end date now
you can add a addition event fields or properties here you can just hit add field and we can change different things about the event like if it's an all day event or if I have certain guests that are getting invited and they need certain permissions I'm going to select summary I'll go ahead and choose expression here and I'm going to paste this again and I'm going to allow it to write a summary of the event and I'm also going to add a field for description and we'll go to expression we'll paste again and here I'm
just going to type in description now let's go ahead and go back to the canvas and as you can see this create event tool is all set up this create event tool is going to be extremely useful for adding new events but the problem is this agent can't see our calendar yet it can only add events to the calendar with this tool the solution is creating another Google Calendar tool that can search throughout our calendar and find exactly what's happening so that it doesn't create any overlap in our calendar I'm just going to hit Plus
on tool again again go back to Google Calendar tool and I'm going to switch this resource to calendar and the operation is going to be for availability it's basically going to allow me to see if I have time slots available in my calendar I'm going to select my calendar Carter from the list and then again we're going to go to the expression I'm going to paste in that expression and this time we'll make it start time and this next one will be end time for the tool description let's set it manually and let's just say
this tool is for searching for available time slots in my calendar and then I'm going to go back to Canvas and now we have an agent that has two tools it can now create events and it can see our availability before this agent couldn't do anything but now it's going to have so much more opportunity with these tools that we've put in place but first now that we're getting into a more complex agent that needs to behave in a certain way this is where the prompting comes in and this is really one of those things
that's going to set you apart that's why again I recommend AI foundations because we teach the prompting we teach the foundations and then we teach you how to build agents with those foundations so let's click on AI agent here and we're going to give it a prompt I'm going to hit add option and I'm going to hit system message now this is the overall message that this agent is going to adhere to and it's good to keep these extremely simple that's my best advice is to keep it really simple and just to basically give it
its role and tell it the tools and when to use them just don't add too much convoluted information here there may be edge cases where you need to make a more complicated system message but often times it can just lead to poor agent performance so for this system message I'm going to say Your Role is my calendar assistant it's your job to add things to available time slots on my calendar the tools you have available will allow you to find empty time slots first then create new events once you've confirmed the time slot with me
so this is a very basic system message and we can test this as much as we want that's the beauty of seeing the executions and just messing around with the chat natively is I can see exactly what kind of workflows are going to work best for this agent let's click back to the canvas and now is the exciting part we can test this agent out and see if it can understand my calendar so I'm just going to hit chat and I'm going to say give me my available time slots for the rest of this month
let's see how it does so we see here that it searched for the availability and it says that I have no available time slots for the rest of the month this simply isn't true so let's go to the Google Calendar tab here and see what it did so the problem is it went and looked back in 2023 started the start and end time way back and of course the availability is false so this is a great lesson in creating AI agents they need to understand the time of day otherwise they're just going to take their
best guess so to fix this I'll go into my AI agent here and in the system message I'm just going to add some details I'm going to say today's date is I'll flip this to expression and it says anything inside of these brackets is Javascript so let's just hit learn more and we can see the different Expressions that are available here going to copy this information right here because I'm not that well versed in JavaScript if I'm honest this is the beauty of AI is we can use AI to help us build better AI systems
and what I'm trying to do is get a datetime variable that pulls back the current time whenever the system message is sent off so let's just go ahead and paste the documentation into an empty chat gpt1 and I'm just going to enter right above it I'm going to say here's the documentation on writing expressions with NN and I'm going to say I'd like you to create an expression in Brackets that prints the current date and time for Eastern Time Zone let's go ahead and send this off and it gives us this expression right here with
the brackets just as nadn had described it looks like it's just getting the date and time from now it's setting the time zone to Eastern and then it's properly formatting the date so that we can see what's going on so I'm going to hit copy code and we'll go ahead and paste this into our expression and as you can see down here the result is pulling through the current date and time for the Eastern Time Zone and it's on point so now I'll go back to my canvas and I'm going to say try now with
the new date and time update that gives you access to current date and time so this time the window buffer memory did pull through the correct date but it still isn't giving me the time slots here so it did put in the right query for for today's date all the way to the end of the month and my availability is still false let's try one more thing I'm going to go into the availability here for Google Calendar and we're going to add some options I'm going to include the output format and I'm also going to
include time zone I'll go ahead and select New York for the time zone or Eastern go with the US Eastern and then the output format these are the different output format so this one returns if there are any events in a given time or not this one Returns the booked slots and this one just Returns the raw data from the API I'm going to go with raw just so that it gets everything I want to give this as much as possible and I'm going to rename this because I haven't done that yet I'll go ahead
and just rename this to search availability and we'll hit rename now I'll go back to Canvas and I'll say try again I've tweaked your tools to get this to to work and give you all the info you need all right now we're working as you can see it just needed a different output format from Google Calendar it says here are your available time slots for the rest of January 2025 and it gives them all right here and if you go to search availability you can see the response right here it's giving all of the busy
dates so that it knows not to utilize those now let's go ahead and rename this one just before we do this I'll just call it create event and I'm going to go back to the chat here and I'm going to say great now schedule a meeting with Drake srat on the nearest available totally empty day anytime after noon so this time around we're going to see that it goes ahead and it creates an event because it had already gone through and searched for my availability it even gives me a link to click on the event
and see it from the URL this is pretty impressive it booked it from 12 to 1 on January 12th if I click on it it opens up that event right here in my calendar so the key takeaway is when you're working with a new API or you're working with a programming language that you're not so sure of one you can keep on testing even though this didn't work the first second and even third time I kept it going and I kept trying to figure out exactly why this wasn't pulling in the right information and I
also went and checked the data that was moving through the execution second I lean on AI whenever I needed it when I was trying to create that date time expression I had no idea where to start I could have went off and learned how to do that with JavaScript but instead the syntax was already created by chat GPT just for me now that we've created our calendar assistant it would be amazing if we could have it access all of our documents and search through those documents in an efficient way look no further than retrieval augmented
generation or rag for short retrieval augmented generation is pretty simple to set up with n8n first make sure that your workflow is saved if it's saved it'll say saved right here but if not you can click the orange save button then we'll click back to our overview from the overview we'll create a new workflow now this workflow is going to be for retrieving our documents and putting them into a nice embedding space so that the agent can search for them efficiently without using too much of its context window so we'll click on ADD First Step
I'll type in drive I'll go to onapp event and I'm going to scroll down to Google Drive we'll select the trigger on changes involving a specific folder and here we're going to set up the credentials so we'll go back to the console. cloud.google.com make sure you're on your n8n agent project if you haven't already created this when we did the calendar step you'll have to create that you can go back in the video to see how I did that and then this time we're going to go to the enabled apis and services I'll click on
enable apis and services and I'm going to type in drive now I'll select the Google Drive API and hit enable if you go to credentials you've already created your credentials here so you can just copy over the client ID hit select credential create new credential paste in the client ID here then we'll click on this little edit ooth button copy your client secret and then head over and paste this into the client secret area now we'll go ahead and copy the redirect URL and we'll add new one right here and you can paste that then
hit save now I'll try to sign in with Google click on the account that is going to be the Google Drive account where you store your files hit allow and it should say got connected the window can be closed now now head over to your Google Drive account hit new new folder and I'm just going to name my folder n8n hit create and now I'll navigate to that nadn folder now as a test document I'm going to be using my AA iterations workflow AA stands for eliminate automate delegate accelerate and this is just my protocol
for doing just that so I'll drag this in and when I click into it it should open up my PDF right here and I can see all of the information that I have inside of the AA protocol so now that our test is all set up I can close this setup module for the Google Drive account for mode we'll leave it at every minute and the trick is changes involving a specific folder we can select our folder from the list here by clicking and we can search for our folder name click it once you see
it and then where it says watch for we're going to click into here and we're going to select file created now I'll go ahead and fetch a test event and as you can see here it's pulling in that PDF that I created if I scroll through I can see all of the metadata related to this PDF now let's go back to our canvas so now that we have this trigger for when a new file gets created we can add another trigger to to download that file I'm just going to search for Drive click on Google
Drive download file everything here is good but you're just going to go to expression and make sure by ID is selected and then if you scroll through here you should be able to find the ID somewhere yep right here this is the ID so we're just going to drag that ID field into the file here and now it's going to dynamically pull the ID of the new created file let's go ahead and test the step and as you can see it went ahead and grabbed that file for us I'm going to go back to the
canvas and now you can see that we have this Google Drive automation all working so when a new file gets added to our folder it's going to download that file but this is where the real magic of rag comes in we're going to be turning that file into an embedding space that the model can understand and to do that we're going to be using pine cone. it allows you to create these Vector databases and they have a generous free plan I'm just going to hit sign up continue through and again and fill out their questions
here and it might generate an API key for you right away but I'm just going to close this for now click on database and here you'll be on the indexes tab from here you can just hit create index for the index name I'll just go with n8n and I'm going to go with text embedding three small scroll down just a bit here and you'll want to be on server list then you're just going to hit create index next we'll head over to API Keys create a new API key and I'm just going to call it
n8n then I'll hit create key and I'm going to copy this key I'll close this and we'll head back to n8n click the plus here and we're going to type in Pine Cone and you should see pine cone Vector store pop up click on that now we'll click on ADD documents to Vector store from here we'll click on credential create new credential and we'll paste our API key now I'll hit save and it should be a successful connection I'll close this the operation mode should be set to insert documents click on choose here and select
n8n that's the index that we created then I'll go ahead and head back to the canvas for the embedding we're going to click here we're going to go to embeddings open aai and it's important that you select the same model that you had in Pine Cone so we chose the text embedding three small so that's the one that I'll use here as well let's go back to Canvas and next we're going to add the document select the default data load we're going to switch the type of data to Binary and then from here we can
go back to the canvas now it wants a text splitter so you can hit the plus right there and just go with the recursive character text splitter click on that and for the recursive text splitter we're going to need to select a chunk size and a chunk overlap so when this information is getting added to your vector database it's going to be split into different chunk sizes and a chunk size is basically how many characters can fit inside of that chunk of text that it's slicing up it's more efficient for the agent to understand exactly
where the text is that it needs to read so that it doesn't have to search through the entire document that's why we're splitting it up into these chunks and then the chunk overlap is how many characters that these chunks can overlap with each other so that you don't lose context of previous chunks in the document for the chunk size I'm going to go with 500 and for the chunk overlap we'll go with 20 these are some good test settings for smaller files I'm going to go back to Canvas and now this is ready to go
so let's go ahead and test the workflow as you can see it sent 10 items through let's click into our pine cone Vector store and as you can see it's chunking down my AA document for me now the model is going to be able to find exactly what it's looking for let's turn this to active so that when new files are added it adds them to our embedding database I'm going to hit got it and I'm going to rename my workflow here we'll just call it drive to Pine Cone I'll head back to the overview
and now I'm going to go into our basic agent example and what we'll do now is we'll connect this agent to that pine cone database so that it can retrieve information so I'm going to give it a new tool I'm going to search for Vector store tool and I'll click on Vector store tool now we need to give the tool a name I'll call it retrieve files and for the description I'm going to go with a tool used to retrieve documents stored in the users Google Drive now we'll click on Vector store we'll click on
Pine Cone Vector store and we can leave this as retrieve documents from the list I'm just going to select n8n and then for the options here we'll go with pine cone namespace and if you remember right we added one called n8n I'll go back to my canvas now and that is good to go let's just get this a little bit more organized I'm going to go to the model right here and I'll select open AI chat model for this one we're just going to go with 40 mini that's perfectly fine I'll go back to my
canvas here and for the embedding drop down we're going to go with embeddings open AI I'm going to select the text embedding three small once again and we'll go back to the canvas now I'm going to hit save since I just did all of that work there and now let's test this out I'm just going to hit chat and I'm going to say what is the third step of of eada and it should return delegate and I'm going to actually tell it just because I haven't put this in the system prompt that it needs to
use the uh retrieval so I'll say use the retrieval of files tool to find this I'll send that off and as you can see it went down to this Vector store tool and it went through that process now if I scroll up here it says the third step of eada is delegate I'm going to say how do I properly delegate give me some examples this is the text that it gave me so choose the right person clearly Define the task provide necessary resources set a deadline allow autonomy be available for support and provide feedback it's
giving me some examples here but as you can see it didn't use the vector store tool so I'm just going to say okay use the retrieval tool again and make sure you give me my example examples and now it's using the retrieval tool and answering and if I scroll down here it's giving me the examples laundry hire a local service to handle washing and folding cooking use meal prep service or have prepared meals delivered graphic design these are all things that were in my AA document so if we go into the AA document as you
can see we go down to delegate all right and as you can see it pulled that information from delegate right here on the Second Step most tasks can be deleg ated here are some examples laundry cooking cold calling graphic design cleaning Fitness planning Etc so it did pull in these examples now what we've created here is an AI agent it has the autonomy to select its different tools here and it's able to create events in my calendar and search for availability in my calendar I also gave it special privileges to access my Google Drive database
in a clean concise way using rag next I'm going to show you how to create another workflow in na n that you can then use as a tool for your agent agents are best when you focus on just a few tasks for them to solve and then Outsource the more complex tasks to other workflows and other agents so what we'll do next is create another workflow in n8n and this workflow is going to be for generating images to do that I have to get an image somehow so how about having it be AI generated to
get my AI generated images and create another workflow that does that for me that this agent can call I'm going to go back to my overview I'll hit save and then we'll create another workflow this workflow we're going to call image generator we're going to go with when called by another workflow I'll click back to Canvas and this is going to allow us to trigger this workflow with the other one the tool that we're going to be using to generate our images is Black Forest Labs Lux this is going to allow us to generate some
pretty awesome images using AI so I'll go to the API tab here I'm going to create an account so it says visit this site here I'll enter that create our account or log in and once you've created your account and logged in it should look something like this you might not have an API key yet and you might not have credits loaded in yet so you can add credits using this button right here I'm just going to add a new API key and I'm going to call it nadn I'll hit create key and now I
can copy that nadn key next we're going to be using an HTTP request to access the flux model so I'll hit the plus button here I'll search for the HTTP request node and I'll drop that in then for the method I'm going to select post and for the URL you're going to paste in this right here api. bfl ml slv1 this is accessing the V1 of flux Pro so then it's slf flux D pro-11 make sure that that URL matches now we'll select send headers and for this first one here I'm going to typee in
content-type then for the value I'm going to type in application sljs we'll add another parameter here this one's just going to be X key and then you're going to paste your API key into here so I'll copy that from Black Forest labs and I'll paste it into the value now we're going to select send body and make sure it's on Json using Fields below for this one we'll type in prompt and I'll enter a test prompt for now I'm just going to type in a water fall in a Serene landscape and now we'll test this
step and it should return an ID this ID is the task ID for that generation so now we can go back to Canvas click the plus button here and type in wait and you should see this weight module click on it and here we can set the weight amount and the weight unit I'll just select minutes and I'll make the weight unit 2 minutes just for extra measure I'm not sure how long it will take to generate the image but I'll go back to the canvas and this HTTP request right here is the one that's
posting the request to get the image so we're going to rename it to request New Image so when this is executed it's going to request a new image it's going to wait for a moment while that image is being processed so we'll duplicate this request image now so that we don't have to do this over again and I'll connect the weight module to it now this isn't going to be requesting the image so we're we going to change the method to get and flu-pro d1.1 we're going to change to getor result we can turn send
body off and then scroll up to your url add a question mark type in ID equals and then we'll head back over to our request new image and we should have an image ID in there I can copy this and I'm just going to paste it in here for testing purposes now we'll click back to the canvas I'm going to DEA activate the weight for now and I'll go ahead and test the workflow to see if we can get this image that we tested out all right so let's see what it returned as you can
see here we get this URL so let's copy this and see what we get I'm just going to paste it and search it and as you can see we got our beautiful Serene landscape with a nice waterfall so we'll return the sample URL when this workflow is finished I'm going to go back to the canvas and I'll actually rename this as well to get new image I'll hit rename name and then we're going to click into here again there's one more thing I forgot to do we actually have to replace this test ID with the
actual ID so get rid of that test ID go back to input request new image and just click and drag on this ID field over to the equal sign and as you can see it's now an expression and it should look something like this now we'll go back to the canvas and I will reactivate this waiting period now we'll head back over to the overview tab make sure to save and then I'll jump back into our basic agent example I'll add a tool and we're going to use the call n8n workflow tool I'll call this
tool generate image and I'll say call this tool to generate and receive an image and I'll say You must give it a prompt to generate the image simply describe the image for for the prompt and for the workflow we're going to select image generator now we'll head back to the canvas and we're going to send through some test data it won't actually generate the image this time around but we want to see if we can get some information sent through so I'm just going to hit chat and I'm just going to say generate an image
of a bunny in a field send that off and as you can see it tried to call our tool here the reason that it's taking a while right now is because it's actually generating that image in the background and it's waiting for that sleep period if you wanted to deactivate that weight module and restart this test you could do that as well but I'm just going to let it run through all right so once that loads up some test data like this it shouldn't have actually ran through this successfully but it did make it through
so here's what it input the query was a cute bunny sitting in a lush green field surrounded by colorful wild flowers under a clear blue sky so it actually did create the prompt for us now we're going to close this we're going to go back to our overview hit save and now we'll go into the image generator now go to executions click on the most recent execution double click into execute workflow trigger and we should see the query that we sent through I'm just going to hit copy I'll click back to Canvas editor and now
I'm just going to drag this out a bit and click the plus button between the executive workflow trigger and my first request I'll just hit the plus and and I'm going to type in open and you should see open AI I'll click on that and now I'm going to message a model now this model is actually going to turn my query into a structured Json response so it's going to take whatever my model inputs and it's going to turn it into something that the API that we created can understand so all that the API needs
in this case is a prompt so that means we only need to pass over one Json object but you could do this with as many objects as you want so if the API that you're using required a prompt and an aspect ratio you could send both of those over using this method that's why I find this method to be so reliable so we'll go ahead and choose a model for this I'm just going to go with 40 mini I'll change the RO to system so that I can give it some instructions and I'm just going
to say you specialize in turning queries into a structured prompt output and outputting your response in Json I'm going to give it an example I'm going to say the user response looks like this here's an example and then I'm going to paste in that example of the query that we copied there now I'm going to say output a Json object of whatever is inside of the query parameter and then I'll add an example output and for this example output we can just copy this query right here paste it in I'll change the name to prompt
and it already has our field in there that we want so that looks good to go this is how I want it to Output then I'll scroll down and we'll click output content as Json and I'm going to test this step and it did output The Prompt and it's right here now I'll go back to the canvas I'll double click into the post request and here you should change your input to open Ai and from here you can drag this prompt variable in so if you remember right we set our prompt down here originally but
we're just going to delete that value and we're going to drag in prompt now that's dynamically going to pull in the prompt that's sent over from our other agent let's go back to the canvas now there was one step that I forgot to add here and that is actually to add the message under here so I did go through and I improved my system prompt because I wasn't happy with the results but that shouldn't matter the issue was that I didn't add a message down here for the user this means that it was just sending
across a blank query so it was only getting the system prompt with nothing from the other agent so what we need to do is we need to add a message but in order to pull this data over we need to go back to our example here but in order to pull that over we need to generate another example so while we're generating the example I'll go ahead and deactivate the weight once more I'll go back to the overview hit save so we'll go back into our basic agent example from here I can have it generate
an image I'll say generate an image of a delicious Naples Pizza so it calls our image generation tool once again so as you can see the delicious Naples Pizza didn't make it over to the image generator so it brought back an error image this is fine we're just going to go back to the overview hit save click into the image generator go to executions and our latest execution should be here let's just click on execute workflow trigger and then we should see our query parameter here I'm just going to copy it go back to Canvas
go back to the editor and then we're going to double click back into our execute workflow trigger and we're going to set some mock data here I'm going to paste in the mock data and I'll hit save now it should say this data is pinned so now I can go into the open Ai and I can go down and hit add message and here I can drag in the the query now let's go ahead and test the step and it should pull through this query here so as you can see it put that in the
prompt so now that we've added this parameter right here we can go back to the canvas double click into here and unpin the test data I'm going to go back to Canvas and now let's double click in and see if we still have our json. query and we do perfect back to Canvas back to the overview hit save we'll go into the basic agent example and I'll click the chat button and from here I'm going to say generate an image of a flamingo on the moon and it should actually return this image this time so
we see that it's calling the tool again I'm going to wait for it to come back with the image and just like that we've received our glorious image of a flamingo on the moon so this has been the NAD beginners crash course if you want to learn more about n an and jump on Q&A calls to get help I highly recommend joining AI foundations using the link below and check out this other useful video that I thought you might find helpful
Related Videos
Perplexity Full Tutorial: WILD Ai Research Tool! (A-Z Guide)
24:57
Perplexity Full Tutorial: WILD Ai Research...
Productive Dude
19,132 views
Build Everything with AI Agents: Here's How
39:58
Build Everything with AI Agents: Here's How
David Ondrej
81,971 views
Anthropic Revealed Secrets to Building Powerful Agents
19:06
Anthropic Revealed Secrets to Building Pow...
Matthew Berman
132,302 views
The BEST (and easiest) Tutorial To Learn n8n - RAG AI Agents And Vector Database
28:56
The BEST (and easiest) Tutorial To Learn n...
Kirk Artman
2,243 views
EVERYTHING You Need to Create an AI Voice Agent
1:02:39
EVERYTHING You Need to Create an AI Voice ...
AI WAVE
3,182 views
Flowise + n8n - The BEST No Code + Local AI Agent Combo
29:12
Flowise + n8n - The BEST No Code + Local A...
Cole Medin
33,810 views
Gutfeld! 1/16/25 FULL END SHOW | FOX BREAKING NEWS TRUMP January 16, 2025
33:21
Gutfeld! 1/16/25 FULL END SHOW | FOX BREAK...
sevginin sofrasi
347,298 views
Vertical AI Agents Could Be 10X Bigger Than SaaS
42:13
Vertical AI Agents Could Be 10X Bigger Tha...
Y Combinator
574,913 views
7 Fantastic Ai Tools for Productivity! *Late 2024*
27:16
7 Fantastic Ai Tools for Productivity! *La...
Productive Dude
23,230 views
How To Use AI Agents To Do ALL Your Work - Full CrewAI Course for Beginners
2:16:59
How To Use AI Agents To Do ALL Your Work -...
Tyler AI
28,463 views
n8n Masterclass: Build AI Agents & Automate Workflows (Beginner to Pro)
1:31:43
n8n Masterclass: Build AI Agents & Automat...
Nate Herk | AI Automation
74,303 views
Turn ANY Website into LLM Knowledge in SECONDS
18:44
Turn ANY Website into LLM Knowledge in SEC...
Cole Medin
77,676 views
Andrew Ng Explores The Rise Of AI Agents And Agentic Reasoning | BUILD 2024 Keynote
26:52
Andrew Ng Explores The Rise Of AI Agents A...
Snowflake Inc.
439,571 views
Build Anything with Claude Agents, Here’s How
18:35
Build Anything with Claude Agents, Here’s How
David Ondrej
254,994 views
The Ultimate n8n Guide: From Beginner to Pro AI Agent Builder
2:32:10
The Ultimate n8n Guide: From Beginner to P...
AI Workshop
17,383 views
ADVANCED Python AI Agent Tutorial - Using RAG, Langflow & Multi-Agents
48:08
ADVANCED Python AI Agent Tutorial - Using ...
Tech With Tim
61,810 views
Anthropic’s Blueprint for Building Lean, Powerful AI Agents
28:25
Anthropic’s Blueprint for Building Lean, P...
Prompt Engineering
35,179 views
Essential AI Coding Fundamentals I wish I knew sooner (ChatGPT, Cursor AI, v0)
59:20
Essential AI Coding Fundamentals I wish I ...
Greg Isenberg
56,326 views
Building AI Agents: Chat Trigger, Memory, and System/User Messages Explained [Part 1]
20:16
Building AI Agents: Chat Trigger, Memory, ...
n8n
13,230 views
Step-by-Step Tutorial: Create a RAG Chatbot with n8n AI Agents in MINUTES
22:42
Step-by-Step Tutorial: Create a RAG Chatbo...
Leon van Zyl
44,873 views
Copyright © 2025. Made with ♥ in London by YTScribe.com