3 AI Workflows Step-by-Step (Beginner's Guide to n8n)

Dr. Violet Howard builds three AI workflows in n8n: a RAG chatbot that answers questions about documents stored in Pinecone, an automated email responder that uses Gmail and policy data to reply to customers, and a daily LinkedIn post generator that searches the web and uses Claude to write posts from a Google Sheet.
Chapters
Today we're going to be looking at 3 simple AI workflows that you can build right now to get started learning N8N. We're going to walk through everything step by step, including all of the credentials and the setups. So let's take a look at the 3 workflows we're going to be building today. All right, the first one is going to be a RAG pipeline and chatbot. And if you don't know what RAG means, don't worry, we're going to explain it all. But at a high level, what we're doing is we're going to be using Pinecone as a vector database. If you don't know what a vector database is, we'll break it down. We're going to be using Google Drive, we're going to be using Google Docs, and then something called OpenRouter. Which lets us connect to a bunch of different AI models like OpenAI's models or Anthropic's models. The second workflow we're gonna look at is a customer support workflow that's kind of gonna be building off of the first one we just built. Because in the first workflow, we're gonna be putting data into a Pinecone vector database. And in this one, we're gonna use that data in there in order to respond to customer support related emails. So we'll already have had Pinecone set up, but we're gonna set up our credentials for Gmail. And then we're also gonna be using an N8N AI agent as well as OpenRouter once again. And then finally, we're gonna be doing LinkedIn content creation. And in this one, we'll be using an N8N AI agent and OpenRouter once again, but we'll have two new credentials to set up. The first one being Tavily, which is gonna let us search the web. And then the second one will be Google Sheets, where we're going to store our content ideas, pull them in, and then have the content written back to that Google Sheet. So by the end of this video, you're gonna have three workflows set up, and you're gonna have a really good foundation to continue to learn more about N8N. You'll already have gotten a lot of credentials set up and understand what goes into connecting to different services, one of the trickiest being Google. So we'll walk through that step by step, and then you'll have it configured and you'll be good. And then from there, you'll be able to continuously build on top of these 3 workflows that we're gonna walk through together, because there's really no such thing as a finished product in this space. Different AI models keep getting released and keep getting better. There's always ways to improve your templates. And the cool thing about building workflows in N8N is that you can make 'em super customized for exactly what you're looking for. So if this sounds good to you, let's hop into that first workflow. Okay, so for this first workflow, we're building a RAG pipeline and chatbot. And so if that sounds like a bunch of gibberish to you, let's quickly understand what RAG is and what a vector database is. So RAG stands for Retrieval Augmented Generation. And in the simplest terms, let's say you ask me a question and I don't actually know the answer. I would just kind of Google it and then I would get the answer from my phone and then I would tell you the answer. So in this case, when we're building a RAG chatbot, we're going to be asking the chatbot questions and it's not going to know the answer. So it's going to look inside our vector database, find the answer, and then it's going to respond to us. And so when we're combining the elements of RAG with a vector database, here's how it works. So the first thing we want to talk about is actually what is a vector database. So essentially this is what a vector database would look like. We're all familiar with like an X and Y axis graph where you can plot points on there on a two-dimensional plane. But a vector database is a multidimensional graph of points. So in this case, you can see this multidimensional space with all these different points or vectors. And each vector is placed based on the actual meaning of the word or words in the vector. So over here you can see we have wolf, dog, and cat, and they're placed similarly because the meaning of these words are all like animals. Whereas over here we have apple and banana, which the meaning of the words are food, more likely fruits. and that's why they're placed over here together. So when we're searching through the database, we basically vectorize a question the same way we would vectorize any of these other points. And in this case, we were asking for a kitten, and then that query gets placed over here near the other animals. And then we're able to say, okay, well, we have all these results now. So what that looks like and what we'll see when we get into N8n is we have a document that we want to vectorize. We have to split the document up into chunks because we can't put like a 50-page PDF as one chunk. So it gets split up and then we're gonna run it through something called an embeddings model, which basically just turns text into numbers, just as simple as that. And as you can see in this case, let's say we had a document about company, we have company data, finance data, and marketing data, and they all get placed differently because they mean different things and the, the context of those chunks are different. And then this visual down here is just kind of how an LLM, or in this case, this agent takes our question, turns it into its own question, we vectorize that using the same embeddings model that we used up here to vectorize the original data. And then because it gets placed here, it just grabs back any vectors that are nearest, maybe like the nearest 4 or 5, and then it brings it back in order to respond to us. So don't want to dive too much into this, don't want to overcomplicate it, but hopefully this all makes sense. Cool. So now that we understand that, let's actually start building this workflow. So what we're going to do here is we are going to click on Add First Step. Because every workflow needs a trigger that basically starts the workflow. So I'm gonna type in Google Drive because what we're gonna do is we are going to pull in a document from our Google Drive in order to vectorize it. So I'm gonna choose a trigger, which is on changes involving a specific folder. And what we have to do now is connect our account. As you can see, I'm already connected, but what we're gonna do is click on create new credential in order to connect our Google Drive account. And what we have to do is go get a client ID and a secret. So what we want to do is click on Open Docs, which is going to bring us to N8N's documents on how to set up this credential. We have a prerequisite, which is creating a Google Cloud account. So I'm going to click on Google Cloud account and we're going to set up a new project. Okay, so I just signed into a new account and I'm going to set up a whole project and walk through the credentials with you guys. You'll click up here. You'll probably have something up here that says like New Project, and then you'll click into New Project. All we have to do now is name it and you'll be able to start for free, so don't worry about that yet. So I'm just going to name this one Demo. And I'm going to create this new project. And now up here in the top right, you're going to see that it's kind of spinning up this project, and then we'll move forward. Okay, so it's already done, and now I can select this project. So now you can see up here I'm in my new project called Demo. I'm going to click on these three lines in the top left, and what we're going to do first is go to APIs and Services and click on Enabled APIs and Services. And what we want to do is add the ones we need. And so right now, all I'm going to do is add Google Drive, and you can see it's gonna come up with Google Drive API. And then all we have to do is really simply click Enable, and there we go. I just enabled it, so you can see here the status is enabled. And now we have to set up something called our OAuth consent screen, which basically is just going to let N8N know that Google Drive and N8N are allowed to talk to each other and have permissions. So right here, I'm gonna click on OAuth consent screen. We don't have one yet, so I'm gonna click on Get Started. I'm going to give it a name, so we're just going to call this one Demo. Once again, I'm going to add a support email. I'm going to click on Next. Because I'm not using a Google Workspace account, I'm just using a, you know, natehurk88@gmail.com, I'm going to have to choose External. I'm going to click on Next. For contact information, I'm putting the same email as I used to create this whole project. Click on Next and then Agree to Terms, and then we're going to create that OAuth consent screen. Okay, so we're not done yet. The next thing we want to do is we want to click on Audience. And we're going to add ourselves as a test user. So we could also make the app published by publishing it right here, but I'm just going to keep it in test. And when we keep it in test mode, we have to add a test user. So I'm going to put in that same email from before, and this is going to be the email of the Google Drive we want to access. So I put in my email, you can see I saved it down here. And then finally, all we need to do is come back into here, go to Clients, and then we need to create a new client. We're going to click on Web App. We're gonna name it whatever we want. Of course, I'm just gonna call this one demo once again. And now we need to basically add a redirect URI. So if you click back into NN, we have one right here. So we're gonna copy this, go back into Cloud, and we're gonna add a URI and paste it right in there, and then hit create. And then once that's created, it's gonna give us an ID and a secret. So all we have to do is copy the ID, go back into NN, and paste that right here. And then we need to go grab our secret from Google Cloud and then paste that right in there. And now we have a little button that says Sign in with Google. So I'm going to open that up. It's going to pull up a window to have you sign in. Make sure you sign in with the same account that you just had yourself as a test user, that one. And then you'll have to continue. And then here is basically saying like, what permissions do we have— does Anydone have to your Google Drive? So I'm just going to select all. I'm going to hit continue, and then we should be good. Connection successful. And we And we are now connected. And you may just want to rename this credential so you know, you know, which email it is. So now I've saved my credential and we should be able to access the Google Drive now. So what I'm going to do is I'm going to click on this list and it's going to show me the folders that I have in Google Drive. So that's awesome. Now for the sake of this video, I'm in my Google Drive and I'm going to create a new folder. So new folder, we're going to call this one FAQ. Create this one because we're going to be uploading an FAQ document into it. So here's my FAQ folder right here. And then what I have is down here, I made a policy and FAQ document, which looks like this. We have some store policies and then we also have some FAQs at the bottom. So all I'm gonna do is I'm gonna drag in my policy and FAQ document into that new FAQ folder. And then if we come into N8N, we click on the new folder that we just made. So it's not here yet. I'm just gonna click on these dots and click on refresh list. Now we should see the FAQ folder. There it is. Click on it. We're gonna click on what are we watching this folder for? I'm gonna be watching for a file created, and then I'm just gonna hit fetch test event. And now we can see that we did in fact get something back. So let's make sure this is the right one. Yep. So there's a lot of nasty information coming through. I'm gonna switch over here on the right-hand side. This is where we can see the output of every node. I'm gonna click on table and I'm just gonna scroll over and there should be a, a field called Filename. Here it is, name, and we have policy and FAQ document, so we know we have the right document in our Google Drive. Okay, so perfect. Every time we drop in a new file into that Google folder, it's going to start this workflow. And now we just have to configure what happens after the workflow starts. So all we want to do really is we want to pull this data into n8n so that we can put it into our Pinecone database. So off of this trigger, I'm going to add a new node and I'm going to grab another Google Drive node. Because what happened is basically we have the file ID and the file name, but we don't have the contents of the file. So we're gonna do a download file node from Google Drive. I'm gonna rename this one and just call it download file just to keep ourselves organized. We already have our credential connected, and now it's basically saying, what file do you wanna download? We have the ability to choose from a list, but if we choose from the list, it's gonna be this file every time we run the workflow, and we wanna make this dynamic. So we're going to change from list to by ID. And all we have to do now is we're going to look on the left-hand side for that file that we just pulled in. And we're going to be looking for the ID of the file. So I can see that I found it right down here in the spaces array, because we have the name right here, and then we have the ID right above it. So I'm going to drag ID, put it right there in this folder. It's coming through as a variable called JSON.ID. And that's just basically referencing, you know, whenever a file comes through, on the, the Google Drive trigger, I'm gonna use the variable JSON.ID, which will always pull in the file's ID. So then I'm gonna hit test step and we're gonna see that we're gonna get the binary data of this file over here that we could download. And this is our policy and FAQ document. Okay, so there's step 2. We have the file downloaded in NNEN, and now it's just as simple as putting it into Pinecone. So before we do that, let's head over to pinecone.io. Okay, so now we are in pinecone.io, which is a vector database provider. You can get started for free. And what we're going to do is sign up. Okay, so I just got logged in. And once you get signed up, you should see a page similar to this. It's a get started page. And what we want to do is you want to come down here and click on, you know, begin setup because we need to create an index. So I'm going to click on begin setup. We have to name our index. So you can call this whatever you want. We have to choose a configuration for a text model. We have to choose a configuration for an embeddings model, which is sort of what I talked about right in here. This is gonna turn our text chunks into a vector. So what I'm gonna do is I'm going to choose text embedding 3 small from OpenAI. It's the most cost-effective OpenAI embedding model. So I'm gonna choose that. Then I'm gonna keep scrolling down. I'm gonna keep mine as serverless. I'm gonna keep AWS as the cloud provider. I'm gonna keep this region. And then all I'm gonna do is hit create index. Once you create your index, it'll show up right here, but we're not done yet. You're gonna click into that index. And so I already obviously have stuff in my vector database. You won't have this. What I'm gonna do real quick is just delete this information out of it. Okay, so this is what yours should look like. There's nothing in here yet. We have no namespaces and we need to get this configured. So on the left-hand side, go over here to API keys and you're going to create a new API key. Name it whatever you want, of course. Hit create key and then you're going to copy that value. Okay, back in n8n, we have our API key copied. We're going to add a new node after the download file. And we're going to type in Pinecone and we're going to grab a Pinecone vector store. Then we're going to select add documents to a vector store and we need to set up our credential. So up here you won't have these and you're going to click on create new credential. And all we need to do here is just an API key. We don't have to get a client ID or a secret. So you're just going to paste in that API key. Once that's pasted in there and you've given it a name so you know what this means, you'll hit save and it should go green and we're connected to Pinecone. And you can make sure that you're connected by clicking on the index, and you should have the name of index right there that we just created. So I'm gonna go ahead and choose my index. I'm going to click on add option, and we're gonna be basically adding this to a Pinecone namespace, which back in here in Pinecone, if I go back into my database, my index, and I click into here, you can see that we have something called namespaces. And this basically lets us put data into different folders within this one index. So if you don't specify an index, it'll just come through as default, and that's gonna be fine. But we want to get into the habit of having our data organized. So I'm going to go back into AnyThen, and I'm just going to name this namespace FAQ because that's the type of data we're putting in. And now I'm going to click out of this node. So you can see the next thing that we need to do is connect an embeddings model and a document loader. So let's start with the embeddings model. I'm going to click on the plus, and I'm going to click on Embeddings OpenAI. And actually, this is one thing I left out of the Excalidraw is that we also will need to go get an OpenAI key. So as you can see, when we need to connect a credential, you'll click on Create New Credential, and we just need to get an API key. So you're going to type in OpenAI API. You'll click on this first link here. If you don't have an account yet, you'll sign in. And then once you sign up, you want to go to your dashboard. And then on the left-hand side, very similar thing to Pinecone, you'll click on API keys. And then we're just going to create a new key. So you can see I have a lot. We're going to make a new one, and I'm calling everything demo, but this is going to be demo number 3. Create a new secret key. And then we have our key. So we're going to copy this and we're going to go back into NN, paste that right here. We paste it in our key. We've given it a name and now we'll hit save and we should go green. Just keep in mind that you may need to top up your account with a few credits in order for you to actually be able to run this model. So just keep that in mind. So then what's really important to remember is when we set up our Pinecone index, we use the embedding model text embedding 3 small from OpenAI. So that's why we have to make sure this matches right here. Or this automation is going to break. Okay, so we're good with the embeddings, and now we need to add a document loader. So I'm going to click on this plus right here. I'm going to click on default data loader, and we have to just basically tell Pinecone the type of data we're putting in. And so you have two options, JSON or binary. In this case, it's really easy because we downloaded a Google Doc, which is on the left-hand side. You can tell it's binary because up top right here on the input, we can switch between JSON and and binary. And if we were uploading JSON, all we'd be uploading is this gibberish nonsense information that we don't need. We want to upload the binary, which is the actual policy and FAQ document. So I'm just going to switch this to binary. I'm going to click out of here. And then the last thing we need to do is add a text splitter. So this is where I was talking about back in this Excalidraw, we have to split the document into different chunks. And so that's what we're doing here with this text splitter. I'm going to choose a recursive character text splitter. There's 3 options and I won't dive into the difference right now, but Recursive Character Text Splitter will help us keep context of the whole document as a whole, even though we're splitting it up. So for now, chunk size is 1,000. That's just basically how many characters am I going to put in each chunk? And then is there going to be any overlap between our chunks of characters? So right now I'm just going to leave it default 1,000 and 0. So that's it. You just built your first automation for a RAG pipeline. And now we're just going to click on the play button above the Pinecone Vector Store node. In order to see it get vectorized. So we're gonna basically see that we have 4 items that have left this node. So this is basically telling us that our Google Doc that we downloaded right here, so this document got turned into 4 different vectors. So if I click into the text splitter, we can see we have 4 different responses, and this is the contents that went into each chunk. So we can just verify this by heading real quick into Pinecone. We can see we have a new namespace that we created called FAQ, Number of records is 4. And if we head over to the browser, we can see that we do indeed have these 4 vectors. And then the text field right here, as you can see, are the characters that were put into each chunk. Okay, so that was the first part of this workflow, but we're gonna real quick just make sure that this actually works. So we're gonna add a RAG chatbot. Okay, so what I'm gonna do now is hit the tab, or I could also have just clicked on the plus button right here, and I'm gonna type in AI agent, and that is what we're gonna grab and pull into this workflow. So we have an AI agent and let's actually just put him right over here. And now what we need to do is we need to set up how are we actually going to talk to this agent. And we're just going to use the default N8N chat window. So once again, I'm going to hit tab. I'm going to type in chat and we have a chat trigger. And all I'm going to do is over here, I'm going to grab the plus and I'm going to drag it into the front of the AI agent. So basically now whenever we hit open chat and we talk right here, the agent will read that chat message. And we know this because if I click into the agent, we can see the user message is looking for one in the connected chat trigger node, which we have right here connected. Okay, so the first step with an AI agent is we need to give it a brain. So we need to give it some sort of AI model to use. So we're going to click on the plus right below chat model. And what we could do now is we could set up an OpenAI chat model because we already have our API key from OpenAI. But what I want to do is click on OpenRouter because this is going to allow us to choose from all different chat models, not just OpenAI's. So we could do Claude, we could do Google, we could do Perplexity. We have all these different models in here, which is going to be really cool. And in order to get an OpenRouter account, all you have to do is go sign up and get an API key. So you'll click on create new credential and you can see we need an API key. So you'll head over to openrouter.ai. You'll sign up for an account. And then all you have to do is in the top right, you're going to click on keys. And then once again, kind of the same as all the other ones, you're going to create a new key. You're going to give it a name. You're going to click create. You have a secret key. You're going to click copy. And then when we go back into NN and paste it in here, give it a name and then hit save. And we should go green. We've connected to OpenRouter. And now we have access to any of these different chat models. So in this case, let's use, let's use Claude 3.5 Sonnet. And this is just to show you guys you can connect to different ones. But anyways, now we can click on Open Chat. And actually, let me make sure you guys can see him. If we say hello, it's going to use its brain, Claude 3.5 Sonnet, and now it responded to us. Hi there, how can I help you? So just to validate that our information is indeed in the Pinecone vector store, we're going to click on a tool under the agent. We're going to type in Pinecone and grab a Pinecone vector store. and we're gonna grab the account that we just selected. So this was the demo I just made. We're gonna give it a name. So in this case, I'm just gonna say Knowledge Base. We're gonna give a description, call this tool to access the policy and FAQ database. So we're basically just describing to the agent what this tool does and when to use it. And then we have to select the index and the namespace for it to look inside of. So the index is easy. We only have one. It's called sample. But now this is important because if you don't give it the right namespace, it won't find the right information. So we called ours FAQ. If you remember in our Pinecone, we have a namespace and we have FAQ right here. So that's why we're doing FAQ. And now it's going to be looking in the right spot. So before we can chat with it, we have to add an embeddings model to our Pinecone vector store, which same thing as before, we're going to grab OpenAI and we're going to use embedding-3-small. And the same credential you just made. And now we're gonna be good to go to chat with our RAG agent. So looking back in the document, we can see we have some different stuff. So I'm gonna ask this chatbot what the warranty policy is. So I'm gonna open up the chat window and say, what is our warranty policy? Send that off, and we should see that it's going to use its brain as well as the vector store in order to create an answer for us because it didn't know by itself. So there we go, just finished up, and it said, Based on the information from our knowledge base, here's the warranty policy. We have 1-year standard coverage. We have, you know, this email for claims processes. You must provide proof of purchase. And for warranty exclusions that aren't covered, damage due to misuse, water damage, blah, blah, blah. Back into policy documentation, we can see that that is exactly what we have in our knowledge base for warranty policy. So just because I don't want this video to go too long, I'm not gonna do more tests, but this is where you could get in there and make sure it's working. One thing to keep in mind is within the agent, we didn't give it a system prompt. And what a system prompt is, is just basically a message that tells the agent how to do its job. So what you could do is if you're having issues here, you could say, you know, like, this is the name of our tool, which is called Knowledge Base. You could tell the agent in its system prompt, hey, like, your job is to help users answer questions about the, you know, our policy database. You have a tool called Knowledge Base. You need to use that in order to help them answer their questions. and that will help you refine the behavior of how this agent acts. All right, so the next one that we're doing is a customer support workflow. And as always, you have to figure out what is the trigger for my workflow. In this case, it's gonna be triggered by a new email received. So I'm gonna click on Add First Step. I'm gonna type in Gmail, grab that node, and we have a trigger which is on message received right here, and we're gonna click on that. So what we have to do now is obviously authorize ourselves. So we're gonna click on Create New Credential right here. and all we have to do here is use OAuth 2.0. So all you have to do is click on Sign In, but before we can do that, we have to come over to our Google Cloud once again, and now we have to make sure we enable the Gmail API. So we'll click on Gmail API, and it'll be really simple. We'll just have to click on Enable, and now we should be able to do that OAuth connection and actually sign in. You'll click on the account that you want to access the Gmail, you'll give it access to everything, click Continue, and then we're going to be connected, as you can see. And then you want to name this credential as always. Okay, so now we're using our new credential, and what I'm gonna do is if I hit Fetch Test Event, so now we are seeing an email that I just got in this inbox, which in this case was, NNN Cloud was granted access to your Google account, blah, blah, blah. So that's what we just got. Okay, so I just sent myself a different email, and I'm gonna fetch that email now from this inbox, and we can see that the snippet says, what is the privacy policy? I'm concerned about my data and passwords. And what we wanna do is we wanna turn off simplify, because what this button is doing is it's gonna take the content of the email and basically, you know, cut it off. So in this case, it didn't matter, but if you're getting long emails, it's gonna cut off some of the email. So if we turn off simplify, fetch test event once again, we're now gonna get a lot more information about this email, but we're still gonna be able to access the actual content, which is right here. We have the text, "What is privacy policy? I'm concerned about my data and passwords. Thank you." And then you can see we have other data too, like what the subject was, who the email is coming from, what their name is, all this kind of stuff. But the idea here is that we are going to be creating a workflow where if someone sends an email to this inbox right here, we are going to automatically look up the customer support policy and respond back to them so we don't have to. Okay, so the first thing I'm actually gonna do is pin this data just so we can keep it here for testing, which basically means whenever we rerun this, it's not gonna go look in our inbox. It's just gonna keep this email that we pulled in, which helps us for testing, right? Okay, cool. So the next step here is we need to have AI basically filter to see, is this email customer support related? If yes, then we're gonna have a response written. If no, we're gonna do nothing. Because maybe the use case would be, okay, we're gonna give an agent access to an inbox where we're only getting customer support emails. But sometimes maybe that's not the case. And let's just say we wanted to create this as sort of like an inbox manager, which we could route off to different logic based on the type of email. So that's what we're gonna do here. So I'm gonna click on the plus after the Gmail trigger, and I'm gonna search for a text classifier node. And what this does is it's gonna use AI to read the incoming email and then determine what type of email it is. So because we're using AI, the first thing we have to do is connect a chat model. We already have our OpenRouter credential set up, so I'm gonna choose that. I'm gonna choose the credential, and then I'm, for this one, let's just keep it with 4o Mini. And now this AI node actually has AI. And I'm gonna click into the text classifier, and the first thing we see is that there's a text to classify. So all we want to do here is we want to grab the actual content of the email. So I'm gonna scroll down. I can see here's the text, which is the email content. We're gonna drag that into this field. And now every time a new email comes through, the text classifier is going to be able to read it because we put in a variable which basically represents the content of the email. So now that it has that, it still doesn't know what to classify it as or what its options are. So we're gonna click on add category. The first category is going to be customer support, and then basically we need to give it a description of what a customer support email could look like. So I wanted to keep this one simple. It's pretty vague, but you could make this more detailed, of course. And I just said an email that's related to helping out a customer. They may be asking questions about our policies or questions about our products or services. And what we can do is we can give it specific examples of like, here are some past customer support emails and here's what they've looked like, and that will make this thing more accurate. But in this case, that's all we're gonna do. And then I'm gonna add one more category that's just going to be other. And then for now, I'm just gonna say any email that is not customer support related. Okay, cool. So now when we click out of here, we can see we have two different branches coming off of this node, which means when the text classifier decides, it's either gonna send it off this branch or it's gonna send it down this branch. So let's quickly hit play. It's gonna be reading the email, using its brain, and now you can see it has output it in the customer support branch. We can also verify by clicking into here and we can see customer support branch has 1 item and other branch has no items. And just to keep ourselves organized, right now I'm gonna click on the other branch and I'm just gonna add an operation that says do nothing just so we can see, you know, what would happen if it went this way for now. But now is where we want to configure the logic of having an agent be able to read the email, hit the vector database to get relevant information, and then help us write an email. So I'm gonna click on the plus after the customer support branch. I'm gonna grab an AI agent. So this is gonna be very similar to the way we set up our AI agent in the previous workflow. So it's kind of building on top of each other. And this time, if you remember in the previous one, we were talking to it with a connected chat trigger node. And as you can see here, we don't have a connected chat trigger node. So the first thing we wanna do is change that. We wanna define below. And this is where you would think, okay, what do we actually want the agent to read? We want it to read the email. So I'm gonna do the exact same thing as before. I'm gonna go into the Gmail trigger node, scroll all the way down until we can find the actual email content, which is right here, and just drag that right in. That's all we're gonna do. And then we definitely wanna add a system message for this agent. We are going to open up the system message, and I'm just going to click on expression so I can expand this up full screen. And we're gonna write a system prompt. Again, for the sake of the video, keeping this prompt really concise, but if you wanna learn more about prompting, then definitely check out my community's links down below, as well as this video up here. And all the other tutorials on my channel. But anyways, what we said here is we gave it an overview and instructions. The overview says you are a customer support agent for Tech Haven. Your job is to respond to incoming emails with relevant information using your knowledge base tool. And so when we do hook up our Pinecone vector database, we're just going to make sure to call it knowledge base because that's what the agent thinks it has access to. And then for the instructions, I said your output should be friendly and use emojis and always sign off as Mr. Helpful from Tech Haven Solutions. And then one more thing I forgot to do actually is we want to tell it what to actually output. So if we didn't tell it, it would probably output like a subject and a body. But what's going to happen is we're going to reply to the incoming email. We're not going to create a new one, so we don't need a subject. So I'm just going to say output only the body content of the email. So then we'll give it a try and see what that prompt looks like. We may have to come back and refine it, but for now we're good. And as you know, we have to connect a chat model and then we have to connect our Pinecone. So first of all, chat model, we're going to use OpenRouter. And just to show you guys, we can use a different type of model here. Let's use something else. Okay, so we're going to go with Google Gemini 2.0 Flash. And then we need to add the Pinecone database. So I'm going to click on the plus under tool. I'm going to search for Pinecone Vector Store, grab that. And we have the operation is going to be retrieving documents as a tool for an AI agent. We're going to call this Knowledge, capital B, Base. And we're going to once again just say, call this tool to access policy and FAQ information. We need to set up the index as well as the namespace. So sample, and then we're going to call the namespace, you know, FAQ, because that's what it's called in our Pinecone right here, as you can see. And then we just need to add our embeddings model and we should be good to go with which is embeddings OpenAI text embedding 3 small. So we're going to hit the play above the AI agent and it's going to be reading the email. As you can see, once again, the prompt user message, it's reading the email. What is the privacy policy? I'm concerned about my data and my passwords. Thank you. So we're going to hit the play above the agent. We're going to watch it use its brain. We're going to watch it call the vector store and we got an error. Okay. So I'm getting this error, right? And it says provider returned error. And it's weird because basically why it's erroring is because of our, our chat model. And it's, it's weird because it goes green, right? So anyways, what I would do here is if you're experiencing that error, it means there's something wrong with your key. So I would go reset it, but for now, I'm just going to show you the quick fix. I can connect to an OpenAI chat model real quick, and I can run this here, and we should be good to go. So now it's going to actually write the email and output. Super weird error, but I'm honestly glad I caught that on camera to show you guys in case you face that issue. Because it could be frustrating. We should be able to look at the actual output, which is, hey there, thank you for your concern about privacy policy. At Tech Haven, we take your data protection seriously. So then it gives us a quick summary with data collection, data protection, cookies. If we clicked into here and went to the privacy policy, we could see that it is in fact correct. And then it also was friendly and used emojis like we told it to right here in the system prompt. And finally, it signed off as Mr. Helpful from Tech Haven Solutions, also like we told it to. So we're almost done here. The last thing we want to do is we want to have it actually reply to this person that triggered the whole workflow. So we're going to click on the plus, we're going to type in Gmail, grab a Gmail node, and we're going to do reply to a message. Once we open up this node, we already know that we have it connected because we did that earlier. We need to configure the message ID, the message type, and the message. And so all I'm going to do is, first of all, email type, I'm going to do text for For the message ID, I'm gonna go all the way down to the Gmail trigger, and we have an ID right here. This is the ID we want to put into the message ID so that it responds in line on Gmail rather than creating a new thread. And then for the message, we're gonna just drag in the output from the agent that we just had write the message. So I'm gonna grab this output, put it right there, and now you can see this is how it's going to respond in email. And the last thing I want to do is I want to click on Add Option. Append N8N Attribution, and then just check that off. So then at the bottom of the email, it doesn't say this was sent by N8N. So finally, we'll hit this test step. We will see we get a success message that the email was sent, and I'll head over to the email to show you guys. Okay, so here it is. This is the one that we sent off to that inbox, and then this is the one that we just got back. As you can see, it's in the same thread, and it has basically the privacy policy outlined for us. Cool, so that's workflow number 2. Couple of ways we could make this even better. One thing we could do is we could add a node right here, and this would be another Gmail one, and we could basically add a label to this email. So if I grab add label to message, we would do the exact same thing. We'd grab the message ID the same way we grabbed it earlier. So now it has the message ID of the label to actually create. And then we would just basically be able to select the label we want to give it. So in this case, we could give it the customer support label. We hit test step, we'll get another success message. And then in our inbox, if we refresh, we will see that that just got labeled as customer support. So you could add on more functionality like that, and you could also down here create more sections. So we could have finance, you know, a logic built out for finance emails. We could have logic built out for all these other types of emails and plug them into different knowledge bases as well. So let's move on to the third and final workflow for today. Okay, so the third one we're going to do is a LinkedIn content creator workflow. So what we're gonna do here is click on Add First Step, of course. And ideally, you know, in production, what this workflow would look like is a schedule trigger. You know, so what you could do is basically say every day I want this thing to run at 7:00 AM. That way I'm always gonna have a LinkedIn post ready for me at, you know, 7:30. I'll post it every single day. And if you wanted it to actually be automatic, you'd have to flick this workflow from inactive to active. And you know, now it says, um, your schedule trigger will now trigger executions on the schedule you have defined. So now it would be working, but for the sake of this video, we're going to turn that off and we're just going to be using a manual trigger just so we can show how this works. Um, but it's the same concept, right? It would just start the workflow. So what we're going to do from here is we're going to connect a Google Sheet. So I'm going to grab a Google Sheet node. I'm going to click on Get Rows in Sheet, and we have to create our credential once again. So we're going to create new credential. We're going to be able to do OAuth2 sign in, but we're going to have to go back to Google Cloud and we're and we're gonna have to grab a sheet and make sure that we have the Google Sheets API enabled. So we'll come in here, we'll click enable, and now once this is good to go, we'll be able to sign in using OAuth 2. So very similar to what we just had to do for Gmail in that previous workflow, but now we can sign in. So once again, choosing my email, allowing it to have access, and then we're connected successfully, and then giving this a good name. And now what we can do is choose the document and the sheet that it's gonna be pulling from. So I'm gonna show you, I have one called LinkedIn Posts, and I only have one sheet, but let's show you the sheet real quick. So LinkedIn posts, what we have is a topic, a status, and a content. And we're just basically going to be pulling in one row where the status equals to-do, and then we are going to create the content, upload it back in right here, and then we're going to change the status to created. So then this same row doesn't get pulled in every day. So how this is going to work is that we're going to create a filter. So the first filter is going to be looking within the status column, and it has to equal to do. And if we click on test step, we should see that we're going to get like all of these items where there's a bunch of topics, but we don't want that. We only want to get the first row. So at the bottom here, add option, I'm going to say return only first matching row, check that on. We'll test this again. And now we're only going to be getting that top row to create content on. Cool. So we have our first step here, which is just getting the content from the Google Sheet. Now what we're gonna do is we need to do some web search on this topic in order to create that content. So I'm gonna add a new node. This one's gonna be called an HTTP request. So we're gonna be making a request to a specific API, and in this case, we're gonna be using Tavly's API. So go on over to tavly.com and create a free account. You're gonna get 1,000 searches for free per month. Okay, here we are in my account. I'm on the free researcher plan, which gives me 1,000 free credits. and right here I'm gonna add an API key. We're gonna name it, create a key, and we are going to copy this value. And so you'll start to get to the point when you connect to different services, you always need to have some sort of like token or API key. But anyways, we're gonna grab this in a sec. What we need to do now is go to the documentation that we see right here. We're gonna click on API reference, and now we have right here, this is gonna be the API that we need to use in order to search the web. So I'm not gonna really dive into like everything about HTTP requests right now. I'm just gonna show you the simple way that we can get this set up. So first thing that we're gonna do is we obviously see that we're using an endpoint called Tavelly search, and we can see it's a POST request, which is different than like a GET request. And we have all these different things we need to configure, and it can be confusing. So all we wanna do is on the top right, we see this curl command. We are gonna click on the copy button. We're gonna go back into our n8n, hit import curl, paste in the curl command, hit import, And now the whole node magically just basically filled in itself. So that's really awesome. And now we can sort of break down what's going on. So for every HTTP request, you have to have some sort of method. Typically when you're sending over data to a service, which in this case we're going to be sending over data to Tavelly, it's going to search the web and then bring data back to us. That's a POST request because we're sending over body data. If we were just like kind of trying to hit an end, if we were just trying to access like, you know, bestbuy.com and we just wanted to scrape the information, that could just be a simple GET request because we're not sending anything over. Anyways, then we're gonna have some sort of base URL and endpoint, which is right here. The base URL we're hitting is api.com/tabelly, and then the endpoint we're hitting is /search. So back in the documentation, you can see right here we have /search, but if we were doing like an extract, we would do /extract. So that's how you can kind of see the difference with the endpoints. And then we have a few more things to configure. The first one, of course, is our authorization. So in this case, we're doing it through a header parameter. As you can see right here, the curl command set it up. Basically, all we have to do is replace this token with our API key from Tably. So I'm going to go back here, copy that key. In n8n, I'm going to get rid of token and just make sure that you have a space after the word bearer. And then you can paste in your token. And now we are connected to Tavily, but we need to configure our request before we send it off. So right here are the parameters within our body request, and I'm not going to dive too deep into it. You can go to the documentation if you want to understand, like, you know, the main thing really is the query, which is what we're searching for. But we have other things like the topic. It can be general or news. We have search depth. We have max results. We have a time range. We have all this kind of stuff. Right now, I'm just going to leave everything here. As default, we're only gonna be getting one result and we're gonna be doing a general topic. We're gonna be doing basic search. But right now, if we hit test step, we should see that this is gonna work, but it's gonna be searching for who is Leo Messi. And here is sort of like the answer we get back as well as a URL. So this is an actual website we could go to about Lionel Messi and then some content from that website, right? So we are going to change this to an expression so that we can put a variable in here rather than just a static hardcoded who is Leo Messi. We'll delete that query and all we're going to do is just pull in our topic. So I'm just going to simply pull in the topic of AI image generation. Obviously it's a variable right here, but this is the result. And then we're going to test step and this should basically pull back an article about AI image generation. And, you know, so here is a deep AI, um, link. We'll go to it and we can see this is an AI image generator. So maybe this isn't exactly what we're looking for. What we could do is basically just say like, You know, we could hardcode in search the web for, and now it's going to be saying search the web for AI image generation. We could come in here and say, yeah, actually, you know, let's get 3 results, not just 1. And then now we could test that step and we're going to be getting a little bit different of a search result. Um, AI image generation uses text descriptions to create unique visuals. And then now you can see we got 3 different URLs rather than just 1. Anyways, so that's our web search. And now that we have a web search based on our defined topic, We just need to write that content. So I'm going to click on the plus. I'm going to grab an AI agent. And once again, we're not giving it the connected chat trigger node to look at. That's nowhere to be found. We're going to feed in the research that was just done by Tavily. So I'm going to click on expression to open this up. I'm going to say article 1 with a colon, and I'm just going to drag in the content from article 1. I'm going to say article 2 with a colon. And just drag in the content from Article 2. And then I'm gonna say Article 3 colon and just drag in the content from the third article. So now it's looking at all 3 article contents. And now we just need to give it a system prompt on how to write a LinkedIn post. So open this up, click on Add Option, click on System Message, and now let's give it a prompt about turning these 3 articles into a LinkedIn post. Okay, so I'm heading over to my custom GPT for Prompt Architect. If you want to access this, you can get it for free by joining my free school community. You'll join that, it's linked in the description, and then you can just search for Prompt Architect and you should find the link. Anyways, real quick, it's just asking for some clarification questions. So anyways, I'm just shooting off a quick reply and now it should basically be generating our system prompt for us. So I'll check in when this is done. Okay, so here is the system prompt. I am going to just paste it in here and I'm just going to, you know, disclaimer, this is not perfect at all. Like I don't even want this tool section at all because we don't have a tool hooked up to this agent. We're obviously just going to give it a chat model real quick. So in this case, what I'm going to do is I'm going to use Claude 3.5 Sonnet, just because I really like the way that it writes content. So I'm using Claude through OpenRouter. And now let's give it a run and we'll just see what the output looks like. I'll just click into here while it's running and we should see that it's going to read those articles and then we'll get some sort of LinkedIn post back. Okay, so here it is. The creative revolution is here and it's AI powered. Gone are the days of hiring expensive designers or struggling with complex software. Today's entrepreneurs can transform ideas into stunning visuals instantly using AI image generators. So as you can see, we have a few emojis, we have some relevant hashtags, and then at the end it also said this post, you know, it kind of explains why it made this post. We could easily get rid of that if all we want is the content. We would just have to throw that in the system prompt. But now that we have the post that we want, all we have to do is send it back into our Google Sheet. And update that it was actually made. So we're going to grab another Sheets node. We're going to do Update Row in Sheet, and this one's a little different. It's not just, um, grabbing stuff from a row. We're trying to update stuff. So we have to say what document we want, what sheet we want. Now it's asking us what column do we want to match on. So basically I'm going to choose Topic, and all we have to do is go all the way back down to the sheet. We're going to choose the Topic and drag it in right here, which is basically saying, okay, When this node gets called, whenever the topic equals AI image generation, which is a variable, obviously whatever, whatever topic triggered the workflow is what's gonna pop up here. We're gonna update that status. So back in the sheets, we can see that the status is currently to do, and we need to change it to created in order for it to go green. So I'm just gonna type in created, and obviously you have to spell this correctly the same way you have it in your Google Sheets. And then for the content, all I'm gonna do is we're just gonna drag in the output. Of the AI agent. And as you can see, it's gonna be spitting out the result. And now if I hit test step and we go back into the sheet, we'll basically watch this change. Now it's created, and now we have the content of our LinkedIn post as well, with some justification for why it created the post like this. And so like I said, you could basically have this be some sort of, you know, LinkedIn content making machine where every day it's gonna run at 7:00 AM, it's gonna give you a post. And then what you could do also is you can automate this part of it where you're basically having it create a few new rows every day. If you give it a certain sort of like general topic to create topics on, and then every day you can just have more and more pumping out. So that is gonna do it for our third and final workflow. Okay, so that's gonna do it for this video. I hope that it was helpful. You know, obviously we connected to a ton of different credentials and a ton of different services. We even made an HTTP request to an API called Tavaly. Now, if you found this helpful and you liked this sort of live step-by-step style, and you're also looking to accelerate your journey with n8n and AI automations, I would definitely recommend to check out my paid community. The link for that is down in the description. There are a ton of great resources on YouTube and you can definitely learn through tutorials like that, but having a community of members who are kind of going through the same thing as you is really gonna help, especially when you run into little issues, sort of like the one we saw earlier in this video. It's just gonna really help when you can come in here and ask questions that have been answered millions of times. Like if in this community, if I type in solved, you're gonna see there's, you know, hundreds of things that we have talked about and problems that people have had. And now, you know, we basically have the solves for all of them right here. So on top of that, we have 5 live calls per week to make sure you're never getting stuck, as well as a classroom section with different topics like intro to AI automation, building agents, vector databases, APIs, and HTTP requests, step-by-step builds, all this kind of stuff. So I'd really love to see you guys in here. Love to see you on the live calls. And I appreciate you guys making it to the end of the video. As always, If you learned something new or you appreciated it, please give it a like. It definitely helps me out a ton, and I'll see you all in the next one. Thanks so much, everyone.










