Loading video player...
NAN is an open source workflow automation platform that lets you connect different apps, APIs
and services to easily automate tasks without needing to implement extensive code. This
course is designed to take you from a beginner to a capable developer harnessing
NAN's power to build sophisticated real world solutions. Gavin Law developed this course.
He starts by discussing essential internet standards like REST and OAuth 2 that make secure
integrations possible setting the foundation for your automation journey. You learn the practical steps
of setting up in a in and then dive into four comprehensive workflow examples, including
an AI powered chat bot and an emergency of WhatsApp notification system. Gavin will
guide you step by step through creating these solutions, demonstrating how to seamlessly
integrate diverse services like WhatsApp, Google Sheets and AI agents.
Hi and welcome everyone, I'm Gavin Lon. I'm a software developer with decades of experience
and I'm really excited to bring you this video on N8n. We are going to
dive into the exciting world of workflow creation using the N8n tool. So,
what is N8n? Basically, N8n is an open source workflow automation platform
that lets you connect different apps, APIs and services together in order to
automate tasks. I've sometimes heard the process of creating NA10
workflows referred to as flowgramming. When creating the workflows for this video, I found it
interesting how the thought process in implementing some of the logic for the workflows was
practically the same when comparing it to the process of implementing code and programming. If
conditions, loops, separation of concerns, abstraction, concepts, with which most
programmers are familiar. But using NA10, you can create some extremely powerful
solutions without implementing any code or with minimal code. You are able to integrate complex
code into your workflows where your requirements demands more fine-grained functionality. We'll take a
brief look at this towards the end of the video. In this video, we'll create
four workflow examples using the NA10 tool step-by-step in order to create real-world
solutions that will not rely on the use of code. When I first started working
with N8n, I had this surge of creative ideas erupt in my head, and I'm
hoping that by going through this video, it will have the same effect on you.
I have to say, I think N8n is an amazing tool. Although I must warn
you, my first reaction
was... But
Once that megalomaniacal energy subsided in me, I started to think of what, in my
opinion, are some potentially useful automation ideas. So the first workflow example we'll
create, and perhaps the least useful idea of all the examples we'll look at in
this video, is a chatbot powered by ChatDpt that provides the user with a list
of ranked items based on the user's prompt. So for example, you could ask the
chatbot, what are the top five movies of all time? And it will answer you
within seconds. Or what are the largest mammals on earth? You know, questions of that
nature. So perhaps more fun than useful, but I think this example provides us with
a good introduction to N8N workflows and how we can harness the power of AI
in our workflows. I'll later show you how you can integrate WhatsApp into this workflow
so that you can interact with your chatbot via WhatsApp. So you could be out
with your friends and someone asks, hey guys, What do you think are the fastest
five cars on earth? With access to your workflow through WhatsApp, you can now eagerly
whip out your phone and be the WhatsApp know-it-all guy and answer your friend's question
immediately. In doing so, really impress your friends. Everyone loves the WhatsApp know-it-all
guy. Perhaps it's not such a good idea to be that guy. Right, moving on.
The second example is a bit more serious and involves using WhatsApp to execute an
emergency request for assistance at your physical address. I've called it the WhatsApp panic app.
So for example, if your home is being burglarized at 2am, you can simply trigger
a workflow using WhatsApp from your phone, which will then read relevant information like your
physical address from a Google spreadsheet and send a notification containing your address information
to a person on duty who can then dispatch trained responders to your address to
handle the emergency situation. You can probably tell from my accent that I'm originally from
South Africa. I've spent a lot of time in the UK, but my formative years
were spent in South Africa. Now South Africa is a wonderful, beautiful country with a
tremendous amount of potential. However, it unfortunately suffers from extremely high levels of crime.
Those that can afford it mostly have private security, but those that can't afford private
security are actually the ones that are most vulnerable to the high levels of crime.
Of course, Many parts of the world are affected by high crime levels. So this
is a workflow that could be useful in many parts of the world. So even
though not everyone can afford private security, I think most people these days can afford
a smartphone and data. So I thought of a cheap solution where those who can't
afford private security and perhaps live in informal settlements can use WhatsApp for sending emergency
notifications. So if, for example, a person's home is being burglarized or the person feels
under threat, for any reason, the person affected can use WhatsApp by sending, for example,
the number one. It doesn't have to be an actual message. Writing a message is
time consuming and this is an emergency. So the number one is sent to a
designated community WhatsApp number to request emergency responders to attend the user's
address to provide assistance. The panic message triggers our workflow and a panic
notification is sent to a designated person on duty who then dispatches a response team
to the address of the person who sent the panic message. The first part of
this WhatsApp panic app is a workflow that involves community members registering over the
internet to use the WhatsApp panic app. So this workflow is very simple. The user
fills in a form containing the user's WhatsApp number and relevant details like full name
and address. Once the information is submitted, the next step in the workflow is invoked,
which saves the user's information to a row in a specific Google spreadsheet. The WhatsApp
number uniquely identifies the user on the spreadsheet. The second workflow in the WhatsApp Panic
application is where the user sends the number one to a specific WhatsApp number that
has been set up to receive panic notifications. The first node in our workflow is
a WhatsApp trigger node, and this node triggers the execution of the workflow immediately after
the user sends the panic notification. The next step in the workflow looks up the
registered user on the relevant Google spreadsheet and identifies the user through the user's WhatsApp
number. The user's address details are then read from the spreadsheet and the panic notification
is sent to the person on duty for the area in which the user resides.
The person on duty can then dispatch responders to the user's address in order to
appropriately handle the situation. The next idea I came up with is a little bit
more complex. So this workflow automates the processing of CVs or resumes of people
applying for a senior C-sharp developer position in a software solution company. This
workflow involves the CVs or resumes being put into a designated Google Drive folder. The
next step involves all of the file names and unique IDs of those files being
read into a list. A loop step is created so that each CV can be
dealt with individually. The significance of including a loop in the workflow is that this
workflow involves the concept of a human in the loop. So a CV being processed
in the loop is downloaded by the next step and the subsequent step reads the
downloaded PDF files content from binary into text format. The text format is then
fed into an AI agent along with an appropriate prompt that prompts the AI agent
to summarize the applicant's CV in a specific way. So the summary of the CV
is customized so as to make the human in the loop part more efficient. So
the human in the loop can at a glance judge whether the applicant is suitable
for the first round interview or not. So the summary of the CV is sent
via email to the person in charge of the interview process. This person can then
either approve the application or decline the application via two buttons that are present within
the relevant email. So the workflow at this point pauses and won't resume until the
relevant person, the human in the loop, either clicks the approve button or the decline
button. If the approve button is clicked, the workflow resumes processing, and an AI agent
is subsequently used to schedule an interview with the approved applicant on the interviewer's Google
Calendar. If the decline button is clicked, the workflow resumes processing, but the AI agent
used for scheduling the interview is bypassed. when an applicant is declined and then the
next iteration in the loop is executed. So the next CV is then processed. So
if there are eight CVs in the relevant Google Drive folder, then eight iterations of
the loop will be executed denoting eight CVs appropriately being processed. So this
workflow automates the approval process for a first round interview and each applicant that is
approved is scheduled for the interview on the interviewers Google Calendar. So once we've
completed the creation of these workflow examples, at the end of the video, I'll show
you some cool ideas in less detail pertaining to what can be achieved in your
workflows. My hope is that this video stimulates you to think of some cool automation
ideas for your own workflows. It would be great if you could share some of
your ideas in the comment section, but perhaps keep those billion dollar ideas close to
your chest. Engineering is all about standards. The N8N tool
relies on certain internet-based standards for disparate entities on the web to securely communicate with
one another and for the disparate entities to work together in a workflow. For example,
N8N needs to firstly have appropriate permissions to, for example, send an email from within
a workflow via a Gmail account. So this can be facilitated using the OAuth2
standard through providing a valid client ID and valid client secret. The
REST standard is widely used for interacting with web APIs. REST emphasizes
simplicity, scalability, and uniformity by using standard web protocols and formats,
often JSON or XML, for data exchange. Standards like REST and OAuth2
make engineering a lot more efficient than if such standards didn't exist. Without these standards,
engineers would potentially be recreating similar protocols with each new project in order to enable
disparate components to communicate with one another. This is, of course, not very practical or
economical. If, however, certain communication standards are known universally, the
engineer can simply make use of the appropriate standards, like REST or OAuth2, within the
relevant project. when facilitating the secure communication of one disparate entity with another disparate
entity. So with these established standards like REST or OAuth2, one disparate entity,
like for example, a web API hosted in Japan, can securely communicate with another entity,
for example, a web API component hosted somewhere in the United States. So let's say
these two entities were engineered separately at different times and independently from one another. Two
independent teams of developers, that have never met, created these two Web API
components that are now hosted with a geographically vast distance between them. Yet one
component or entity if you like can communicate with the other component and make use
of that component services over the internet. It's almost like magic, but universally recognized
established standards adhered to by both independent teams are the reason why this is possible.
Standards like these, for example OAuth 2 and REST, are the underlying reason why a
tool like N8N can facilitate complex functionality where the developer doesn't need to know the
complexities of the underlying standards. This is abstracted away, and therefore the developer can
concentrate on the business rules of the workflow that the developer wishes to create. This
allows the developer to create sophisticated workflows made up of independent entities represented by nodes
on a canvas. These entities hosted independently, potentially vast, distances from one another
can securely communicate with one another using established standards. So to create a workflow, the
developer does not have to worry about certain underlying complexities. So basically N8n
provides an easy to use graphical user interface where a developer can automate complex tasks
by simply connecting nodes together in a specific sequence called a workflow. So going back
to the WhatsApp panic app example, we have a WhatsApp trigger node, that is connected
to a Google Sheets node that is connected to another Google Sheets node that is
lastly connected to a Gmail send a message node. Each node represents a step in
the workflow. The workflow represents the automation of a task. The task is to dispatch
responders to a user's physical address following the user sending a panic notification
via WhatsApp to a designated WhatsApp number. The seamless integration of diverse services like WhatsApp
and Google within a single workflow is made possible by the interoperability standards such as
REST and OAuth2. So having at least a basic knowledge of how REST and OAuth2
work is definitely beneficial. I created this video a few years ago for my YouTube
channel and it may be helpful to you with your understanding of OAuth 2.0. So
please check out this video if you'd like to see a basic explanation of how
OAuth 2.0 works. The link is in the description of this video. Right, let's get
started. Let's set up N8n so that it can be hosted on Hostinger. So in
this video, we are using Hostinger's self-hosting model for our N8n workflows, which
means you host N8n yourself through the provider, which makes the installation of
N8n much easier. In short, we are using the VPS virtual private server
hosting option for NA10 self-hosting model with a pre-configured NA10 template.
I'll briefly guide you through the signup and installation of NA10 on Hostinger so you
can host your NA10 workflows on Hostinger. You'll see it's very straightforward and easy to
do. Once we are set up to use NA10 hosted on Hostinger, we'll build four
workflows together step by step. So let's start by navigating to this URL.
Then choose your plan.
Configure your payment period, for example, for one month, 12 months or 24 months.
Configure your hosting options like geographic location and operating system.
Log in and provide your billing details.
unchecked malware scanner at this stage and clicked the finish setup button.
Then it takes about five minutes to install and set up N8n on Hostinger and
you are able to leave at this point and you can be notified via email
when N8n is set up appropriately.
Then you can click the manage VPS button like this.
skipped this bit.
Then on the same line or row of the NA10 label here, click the manage
app button like this.
Then set up your owner account and choose an appropriate password. that you'll
need when you log on to use N8N in the future. Then you can customize
N8N.
Great. And now you're ready to create an N8N workflow. As you'll see at
this point, my Chrome browser is using a light theme, but I subsequently chose a
dark theme for Chrome before I created our first workflow. Please note,
you have access to many N8N templates, and you can check those out by clicking
this templates menu option here.
It's great. So let's get into it. Let's create our first workflow.
Okay, so let's create our first example. What we're going to do here is we're
going to create a folder to house our examples. You can see I've got loads
of workflows I've been creating in preparation for this course. So let's start by
organizing all our new workflows into our own folder. And you can
do that using this facility here. So click this arrow down
icon here and then create folder. And I'm just going to call this my work.
workflows like that. Okay, create. We've got a my workflows folder. Let's go into that
folder. Nothing in my workflows yet. So let's create something
and we can do that by hitting this create workflow button here. So let's do
that. Let's hit the create workflow button and we're presented with the canvas here
and we're going to create our first example, which is just a chat bot, which
when we prompt the LLM, that we're going to use in our chatbot, it returns
an output of a list of items that we request. For example, a list of
ranked national rugby teams, the top five best national rugby teams or the top
five best movies of all time. So that's what this chatbot is going to be
all about. So it's a very simple example to get us going, just to get
us started. And to start this workflow, usually what we first do is we
click this plus icon and we add a trigger. So each workflow has to start
with a trigger. For example, you could trigger it manually just by clicking the node
and then it would trigger your workflow. Or a webhook call, so you could
kick off this workflow from an external source using HTTP. You could call the relevant
URL for a webhook that we create within our N8N workflow and it would kick
off the workflow. and we could pass various parameters to our workflow and that sort
of thing. And then an on submission form where we will actually look at this
in a little bit later. And you can create, for example, a registration form where
the user enters loads of information about the user and presses a submit button. And
then that information can get captured on a Google spreadsheet or a database table or
whatever. So each workflow must start off with a trigger. And the trigger that I'm
going to use here is the OnChat message. But we can actually add this by
default by just adding an AI agent node. The AI agent node enables us to
create this chatbot functionality that we're going to create here. So I'm going to do
a search for the AI agent node. And let's click on this option here.
And you can see here we're presented with a really great user interface.
provides you with a really good UX user experience because you've got the incoming data.
It's very intuitive. You have the incoming data, you've got the actual node itself, which
processes the incoming data, and then you've got the output, which will be presented to
us when you click, for example, the execute step button here. But if we press
an execute step button here, Now, for example, nothing's going to happen because you can
see here that this prompt will use the message field is grayed out because we
haven't yet generated any user input. So that will be the first thing that we
do. So let's actually go back to the canvas here. And now this is what
I wanted to show you. We've got our trigger node that has already been added
by default. It's connected to the left hand side of our AI agent here. so
you can see that it's very intuitive you can see the flow in action just
by looking at the canvas here when chat message received so we create the chat
message which becomes our prompt for the ai agent that input is connected here
so the input flows in the direction to the right to the ai agent and
you can see here it's trying to by default capture json dot chat input in
this JavaScript expression. Yeah, you can tell that this is a JavaScript expression because it's
wrapped in double curly braces here. And we got $json.chat input, but we don't have
any input. It says no input data yet, which means we haven't got any data
to work with at the moment. So if we press execute step, it's not going
to do anything. That's actually gone red because nothing has happened. There's no input data.
It's grayed out here. So that's the first thing we're going to do. We're going
to generate some input And by default, we've actually got this facility that we can
work with here to add our prompt to the web that will get captured by
the web by the when chat message received trigger node. So I'm going to
prompt, or I'm going to enter some input, which is basically the prompt for the
AI agent. What are the best? Sorry, what are the top
top five best national rug
the teams. And let's see what happens. Okay, chat model
subnode must be connected and enabled. You see, we've got this connector here and it's
labeled chat model. And when we press it, you see this panel shoots out from
the right of our screens here because we can now actually add a chat model
to our agent. This agent basically doesn't have a brain at the moment. It's just
a node and it won't do anything. But one thing that we do have here,
if we go in there, we've actually got some data to work with. Now, you
can see the JSON.ChatInput expression is now green, which means it's picking up what we've
entered into our chat input field here. So we could actually execute a step, but
it still won't work. ChatModel subnode must be connected and enabled. So let's go back
to the canvas. Let's click the chat model. So you can see that's labeled chat
model. And it's got a red star there, meaning it's required for our agents
to perform or to function. We
do need to attach a model, a relevant LLM. So let's press
that plus icon here. And then the panel shoots out from the right of our
screens. And you could add an Anthropic chat model, Azure OpenAI chat model,
AWS Bedrock chat model, whatever chat model you want, DeepSeek chat model, Google
Gemini chat model. But we want to add, we're going to add the
OpenAI chat model. So we can actually perform a search for it, OpenAI chat
model, and we can just attach that model to the AI agent. And you can
see here on the canvas, it's attached that subnode, AI, OpenAI Chat Model to
our AI agent. So we are giving it a brain here. So now let's go
into our OpenAI Chat Model here. And you can see I've actually created credentials here.
I've created a few of them here already. So that's why it's picking everything up.
It's picked up GPT 4.1 mini, which is the LLM that I want. You can
see we've got a wide selection of LLMs we can choose from, but I want
to select GPT 4.1 mini because that suits our purposes here.
So let's go back to the canvas here and let's go into AI agent. And
we now have a brain for our AI
agent, but let's go into our open AI chat model. And you can see here,
I've got credentials set up already, which means I can connect to the
relevant LLM, the relevant chat model, from made available
to us through OpenAI. But if you haven't set up any credentials, to
access this third party functionality provided by OpenAI, you will need to create
credentials. And this is how you do it. So let's go through the process of
how you would add credentials to this particular OpenAI chat model.
Here, this chat model node, you would go to the credential to connect with field
here, you click the drop down and click create new credential like that. And you
can see how we've got API key, it's got a red star next to it,
which means it's a required field. And so we need to insert a valid API
key here in order to use the relevant LLM, the GPT mini, the GPT for
mini LLM that we want to use in our agent node in our AI agent
node. So let's go to open AI.
So let's go to Google here and just type in open AI. And we're going
to set up a credential for open AI. And it's this one that we want
here. We want open AI.com here. So let's
click that. And then it's defaulted us to chat GPT. So we could use chat
GPT for free here. But that's not what we want. In this particular case, we
need to go to this login button here. And we want to go to the
AI platform. Okay, and I've been already logged on
because I've created an account. If you haven't yet created an account, you need to
create an account with OpenAI. So when you sign up, it will ask you to
spend a minimum of $5 and that will give you $5 worth of credits that
you can use to interact with OpenAI. So you can't really get around that. There
used to be a free tier. There's not a free tier available at the moment.
Each call to OpenAI diminishes your credits by a tiny amount. So it does
give you a lot of available functionality. And then the next step is we go
to this dashboard, header option here, and we create our
API key by clicking, firstly clicking this API keys option here.
Great. And you can see I've already created three. API keys. So let's create another
one. This is how you do it. You go create new secret key like that.
And then let's name it. So my API key, I'm just gonna say
in a in here. And then you press the create secret key
button here, and it generates your key. And then you won't if you go out
of this dialogue, you won't see this API key again. So what you want to
do is copy it to your clipboard, then go back to N8N here and then
paste it in here. And then you click the Save button. Okay, and you can
see here it's been successful. So we can now successfully interact with OpenAI
through our OpenAI chat model here, which is GPT 4.1 mini.
Excellent. So we can go back to the canvas here. Let's go to our AI
agent. And we can now actually execute this step because we've inputted our prompt here
and it's remembered our prompt and it's available to us through this JSON data here
and you can see this field chat input which has been added here by default
JSON.chat input so it's picking that value up there and we can actually that will
go through now to our GPT 4.1 mini model
because we've set it up to do so in our canvas here we've added the
OpenAI chat model to our AI agent here so now we can actually execute
this step here and you can execute it from here just for for a test
and our prompt is what are the top five best national rugby teams and let's
hit the execute step button here and see what we get
okay human what are the top five best national rugby teams and the output. As
of the most recent rankings and general performance in international rugby, the top five national
rugby teams are often considered to be New Zealand rugby. And you can see here,
it's got a lot of blurbs surrounding the actual list. And we actually just want
the list. We don't want all this fluffy blurb coming from the prompt. We just
want the list. So how can we specify that we just want the list and
we don't want all the surrounding blurbs? So we just want Return from this prompt,
New Zealand, South Africa, England, Ireland, France. Not all this other blurb. So to
do that, we can add a system prompt. You'll notice how we have a panel
in the center of our screens where we can customize settings and parameters for our
target node, which in this case is the AI agent node. So for example, we
can configure this field marked prompt user message to prompt our AI agent.
We can toggle this switch here, marked required specific output format to the on position,
which means we can specify a specific output format for our AI agent instead of
the output provided by default, which would simply be the response outputted by whichever AI
model we choose as the brain, as it were, for our AI agent. Importantly, we
have this execute step button here on the top right, which allows us to execute
our node or this step in the workflow at this point. By clicking this execute
step button, we've actually executed our basic functionality here. But what our problem is
here is that it's outputting the output format that we've got here is too fluffy,
there's too much fluff there, we want to trim it down to just the list
items, just the names of the rugby teams. So to do that, we can actually
augment the prompt by adding a system prompt or a system message. So let's discuss
the difference between the user prompt and the system prompt. So the user prompt can
be described as the input or question the end user provides to the LLM. So
our question here is which are the top five best national rugby teams? The purpose
of the user prompt is to directly tell the model what the user wants, whether
that's a question, instruction or request. So here we are asking the model to rank
the world's national rugby teams. and give us the top five world national rugby teams.
A system prompt provides hidden instructions to the LLM by the system or developer before
the user interacts with it. The purpose of the system prompt is to set the
model's behavior, personality, style rules, and boundaries. So how can we add a
system prompt so that we can make the output from our language model more concise
So it just lists the national teams and doesn't waste tokens. Remember each token comes
at a cost. So we want to be more economical with our tokens. We can
add a system prompt by clicking the add option button here, going to system message.
And then we have this input box here that we can utilize in order to
add our system prompt. So I just want to enlarge that a little bit so
you can see it on the screen. Okay, so we can actually format this in
Markdown, which makes it a lot easier for us to read us as the developer
to read. So let's add a header with in Markdown format says,
hash hash role. So we're going to add a role header here, we're basically going
to tell the AI agent what its role is, we're going to define its role.
So let's type you are a help full
assistant that provides
concise ranking lists
to the user in response to user
questions. So that is its role and we're defining it here within the system message.
This is the system prompt. Okay, let's press the enter key. And the next thing
I want to do is provide our AI agent with instructions. So
let's create an instruction section in Markdown. So we type hash, hash in struck shins
like that, press the enter key. And now we can define our instructions. So each
item in the ranking list should be
on a new line. So this is how we want our output to be formatted
and list item must
only include the name of
the item and not any additional
information. Great, that's just a basic instruction to our
LLM on how to format the output. And the other thing we
can do is actually provide the LLM with examples of the format. So let's create
an example section. So hash, hash, examples like
that. And then we can provide examples to our LLM like this. So a
ranked list of top five best best
national rugby teams would look
like this comma. And then we can just include a list of our rugby team.
So New Zealand, South Africa, England,
France, and Ireland. Great. And let's provide another example.
So a ranked list of top five best
movies of all time would look like this
comma. And then we can include movie examples, Shaw, Shank
Redemption, certainly one of my favorite movies of all time.
Like that. And then the Godfather 12
Angry Men. Okay. The Dark
Knight. and the Godfather
part two. So we're just basically providing examples of how
we would like the output presented to us. Okay, and I think that looks
pretty good. So let's save our workflow. Ctrl S if you're on a Mac, Command
S should I say if you're on a Mac, Ctrl S if you're on a
Windows platform, and then we can just execute that step again and see what our
output looks like. Okay, so we have the input and the output, New Zealand, South
Africa, England, France, Ireland, and it's outputting our data in the format
that we provided in our examples. So in prompt engineering, a one-shot
example, a one-shot prompt, means that you give the model one example of the desired
behavior format or reasoning pattern within the prompt itself before asking it to perform the
same kind of task on the new input. It's a middle ground between
zero shot prompting, and this is when you give no examples, you just ask the
question or give an instruction, and then you have few shot prompting. You give several
examples to help the model generalize the pattern. We are giving our prompt two examples,
but we could of course provide more examples regarding the type of response we want
as output. And you can see it's very intuitive how it flows. So the input
from the chat trigger, the facility provided to us through NA10, flows to the
AI agent, and then that goes to the subnode, the LLM. So it goes off
to OpenAI, and we've set up the credentials, so that's how we are able to
interact with OpenAI. And then OpenAI returns the response through our
AI agent the response has been formatted appropriately the
way that we've asked it to format our output and we can look at this
in json format here great and that's working correctly that's working as
expected but now let's go back to the canvas and there's something i want to
show you that's very important so we've got a chatbot kind of working here but
it's not perfect because at the moment, if we had a conversation with our chat
bot, it's only going to remember one prompt and you'll see what I mean by
this. So subsequent prompts will not have any context. So it will see that as
an individual prompt, any subsequent prompts. So we need to do something here
that's very important. And I'll just demonstrate why that is now. So let's go. What
are the top five best movies of whoops movies
of all time, like this. And let's see what response we get.
Shawshank Redemption, The Godfather, The Dark Knight, 12 Angry Men, this list. Okay, that's great.
But now what if we said, what are the next
best five? Let's see what it does.
So it doesn't have a clue what we mean by that. Could you please specify
the category or context for the next best five? For example, are you referring to
movies, books, sports teams or something else? And the reason it's
sending back this response is because it can't remember the previous response. So it has
no context whatsoever. So we can actually give our AI agent
memory, which will allow us to give it context. So we can actually So the
user will actually be able to have a conversation with the chat bot. So it's
pointless having a chat bot that you can't really converse with. So to add memory
from N8N, you'd simply press the plus icon button here, where it's labeled memory, you
can see memory below the AI agent, you've got chat model. So we've added a
chat model, open AI chat model, we can add memory and we can add tools.
And we'll look at adding tools later on. Now the difference between a chat bot,
which is what we're creating here, and an actual agent is that an agent actually
does something, for example, schedule an interview, and add it to the user's calendar.
Whereas this provides us with a chat bot that we can converse with. So we
can prompt it with a question and it will answer our question, for example, but
it won't actually do anything. So this is just a chatbot. But we want to
add memory to our chatbot so that we can have a conversation with our chatbot
and it will remember the previous prompts. So let's do that by pressing the plus
icon here attached to the memory connector here. And you can see the
panel shoots out from the right of our screens here and we can now add
our memory and we have various options here. but they are separated into four beginners
and other memories. We only want to add simple memory. So let's select simple memory
here. Great. Okay. And this context window here, this is
important, is set to five. Context window length is set to five and
that suits our needs because we don't need more than that for what we want
here. But you could, for example, set it to 10 and then it would remember
the last 10 prompts, the last 10, of interactions with the with the
ai agent but five will do for our purposes here so it will remember the
last five interactions and that's what this means here and this session id field just
provides a constant thread of conversation because if the session id was different each time
you prompt it it wouldn't have that memory so it's one thread of conversation that's
what this unique session id represents here so this is a unique id so that
regarding a particular conversation with the chat bot. Okay, so let's go back to the
canvas here. And we can actually test that again. So let's go back to the
rugby example. So what are the best
five national rugby
teams like that? Okay, New Zealand, South Africa,
England, France, Ireland, Excellent. That's what I would have expected to see. And then now
what if we go and what are the
next best five? So we haven't included any context in this prompt. It
doesn't know that we're talking about rugby teams, but because we've added memory, it will
remember the last interaction where we did mention rugby teams. So that provides this prompt
with its context. So it will remember that hopefully it will remember that we're talking
about national rugby teams here. And let's see if it does.
Excellent Australia, Wales, Argentina, Scotland, Japan. And that makes sense. So we've now got
the top 10 best national rugby teams. So that's great. And we could
say, for example, ask what are the best authors of all
time. And we've got a functional chat bot here that
helps us rank various items. William Shakespeare, Leo Tolstoy, Charles Dickens, Jane
Austen, J. R. R. Tolkien. Okay, that makes sense. Great.
And the next five. And let's see what
response we get. So we've got the next five best authors. Excellent.
So we've got our first workflow and everything seems to be working correctly. And we've
created a very basic chatbot.
Let's go into Hostinger. Okay, I'm just going to go to my
account here and log in to Hostinger. Log in
with my credentials, my Google credentials. Okay.
And then we go to manage here and skip this and then manage app.
And then we're going to log into NA 10. Okay.
Email address. So I'm logging in with my credentials.
Okay. Okay. And we logged in now. So let's go into personal and I created
a folder called my workflows here. And first thing I'm going to do is actually
just go in here and name the project that we created in the previous segment
of this course. And I'm going to name this example one.
So I'm pull one dash chat bot like that. Let's go back to
my workflows. And within my workflows, I'm going to create another workflow for this example.
And let's name this one panic
app registration like this.
Okay, and we're going to get started in a bit. But the first thing we
want to do is to create a Google sheet. So I'm
going to use my Safari browser to log into Google with my credentials.
So if you don't have a Google account, you will need to create a free
Google account and then log in. And then I'm going to go to sheets here.
And I'm going to create a new Google sheet. So I'm just going to create
hit this option here, blank spreadsheet.
Okay, great. And I'm going to name this
Panic app registration, like that.
So let's include headings for the various fields. This denotes the information that the user
will enter into a submission form to register to use the Panic app. So we
want first name for the first field. And in the second column, we want
last name like that. And then we want email in this field here.
And then address one, address one and address two. So only two
fields regarding the address because I'm basing this on an example for an informal settlement.
So these are people who can't necessarily afford private security. They live in an informal
settlement. So their address will be, for example, the house number will be address one
and the area in which they live will be block B or block C. So
you can extrapolate this example out to a like that would have a postcode and
then you might have more address fields. But for this, we're talking about informal settlements
where they might not necessarily have a postcode. So address one will have a house
number 13 and address two could be, for example, block D or block B.
And then for the last field, it's going to be what uniquely identifies the person
who's registering for the app. And that will be the user's WhatsApp number.
So each user will have a unique WhatsApp number. We're going to use that to
uniquely identify each registered user. Okay, and that's pretty much our
spreadsheet. So we want to go back to N8N and I've got that loaded up
in Chrome. So I'm going to minimize this here. And I'm going to go to
Chrome now. And the first step is to click this plus icon
here in the middle of our canvas to add a trigger node to our workflow.
So each workflow starts with a trigger node, which is what we discussed when we
were creating the first workflow in this course. So let's hit the plus icon here.
And of course, the panel or the window shoots out from the right
side of our screen and we can add whatever trigger we want. You can see
a trigger manually, which means you trigger workflow by clicking on the trigger manually node.
But we are actually going to trigger our workflow with the node marked on form
submission. So we're going to select on form submission and we're going to build a
form. Okay, so let's give our form a title.
And you can see here form title. So let's go into this form title field
and we are going to give this a title of register.
Okay, we'll make that a bit larger. Register user for
security response like this.
Okay, and then we can give our form a description. So
registered user Users can request
armed response.
Sorry, response in
emergencies via
WhatsApp. Okay. Great, so now we want to create
our form elements. So these are the fields that we are going to map to
the fields that we created within our Google Sheets. So let's go to Google Sheets
here quickly. And you can see here we've got first name, last name, email, address
one, address two, WhatsApp number. So we are going to now create those fields within
our N8N workflow, specifically our on form submission node
here, this particular step for this particular step. so we go add form element here
and the field name is first name okay and we're just going to leave that
as text and the placeholder that will appear within the relevant text box will just
be first name like that and all of these fields are going to be required
so the user must enter the user's first name and all the other fields so
we're just going to put we're going to switch this to on the on position
required field like that means it will have a red star next to the field,
you'll see that when we eventually run the form. And then we want to add
a new field and this one we're going to call last name. And we're going
to leave that as text and the placeholder will be last name. And we also
want to switch this required field into the on position. Because each of
these fields, as I've said, are required fields. And then we want to include a
field called email. And let's select email here. So
what the user enters will automatically be validated. So if the user enters an
erroneously formatted email address, it won't let the user
submit the relevant form until that particular email information has been entered
correctly in the correct format. And we'll just in the placeholder field, we'll just include
email address like this. And let's switch the required field field on
like this. Okay, so the user must enter a valid email address. And the next
one will be address one. So this could be for example, the person's house number.
And we'll leave that as text. So we'll just call this address one like that
and switch required field on. And then we've got the address to field that we
must include here address to And let's leave that as text and placeholder
address two. So this will be the name of the area in the informal settlement
in which the user lives. For example, block A, block B, block C. Okay, and
then let's switch this to on. And great. And then the last
one is the WhatsApp number, the user's WhatsApp number. Okay, so
WhatsApp number. number like that, and we'll leave that as
text and the placeholder.
Okay, we leave that as
text and the placeholder is simply what's app number. And
let's switch that to the on position.
So even though this step is not actually connected to anything, this trigger
node we've only got one node at the moment here the on form submission node
we want to create some information that we can use so i'm actually going to
do that now by running the first node the on form submission node so let's
double click on that node and we can include and we can execute the step
by pressing this button execute step and you can see now our form has been
created for us already look at that that's pretty Great. So register user for security
response. Registered users can request armed response in emergencies via WhatsApp. And I'm going to
include my first name here. Lon, email. So include your email address.
Okay, let's say that I live at house number 12,
block B. And I'm going to actually
include my actual WhatsApp number here. So I can actually test a user panicking
via WhatsApp. So we can see the whole application in action and how it would
actually work via WhatsApp. So this is actually my valid WhatsApp number. And I would
urge you to do the same thing, actually include a valid WhatsApp number that you
can test the next workflow with where a user actually
panics using the WhatsApp. application. So a panic notification
actually goes through, through, through the use of WhatsApp. So we must include a valid
WhatsApp number. And this WhatsApp number is used to uniquely identify a registered user, a
user who's registered to use the WhatsApp panic app. Okay. So
this isn't going to go anywhere but it will capture this information we'll be able
to pin this information so that we can run the next step in isolation ie
without having to fill this form in every time we want to test our workflow
so i'm just going to hit the submit button great so it says here form
submitted your response has been recorded excellent so let's go out of that there and
if we go into the node we can see our output here and that looks
Great, that looks perfect. So the output is valid here, the information that I've entered
there. And a great thing that we can do here now so that we don't
have to keep going through that submission process in order to test the
subsequent nodes in our workflow or the subsequent steps in our workflow is we can
pin this data and all to pin the data all we need to do is
press this pin icon here. So let's pin that data by pressing this pin icon
here. Excellent. So that's excellent. Great. Okay, and we can
go back and continue building our workflow now. Now that we've got our submission form
trigger on form submission trigger set up correctly. And to do that, we can connect
another node. And this will be the Google Sheet node to the on form submission.
So the next step in this workflow is to add that information, this information here
that we've pinned to our spreadsheet. Okay, so let's go back to Canvas and let's
click this plus button to connect the
Google Sheets node, the Google Sheets node. So
let's click this option here. And then we've got various options to choose from. And
we want to append a row to our Google Sheets. So we want this option
here. Append row and sheet. Great. And it's added that there. And you can
see I've actually set up relevant credentials here to connect to my Google Sheet that
we created earlier on. But I want to go through the process of how you
will create those credentials. So we'll create new credentials for this
step here. And you can see here on the input, we've got our pins data
that will be sent through to the node here, the append row
to Google Sheet node here, append row and sheet node here. And then this
node will be responsible for adding that information to our Google Sheet. So it will
add the relevant field values under the counterpart headings here in our Google Sheet.
Okay, so let's go through the process of creating a credential so that N8N has
permissions to add a row to a Google Sheet that is saved under your
account credentials in Google. So this is basically a way for us to give N8N
permission, this workflow permission to add a row to a Google Sheet.
That's basically all we're doing here. So let's click Create New Credential. And you can
see here it's using the OAuth2 standard
by default, so that we can give permissions to N8N to access that
Google Sheet. And what it requires are two fields, client ID, and client secret. So
we need to generate those values. And we do that through Google. So to
set up our credential, we actually need to go to a specific Google path. So
we need to look up console, Google Cloud. And this is what we
want here, we want this URL console.cloud.google.com. And
we go we do this just click this URL link here. can see i'm already
logged in if you're not logged on we uh you must log on and this
actually just reflects your latest project your current project okay so we
want to create a new project here
so so this is the the current project i've got loaded but
if you click this button here it will present you with this dialogue and then
you can create a new project so by clicking this option here new project
okay and great so now we can give our project a name
call this project n8n panic app
project like this great okay i'm just going to say no organization here and let's
just create our project so click the create button like this so it's creating new
project and now we have to select our new project n8n panic app project so
click the select project link here okay and so
now n8n panic app project is our current project okay so in the left
menu here let's go to api and services
library like this Excellent.
And then we want to enable a particular API and that would be the Google
Sheets API because actually what we're doing here is engaging with the Google Sheets API
and instructing the Google Sheets API to add the relevant fields that we've
discussed that we created in N8n to the relevant spreadsheet here.
Okay, so let's search for the appropriate API. So we search for Google
Sheets API and there it is. Great. And let's select that option.
So it's presented Google Sheets API and a result here. So let's select that there.
And then we click the enable button. Yeah, we're enabling Google the Google
Sheets API for this particular project that we're going to be connecting to through NA10.
So let's click the enable button.
Excellent. And now we want to generate our client ID and our client secret. So
to do that, we go to credentials here. Okay, so from this
web page, we need to click create credentials like this. And
then OAuth client ID. So let's select this option
OAuth client ID. Okay, brilliant.
A client ID is used to identify a single app to Google's OWALT server. So
now we click the configure consent screen button. Okay.
And let's get started. Okay, so let's give it an app name.
Let's just call this panic app.
Or panic WhatsApp. app, WhatsApp, whatever. Okay. Supported
email and that's just going to be my email address here. So just pick the
default address there and then click the next button. And this will be
external. We want to select the audience. It's going to be an external audience. So
select external there. Click the next button and then contact
information. So okay, just give your email address.
just put in whichever contact email addresses you want to include for contact information
click next and then i agree to the google api services user
data policy and then press continue and then create
okay so we're basically creating a consent screen and you'll see the consent screen when
we log into google via n8n once we've included the client ID
and the client secret. And now we
go create OAuth client. We hit this create OAuth client
button here. Okay, and the application type is
web application. Name web client one, I'm just just going to leave that as is
at the default. And then we need to paste from N8N
the callback URI that's given to us here. So click to copy here,
there. So we've copied that to our clipboard. Let's go back to Safari, in my
case, where I'm filling in this form and paste that in there. And that's the
callback URI. Okay. And then let's press
create. and it's generated our client ID and our
client secret so we can now just copy let's copy first the client ID value
let's go to n8n here and paste that in the client ID field and then
let's do the same for the client secret here let's paste that in there
and then we can simply and let's just go okay because we've copied the relevant
fields and it's created our client ID and our client secret so Let's save that
information, the client ID and secret credentials successfully created inside your personal space. Brilliant.
And now we actually need to provide consent for N8N to connect to
Google and be able to use that Google Sheet. So we provided all the necessary
credentials, the client ID and the secret, and now we just need to provide consent.
So let's go sign in with Google. And this is just how the OAuth2 protocol
works. Okay, I'm gonna sign in with my credentials here. One thing we need to
actually do before we provide consent so that NA10 can add the relevant fields to
our Google Sheet so NA10 can have the appropriate privileges to access our Google Sheet
is we need to add a test user. So I'm gonna go to the audience
option here and I'm gonna add a test user here. So add, I'm just
gonna add myself. add your email address
of the account that you've logged on as okay and i'm going to save that
there okay so i've added a test user and now i'm going to sign in
with google and provide consent okay so go to i'm going to
log in with my credentials into google continue okay and
now we are presented with the relevant consent screen that we've just built
within our project that we just created within console cloud Google. And we're going to
provide consent. So we're going to select all here, click the Continue button to provide
consent. Connection successful. Excellent. So now we can use our Google Sheets account three
And it's account three because I've created several other accounts prior to this. So that's
the reason why it's got this three appended to it. So we're now successfully connected
and we've given consent for NA10 for our workflow to access our Google Sheet. And
we can actually just execute the step from here because we've got this pinned data.
So we won't have to reenter all those values for those for the relevant fields.
We can just execute this node right here, this step right here. But we
actually can't because we haven't wired up the relevant fields, the field
values here to our document. And we haven't selected the
document that we want to connect this step to. So that's the next step. So
we've got from list here. I'm actually we're actually going to use the ID. So
with the document field here, we want to select by ID here and then we
want to enter the ID. So we must go back to the
spreadsheet here. And I'm going to copy the ID.
This is the actual ID of the Google Sheet. It's part of the actual URL.
So this value here, just copy it to your clipboard.
So Ctrl C, I'm on a Mac, so it's Ctrl C, obviously, sorry, Command C
if you're on a Mac and Ctrl C if you're on a Windows PC. So
I'm going to copy that ID to my clipboard and then go back to N8N
and paste that ID here. So now we can actually test whether we've
been successfully connected to that Google spreadsheet by pressing
this down arrow in this drop down list here for the sheet field. So we
want to select the relevant sheet that we want to access within our Google document.
And we can do that by pressing here this arrow down button here. It hasn't
connected because I've included too much information here. If we look here, it's got parts
of the URL that we don't need. So I'm going to remove, remove those parts
here. We just want the ID here and now it should
connect and let's see if it does. And there we go. Sheet one from list.
Okay. Excellent. And automatically it's taken, it's read those fields that we
created. So these field from these field headers here, that knows that these are the
fields that we want to wire up. So it's automatically detected those fields and
presented them to us here. And to wire them up to our data, we can
now drag and drop you see we've got JSON data presented to us in the
input section here. And we can wire up those fields to the fields
that we've included within our Google spreadsheet. And to do that, all you do is
you drag and drop the field from the input section
to its counterpart field within the append row and sheet node
here and you can see it's gone green because it's valid JavaScript expression. So it's
picked up that field value. And you can see this expression means that it's dynamic.
You see, we've got the expression option here selected, we could have the fixed option
here select, but we want the expression option because this must be dynamic. It's like
a variable. So for each run of our workflow, of course, this value can vary.
So you might, for example, register Bob Jones for the next execution of the workflow.
So the first name Gavin here will of course be different. It will be Bob
in this particular case if we're registering Bob Jones. So let's go through this. So
then we can wire up the last name field and it's the same process and
wire up email like this. Okay. And then we can just wire up address one
like this. Address two and then
WhatsApp number like that. Great, and we've wired up our fields, and actually we're ready
to test this step, the append row to sheet, append row in sheet step. And
because we've pinned our data, we don't have to actually fill in the form again,
and we can just execute this step. And it should place these field values
under the counterpart field headings here. let's see if that works. So let's
execute step. Excellent.
That looks good. Node executed successfully. And let's go back to our spreadsheet. And there
it is, there are our values that have been successfully added to the spreadsheet.
Okay, great. So what I'm going to do is I'm going to unpin this data
from the previous node from the on form submission node, I'm going to unpin that
data, and we'll run through the entire workflow in production.
So you can see here, we would access this URL for test purposes. But if
we were running our workflow in production, we would use this production URL here. So
let's copy this to our clipboards, this production URL here. Let's go back to our
canvas now. And let's save this. And let's
select this switch here so that our workflow is active. Let's select this option here.
Let's press this here to the on position. Got it. And now it's
activated. And we can actually run this in production from
the production URL. So let's go let's open another tab here, paste that production URL
in there. And now let's register Bob Jones. Oops, Bob.
Jones, Bob Jones at Hotmail. This isn't a valid
address. It might be a valid address, so don't use it. It's just a test
address as far as I'm concerned. And then his number is 12. No, we've done
12. So 10, and he lives in block A. And his
WhatsApp number is pretty much anything. This is not a valid WhatsApp number. And we
can submit that. form submitted and we can check whether that information has been added
appropriately to our spreadsheet and it has. Excellent. So our
workflow is now operational. Okay, so let's create a new workflow and let's
call our workflow WhatsApp panic app. In fact, let's call it panic app notification. You
can see we've got panic app registration that we created in the previous section of
this course. where a user registers to use the WhatsApp panic app. So in this
part of the course, we're going to be handling the notification functionality where the user
feels threatened, perhaps there's a burglary underway and the user needs armed response.
The user can use WhatsApp, send a message to a designated WhatsApp number, then the
workflow will subsequently check the relevant spreadsheet, the spreadsheet that we created in the last
section of this course, will look for that user's details. And if the functionality in
this notification workflow finds the relevant row based on the user's WhatsApp number, which
uniquely identifies the user, that means the user has registered, and the user's address is
part of the user's registration details. So that information is then sent via email to
a person who's on duty. So somebody will be monitoring their emails to monitor the
relevant panic notifications that come through on email. And within that email will be the
user's details. The person on duty can then dispatch armed response to that user's residence.
So perhaps if a burglary is underway, the responders can
appropriately, these trained responders can appropriately handle the situation. Okay, so let's create the
workflow. So I'm gonna hit this button to do so. Create workflow and let's call
this one panic app
notification like this. Great. So
we've created our workflow and now what we want to do is add the relevant
trigger. Remember each workflow starts with a trigger node. So we're going to add the
relevant WhatsApp trigger because what the user is going to do is send a message
And this should only be like one character. It doesn't have to be an actual
message because that might take too long for the user to write, especially if the
user's panicked. So the user might just send the number one to the designated WhatsApp
number. And then the workflow can extract the user's WhatsApp number, which will subsequently be
used to look up the user's details on the relevant spreadsheet. So let's add the
trigger node. Let's So as per usual, the relevant panel shoots out from the right
side of the screen and we can look up the relevant WhatsApp trigger. So let's
type WhatsApp. Okay, WhatsApp Business Cloud is the one we want. So let's click WhatsApp
Business Cloud. And then we want a particular option here and it will be the
on messages. So let's select on messages here.
Great. Excellent. And you can see I've actually already created credentials
for WhatsApp, but we want to create the credentials. We want to go through the
process of creating the credentials step by step. So we're not going to use this
one. So let's create credentials. And now as per usual, this is the
most arduous part of creating the workflow. These workflows are quite easy to create, but
I do find creating the relevant credentials somewhat fiddly. Fiddly is the word. Somewhat fiddly
at times. So anyway, so let's select the create new credential option here. Great, you
got the client ID and client secrets. So let's move on to the next step.
I'm going to go to my Safari browser here. And then we need to
navigate to a particular Facebook URL. So
let's type Facebook business here, business meta. And
this is the one we want. So it's business.facebook.com. This is the actual one we
want. And we can log in now with our Facebook account, whatever your Facebook account
is, log in with that. And then you must create a business portfolio.
And you can do that like this. See this option here, Gamelon Digital, and then
create business portfolio. So this is the first step, create business portfolio. Okay, this is
for sure. So we need to give our business portfolio a valid name. So I'm
just gonna go my new business
like that. First name, Gavin, surname, Lon, and
put in whatever email address you want to associate with this business portfolio. So
like that, and then hit the create button.
creating the new business portfolio
excellent okay my new business okay gavin on digital facebook great and then go
next here just follow through with the instructions let's go next
okay and then hit the confirm button here
excellent let's go to our business
portfolio so my new business and let's click visit settings like this
brilliant okay and then we want to go to apps in the
left pane here like that click on apps and we don't have any apps associated
with our business portfolio so we click add here to add
an app we create
client app like that. So create an app and
give our app a name. So I'm going to call this my new app and
it's already by default selected the relevant email address for me and then
click next like this. And then we have to select a use case and I'm
going to select connect with customers through WhatsApp and then press
next like this and we want this portfolio you can see i've created a few
portfolios here but we want my new business the latest business portfolio that i've created
then i'm going to select next like this okay and then
okay and then let's click the next button here excellent
okay now let's click go back to
dashboard here. Okay,
excellent. And then it's asking me to authenticate here. So I'm authenticating
to go back to the dashboard for my app, my new app.
Okay,
Brilliant. And now we can actually go to app settings here and go to basic.
Okay, and we have our app ID, which is in fact our client ID. So
we're going to copy that there and paste it into client ID in NA10
and the relevant dialogue here. And this is going to be called WhatsApp OAuth account
five. And the five of course means it's just because I've created several other accounts,
four to be exact, before creating this account and then get our client secret. We
can go show secret here and then we can just copy this client secret or
it's called an app secret through the Facebook interface. It's the
client secret here And we've copied that in there and then we can just click
save like this. Credentials successfully created inside your personal space. And
that's what we wanna see and that's brilliant. Great, and we can
actually just click on the X and go out of this now. We've got our
WhatsApp OAuth account five. So we're using OAuth, OAuth2 protocol to
log into Facebook and of course, Facebook, and of course, we're going to use
WhatsApp through Facebook, through the app that we've just created within our business portfolio. So
now if we go to use cases here, in the left pane, click on
use cases, and then customize here.
Okay,
then go to Click Start here. Click Continue
here.
Excellent. And then we can click the Start using the API button here.
And yes, it's a bit of an arduous process, but we have eventually got there.
And you can see here, we've got a WhatsApp number that has been
created for us here. We've got a phone number, ID, and a test WhatsApp number
that will be the receiver of our WhatsApp message. So we're the panicker. We're going
to press one, send it to this WhatsApp number, and that will kick off our
workflow. and send the relevant email to the person on duty. So here we go
at the test number at that WhatsApp number. Brilliant. What I'm gonna do is I'm
going to generate an access token, which means we can send a test message to
a designated WhatsApp number. So I'm gonna do that, generate a workflow. I
have to authenticate here.
i'm just going to select that and continue if sick the top option here and
select continue okay save that
got it okay so it's generated an access token
and i need to select the two option here i need to manage the phone
number list so i'm going to create i'm going to create a WhatsApp number that
I want to send a test message to. So this will actually be the user
in this case. I'm only sending this test message just for testing purposes and then
it'll be easy for us to, we'll have that test number within our messages
through WhatsApp and we can test our workflow through that. Okay, so I'm going to
put in my WhatsApp number here and this is actually a valid WhatsApp number. So
I'm about to send a test message to my WhatsApp number. Okay. And I'm
going to press the next button here. It's actually sending me a verification code now
to my WhatsApp number. I'm going to insert a verification code now that it's just
sent me via WhatsApp. And then I'm going to switch to the desktop version of
WhatsApp to test our workflow. But we could, of course, test it through WhatsApp here,
through my actual phone. but I'm going to just for convenience, I'm going to use
the desktop version of WhatsApp for that purpose. So I'm going to hit the next
button here. Okay, great. So we've now set that up and I'm going to send
a message. It should send a test message that you can see within this
section of the webpage. It's detailed here in the curl command here, and you can
actually run it in postman if you like, but I'm going to just send a
message from here to my WhatsApp number.
Okay, press send message. Okay, great. And there it
is. Look at that. Hello world. So we've got
Hello world, welcome and congratulations. This message demonstrates your ability to send a WhatsApp message
notification from the cloud API hosted by Meta. Thank you for taking the time
to test with us. Great, so now we can test our application. We're in a
position where we can actually send a message to our workflow. Great, so in fact,
we can execute this step here. So through NA10, so let's go back to the
canvas. We've only got one node, it's our trigger node, WhatsApp trigger. We've wired it
up to our business portfolio, an app within our business portfolio, which has provided us
with a test number. Okay, so let's go into this trigger. node
here and you can see we've wired up the credentials whatsapp oauth account 5 successfully
and now let's execute this step so now we're going to see that it's listening
i'm just going to send the letter one so this is simulating a user panicking
from their phone so they got their phone here and they panicking i could do
it from my phone but i'm going to do it on my desktop so i
could do it from my phone to that test address there but i'm going to
do it from my desktop so i've entered in one, the character one, and I'm
going to send that through to this WhatsApp number. So let's press the
send button here. Great. So we've in fact got the user's
details here. We've got the number that uniquely identifies the user on the spreadsheet. We've
got the user's WhatsApp number here, WA underscore ID, and we can use that for
the subsequent step in our workflow, which will look up the user And that's my
WhatsApp number on the relevant spreadsheet. So let's pin that data here so we don't
have to run another test through WhatsApp to execute the next step in the workflow.
And we're going to move on to the next step in the workflow now. So
I'm going to pin that data there. Great. And let's go back to Canvas now.
And the next step is we want to add a Google Sheet. So let's type
in Google Sheet. So we want a Google Sheet action node here. Google Sheet, sorry.
And we go there and we want to get a row in this. So get
row in brackets s in sheet and we want to select this option here. And
we've actually already got an account set up Google Sheets account three but we need
to enable a specific API for this to work. Google Cloud
Console, console.cloud.google.com. So let's click on this link here.
And we're on the current N8N
Panic App Project. This was the last app that we created in the previous section
of this course. Let's go to this menu option here, and then API and
Services Library. So let's search for Google
Sheets API. Okay, this is the
one we want. Let's select that. Okay, read and write
Google Sheets data, manage, try this API. So we've actually already enabled it. That's what
I wanted to check. Great, so we've got the credentials now to read the relevant
spreadsheet. And I'm gonna actually navigate to that spreadsheet now
that we're going to read, because we're going to need its ID to wire it
up. So let's go to Sheets here.
Okay, it was panic app registration here. Excellent, you can see Gavin Lon and Bob
Jones have been added to this spreadsheet. We registered those users. This could now have,
say for example, 50 users, but when I panic, it's gonna have my WhatsApp number
associated with the message that I sent through to the relevant test
WhatsApp number. And then this part in the flow is going to
filter the rows within the spreadsheet based on the WhatsApp number that
we're going to extract from the previous node, that is the WhatsApp trigger node. And
that's going to go through and it's going to select the details. So the user's
first name, last name, address one, address two, and then we're going to send that
via email in the next step to a Gmail address that
the person on duty can then receive that panic notification and dispatch armed response to
the relevant address. Okay, so we're on to the next step here and which is
going to be reading Gavin Lon's details from the spreadsheet because based
on the WhatsApp number that is associated with the message sent through. So it's Gavin
Lon panicking, somebody's burglar in Gavin Lon's house, burglarizing Gavin Lon's house and Gavin Lon
sends a one the relevant WhatsApp number. And
that engages with our workflow, it then looks up Gavin Lon's details on this spreadsheet
based on the relevant WhatsApp number. And then the subsequent step, which we'll create in
a bit, will send an email notification to the person on duty. And then the
person on duty can then dispatch on response to Gavin Lon's address. So we're back
in N8N and we actually we need to So we've set it
to get rows, that's correct, the operation. Sheet within document, that's all correct. And then
from list. So we don't want to do it from list. We're going to select
by ID for the document field here. And this is the data that we want.
So it's just before forward slash edit. So this is the ID
of the Google spreadsheet that we want. So copy that to your clipboard. and paste
it into this field here. Excellent.
And then we can test whether it's able to read that document associated with this
ID by selecting in the sheet field from
list the sheet that we want. It should have present us with sheet one and
it has and let's select sheet one. Great. And now we want to filter.
We want to filter the row because it's a get row operation. we want to
filter it on the WhatsApp number. So this column is, we're going to select the
relevant column here and it's WhatsApp number. You can see it's extracting the
headings from the relevant spreadsheet. So let's select WhatsApp number here. And then we
set this to expression. And then we're going to drag the wa underscore
ID JSON field onto this value text field here like that,
because that will be the WhatsApp number associated with the
message that the user sends, which denotes the user
panicking, the user requesting armed response. Great. So now our workflow
has the user's WhatsApp number. Excellent. So we could actually execute this
step. And from here, Let's click the execute step button and it should read the
relevant row and there it is. Gavin Lon's details, his address, name, surname, and WhatsApp
number. And it's worked. This step has worked and it's presented the output within the
right panel of the relevant step here. Okay, perfect.
So let's go back to Canvas and we want to, and we now want to
perform the next step So there is actually another reading of a spreadsheet. And this
is the spreadsheet we want in this particular case. Okay, and you can see here,
we've actually associated an email address with each of the address to
fields. So each address to could have a different email address, which is
associated with the person on duty. So each block may have a different person on
duty monitoring the emails for panic notifications. So a block b block c
block d here and you can see gavin on lives at block b
and i've actually just used the one email address for all of the blocks but
in the real world you'd want to have four separate email addresses which
relate to whoever is on duty so there'll be different people on duty for each
of these blocks monitoring the notification emails coming through. We want to add another one
of these nodes because we want to look up who's on duty
for Gavin Lon's block in this particular case. So let's go there and we can
go get and we can go Google, Google Sheets. And then
we want to get rows, get row or rows, we'll use the same Google Sheets
account because we want to perform the same thing, but we want to do it
on a different Google spreadsheet in this case. So let's click from the document field,
let's click by ID. Let's select the ID for data for this
particular spreadsheet. And we'll look up which block that person
lives in. So it will be block B in this particular case, you can see
that here, Gavin Lawn lives in block B of the informal settlement. And then we
can select sheet one from the relevant drop down and then we
can add a filter and this time we're going to be filtering on the block
name so select block name in the column and then we can drag the relevant
field which is address 2 for the values so it's going to filter that spreadsheet
on value yeah so it will filter the rows by block name here and extract
the email address of the person who's on duty for that particular block Okay, great.
And that's how you do that there. And now if we execute this step.
Okay, brilliant. So it's got block B and it's got the relevant email address associated
with block B. So that in the next step, we can send an email so
they'll receive the panic notification. Okay, so let's move on to the next step. Let's
go back to Canvas. And let's add the new node. So let's press the plus
icon there. And now we want Gmail. So let's select Gmail
and we want send message here. Okay, so we've added the
send a message node here, the Gmail send a message node, and we want to
make sure that we have relevant credentials set up. So I'm going to use the
same project for this, but you can create a new project by going new project
and going through the steps that we went through earlier on in the course, just
reference those steps just to remind yourself how to do that. If you want to
create a new project for this, I'm going to select the same project that we've
been working with here within Google Cloud. And the next step, I want to go
to library and I want to enable a particular API and that's the Gmail
API here. So let's find Gmail API. select the relevant result
and then hit the enable button. So we are enabling the Gmail API because we
want to send an email from our workflow. So we're going to send the relevant
panic details to the person on duty for a particular block, Gavin Lons block in
this particular case. Okay, so let's go to credentials. And I'm just going to
create a new OAuth client ID here in secret. So to do that, we can
go create credentials here. let's go OAuth client ID like that.
Application type is web application.
Okay, we're applying to fine and then we have to add the relevant
redirect URLs. So go there and then we go back to n8n. So let's go
create new credential here. And you can see here we've got this field, OAuth to
redirect URL, we need to provide that to Google Cloud here within this setting here
to set up this new client ID. And then we can just hit create
like that. And now we can copy the relevant details. So I'm going to copy,
we can actually press this button here, copy client ID. Let's go back to N8N,
paste that in the client ID field there. And we can do the same with
the client secret, copy that there, and then paste it to client secret
field here. And then we want to sign in with Google. So let's do that.
And this is so that we can consent through the consent screen.
And let's select all here. So you can go through these if you would like
to see all the relevant scopes. So this is just whatever privileges you have
are consenting to here that NA10 can have regarding your
Gmail account. So we want N8n to be able to send
an email to a particular email address. And let's hit continue.
Great connection successful. Excellent. So we are now ready to
use these credentials. It's Gmail account for because obviously I've created credentials while I was
preparing for this course. So that's why there's a four appended to it. And let's
go out of this we're now set up with the Gmail account for And we
can send an email. So here, you can see that we've got various options, we
can actually select from all the nodes in our workflow. And we actually want
the results from the WhatsApp trigger node here.
Sorry, we actually want the result not from the WhatsApp trigger node, we want the
result from the get rows in sheet one step
here. Okay, and we want to drag, so we want
to send this to the person who's on duty for block B. So Gavin Lon
lives at block B. Gavin Lon is panicking because someone's burglarizing his house.
So he wants armed response sent to his address. So we want this email address
and that's the address associated with the person on duty who's going to receive the
panic notification. So let's drag the email to the to field here. that's the
email address we want to send this email to and the subject will be panic.
So the person on duty will see panic and will be able to respond. So
the email will come through and in real time, the person on duty can open
that email and read all the relevant details about Gavin Lon and where to dispatch
armed response to because the part of those details sent in the email will be
the user's Address, physical address. Okay, and now this is the most important part,
the message. So we're going to have to get data from the
previous node in the workflow. So it would be this node here, which contains all
of Gavin's details. So we can go first name like this. So we need to
set this to expression so we can include variable data. because it might not necessarily
be Gavin Lon panicking, it could be Bob Jones, it could be Sarah, it could
be whoever. So we've got first name and let's drag first name field here.
And then we want to include a new line here and we go last name.
And let's include the last name field here.
Okay, and then we want address one. Let's
drag address one. So that's Gavin's. In this particular case, that's Gavin's house number.
Okay, and then we want to include address two like this, and we're gonna drag
and drop address two, which is block B here. So the responder will know which
address to go to to respond to the relevant request for armed response.
Okay, and that, and we want email type, let's just make it text here. So
we're sending an email that has a subject of panic. We're sending it to the
person on duty for the relevant block, which is block B. And we've managed to
get that data from through the execution of this step here, which looks up who
is on duty for the relevant block, in this case, block B. And then we've
got the person on duties, email address here. And that's where
we're sending this particular notification. So let's see. if this panic goes
through to the relevant person on duty for block B. Okay, let's execute the
step. Okay, node executed successfully.
Okay, and let's actually go to my the relevant email address here and
check whether that's come through. There it is panic. And it's got all the relevant
details Gavin lon address 12 and we could have sent through the WhatsApp number in
case the user, in case the personal duty or the responder needs to phone
the user who has put forward the panic notification. Okay, I'm going to
unpin the data from this first step here and we're going to put that live
by hitting this inactive button here and now our workflow is in fact
active. So we can now test out the entire workflow here.
So I can actually do that through my desktop version of WhatsApp here. You could
use your phone to do this, as long as you're sending it to the appropriate
test number, it will work. So I'm gonna send a one, meaning I'm panicking, or
it could be any character because we're picking up, this number is designated as
the number to receive panic notifications. So then it goes to the next step, And
through the next step, we are able to extract the user's WhatsApp number, identify the
user on the relevant registration spreadsheet. And then we can extract the user's details from
that spreadsheet, the address, and then those details can be sent to the person who's
on duty. And then the person on duty can dispatch the relevant responder to the
relevant address. So let's send that one through. Okay, and
see what happens. So we've sent that through.
Okay, and let's check our emails. And there it is panic, it's come through.
And we can check that Gavin Lon has panicked. Okay, perfect. So our workflow is
working. Excellent. Right. So in this example, we are going to automate the scheduling of
first round interviews for a job advertising for a senior C sharp developer. So how
this works is the applicant's CV or resume is put into a designated Google Drive
folder. Our workflow loops through each of the CVs, so each of the PDF files.
A summary of the most important points are extracted from the CV and sent via
an email to the person managing the interview process. Based on the summary
of the applicant's CV, the person managing the interview process has two buttons available within
the relevant email. one labeled approve and the other labeled decline. If the person
managing the interview process clicks the approve button, an AI agent schedules a one-hour in-person
interview with the relevant applicant the following week at the earliest available slot on the
manager's Google Calendar. If the manager presses the decline button, the applicant is
not considered for the position and doesn't get the opportunity to be interviewed. So then
the workflow moves on to process the next applicant's CV or resume, the next CV
within the designated Google Drive. So this example deals with the concept of a
human in the loop. This basically means that a human's discretion is required at a
point in the workflow where at this point the workflow pauses and waits for a
specific action to be performed by a human. In this case, the workflow pauses and
waits until the manager of the interview process either approves an application for an interview
or declines the applicant as a prospect to fulfill the senior C-sharp position. So the
most important aspect of this workflow is the concept of a human in the loop.
So we're going to take a closer look at this now. So with the assistance
of ChatGPT, I generated eight CVs. So I'm just going to show you where I've
generated those eight CVs. So if we go to
here, we can see in this Google Drive folder, I've designated a particular folder
within Google Drive. So if you want to follow along with this example, you want
to create a designated folder where you'll put your CVs for this workflow. And you
can see here I've got eight CVs that I've created through ChatGPT.
content was created generated through chat GPT. And then I exported them to this PDF
format. Great. So let's create the workflow. Okay, so I'm going to go to n8n
here. And we've created a particular folder here called
my workflows. And I'm going to hit this button here, create workflow to create
our workflow example. And let's name this workflow.
interview
like that. Excellent. And now we want to create our trigger node within our workflow.
So each workflow has a trigger node and the rest of them are going to
be action nodes. So let's create our trigger node. So let's click this plus button
here. And of course, the window shoots out from the right and we can find
the trigger node that we want and we want to trigger manually. So runs the
workflow on clicking a button. NA10. Good for
getting started quickly. So we want to get started quickly with this workflow. You could,
for example, have a node that actually monitors the relevant Google Drive folder
for changes. So if for example, three new CVs were put into that Google Drive,
this could trigger the process could trigger our workflow to process the relevant new CVs.
And then of course, at the end, what you'd want to do is once those
CVs have been processed, you'd want to move them into another folder. And then any
subsequent PDF files that are put into the designated Google Drive folder will kick off
the workflow so that those CVs that have recently been put into the Google
Drive folder are processed by our workflow. So we're going to, just for testing
purposes, we're going to use the trigger manually node for our trigger node here. Great.
So when you click this node, will kick off the workflow. Excellent. Okay, so the
first action node we want is a node that returns all the PDF files. So
it will return all the PDF file names within our designated Google Drive folder that
will be used to contain the relevant CVs or resumes and are denoted by PDF
files. And we're going to search for Google Drive.
And there it is Google Drive. And let's click on this option here. Okay, and
we want a specific option for Google Drive. And we want
the search files and folders option here. So let's click on this option there.
Great, excellent. And you can see that I've already got relevant credentials
set up to access Google Drives, but we're just going to go through the create
new credential process again. So I'm just going to click create new credentials. So this
will give our workflow access to the relevant Google Drive folder. And of course, we're
going to use OAuth 2, the OAuth 2 standard to allow NA10 to have the
correct privileges to access the relevant Google Drive folder. So we need a client ID
and a client secret. So we are going to go to, so let's go to
Google and we want console, Google Cloud. So we want to
access a specific URL and it is
console.cloud.google.com. So let's go there and make sure we're logged on with our Google
credentials. Even though the name is no longer really appropriate, NA10 Panic
App Project. This is because we used this project in the previous application to do
with a Panic App, a security Panic App. But we could rename this project or
create a new project, but just for the sake of saving time, we'll stick with
this project. And the first thing we want to do is to go here and
go to API's and services library because we want to find the
relevant API. So it's Google Drive API, right
Google Drive API. So we search for Google Drive API. And we need to enable
this particular API, Google Drive API, let's select this result here. And then
click the enable button like that.
Excellent. And then as per usual, we want to go to credentials. And now we're
going to go through the process of generating our client ID and our client secret.
So to do that, we click create credentials and then OAuth client ID.
Excellent. So application type is web application
Okay, and we'll leave that at web client three. And then we need to, this
particular URL, this is the OAuth redirect URL. So click to copy, but we need
to add that to this particular field, authorize redirect URIs, and let's paste that in
there. And let's click create. And it's as simple as that.
We've got our client ID, let's copy the client ID over to N8N here. And
then of course, we need to copy the client secret. Let's copy that and
paste that in there. Okay, excellent. And let's save that.
Credentials successfully created inside your personal space. And that's what we want. And then let's
sign in with Google. Now we need to provide consent. So I'm just going to
log in with my Google credentials. Continue
And now we want to select all so that we can use our Google Drive
appropriately. And we can just select all here and then click continue.
Excellent connection successful. And we're good to go here now. We can start using our
Google Drive for our purposes here. So what you want to do now is create
a Google Drive folder and paste in all the PDFs that represent
your applicant CVs, your applicant CVs. You can download those PDFs and you will have
access to this GitHub folder. So if you navigate to this GitHub folder, you can
see the relevant CVs here that I've created. So Janet Winslow,
for example, you can see here curriculum vitae, personal details, full name, Janet Claire Winslow.
We're going to use an AI agent to extract relevant details about
a particular applicant and that will get then sent via email to the person managing
the interview process. And then that person based on these details sent to the person
can either approve or decline this particular applicant. And that is the
human in the loop. That is why we're using a human in the loop because
we feel that this particular workflow requires human discretion, but we're also leveraging the power
of an AI agent to summarize the relevant curriculum vitae or resumes, if
you like. You can see about personal summary, technical skills, work experience, and it's quite
a long CV. So to speed up the process, our AI agent will summarize the
relevant details so that at a glance, the person managing the interview process can glance
at that summary on an email and either just click a button, approve or decline
to indicate that the person managing the interview process either wants to see that applicant
in the first round interview, or rather decline that particular applicant. for the senior C-sharp
position. So then whichever folder that you've designated the container for the relevant
CVs here, and you can see there's eight of them. The one we've just looked
at is Janet Winslow's CV here. And what we need here is the
ID of that folder. And you can see that in the URL here. There's the
ID of that folder. So copy that to your clipboard here like this. Go
back to NA10. then paste it within the search query field. So we've got the
search query field here, we want to paste that in there. And we also want
to put that within single quotes. Okay, like that.
Okay, and then this requires a specific
type of query. actually requires an
advanced search. So the search method must be set to advanced search. We've got the
Google Drive folders ID here. And then we want to
create a query so in parents. So this is just a specific notation for our
purposes here to query that particular folder. So we've got the relevant folders ID
in parents and then and and it's almost like a SQL query
really. in its format. And MIME type
equals to then in quotations here, we go app
location like that. Let's just make this a bit larger application
forward slash PDF. So we're filtering out all the PDFs
within this folder at the moment, it's only got PDFs, but we still want to
be precise with our query here. so that if a text file ends up there
or a folder ends up in that particular folder that it is filtered out. Okay,
so we only want the PDFs queried from this folder. Great. Okay,
and I guess we could just go return all here. Okay. We
want to return all the CVs from that particular folder. Great, so let's execute this
and see if it returns those PDF file names as output, which is what I
would expect. let's hit execute step. Excellent. That's great. So it's
returning the ID of the relevant file followed by the name of the file. So
you can see that the first file is Janet Winslow CV. PDF. That's the
PDF that we actually looked at there. So it's returning the expected output, Brenda Jones
CV, Devon Rhymes CV, Jessica Bailey CV. And
we've got loads of applicants for our senior C sharp role. Brilliant. And what
I'm going to do is so that we don't have to run the step continuously
each time we test it. Let's just pin that data. Great. So we've pinned that
data. Let's go back to Canvas. So because I want to split out each output
item, i.e. each PDF file and include a human in the loop pertaining to each
file, I'm going to include a loop node. So a loop node, so think of
it as kind of like a for loop in programming or a while loop. what
we're going to do. So we include this loop node so that we can have
a loop. Each iteration of the loop represents the processing of a PDF file.
So it's looping through all the PDF files, downloading its content, and summarizing that
content, sending it to the person who's managing the interview process. The person at a
glance looks at that summarization of the PDF and either approves the applicant or
declines the applicant. So that's the human in the loop And we want to do
that for each CV. So that's why we're going to include this loop node so
that we can loop through each CV individually, you can sort of get a sense
that if we didn't have that loop, it's going to try to process all of
these items in parallel. And because we've got a human in the loop in this
particular workflow, we don't want to do that. We want to process each item individually
within a loop. So that is why we're including this loop node here. So let's
look for loop here. loop over items split in batches. We want the size of
each batch to be one, one item.
Okay, and you can see it's created the loop for us here and we've got
a replace me node and we'll replace that in just a bit. In fact, I'm
going to just delete that. We don't need that. Okay, I'm going to delete that
and we're just going to Eventually we're going to loop that right around so that
we're processing each PDF file. But for now, for testing purposes, while we're building up
our workflow, we'll just remove those extra nodes that were added by default when we
added the loop over items node here. So we want to split the output into
a batch of one. We want to traverse over each PDF file, summarize the data
in the CV and send it to a human in the loop as an email.
The human in the loop must then approve the application or deny the applicant before
The workflow continues. So an iteration per each PDF file will be fired in the
workflow. So in this case, that will be eight items, one per PDF file. Right,
so let's go back into this node here. And if we execute the step, you
can see that it is loop branch one item, it is
selected the top item here, which is Janet Winslow
CV.PDF. and that's the top item in our list of PDF files. So it's going
to process each of these PDF files one by one within a loop. So each
iteration denotes the processing of a particular CV. Okay, great. So
let's go back to Canvas. And we want to now add a node that will
automatically download the contents of the first PDF to be processed. So to do
that, see we've got two connectors here done. So this is when
all the iterations of the loop have been carried out. We can add another node
to that. So you could add us say a Gmail node that emails you once
the all the items have been processed. So you know that the workflow is completed
processing all the items. But we want to connect to this loop node because this
denotes that this is we want this node to be run one once
per each iteration of the loop. Okay, so we want to add the Google
Drive download file node. So to do that, let's click the plus here and let's
go Google Drive, select Google Drive, and then download
file like that. Great. Okay, so we've got the Google Drive account
three drive selected, I think we've got the correct credentials here.
Right, so let's go back here. go into the loop here and let's execute step
there. Okay, and go loop, branch one item, click that we've got
that item available. Yeah. Okay, let's go back to Canvas. Let's
go to download file. And we've got our input available to us here. And we
want to download the file by ID. So you can see this is set to
red because it's empty. Let's set that to expression. This file field must be set
to by ID. And then let's drag the ID field value onto the
file field here. Excellent, like that. And let's execute the step here.
Okay, so the next step is we want to extract from file, we want to
extract the relevant contents from this binary file. So we need an extract from
file node connected here. Let's go there. Okay, sort out this
workflow. Let's click the plus button there, plus icon, and let's search for
extract from file. And this is the node we want here. And we
want to extract from PDF. Great. Okay, excellent.
And now I think all we need to do is
execute the step and it will extract the contents of this PDF
and put it into text format, which is what we want for our next step,
which will summarize the text. We'll get an AI agent to summarize the text before
sending that summarized information to the person who's managing the interview process. So let's hit
the execute step button and see what happens. Brilliant, look at that. So it's
actually read the contents of the PDF. And this text field here
contains the extracted text from the PDF. And that's what we want there. So we
can now use that as input for the AI agent that we're about to create.
And let's pin that data to make life easy for us. Great. And let's go
back to Canvas. And now we are going to be creating our AI agent. Okay,
so it's pretty exciting. Great. So let's hit the plus button.
Oops, it doesn't look very tidy. Looks a bit better. And let's hit the plus
here. And now we want an AI agent. So let's go AI agent. Let's
select this node here. Okay.
Great. And we want to firstly add a chat model. So we're going to
stick with the OpenAI chat models.
OpenAI chat model and I like GPT 4.1 mini. So let's stick with that. We've
got an OpenAI account set up. If you don't remember how to set up an
account, please go back to the relevant part of the video where we set up
an OpenAI account and create the credentials to access it from NA10. But I'm just
going to stick with the one that we've already set up here. And it's which
gives us access to the GPT 4.1 mini model here. Great.
Okay. So that's our model setup. Let's go back to
the AI agent there. And you can see how this is red because there's no
JSON chat input field available here. And we want to replace this with
an appropriate prompt. So first thing we need to do is select define below
for source of prompt user message. So we define below. And now we're going to
create a prompt and just to save time, I've actually created
the relevant prompts for us. So let's go into this particular file. You can just
download these files and use them for your workflows. And I'm going to just paste
this particular one here. You can see here it says, this is the prompt, it
says, please analyze the following curriculum vitae content and return relevant details
about the applicant and your recommendation about the applicant's suitability to fill the position
as Senior C Sharp Software Developer. And then we've got this JavaScript expression here,
which will actually contain the text that we've extracted from the PDF file. So I'm
going to copy all this information here.
This entire prompt I'm copying to my clipboard. And then let's go back to N8N
and I'm going to paste it here for the user message prompt. And you can
see this is green here, but I'm just going to delete this, this expression and
show you how you need to add that. So this is the kind of base
prompt here. And then to get the content from the relevant CV, we can just
drag this text node at an appropriate position onto our prompt user message field
like this. Great. And it's green. that's perfect. So we've now got our prompt. So
we're asking the model to summarize the content of the person's
CV, the applicant's CV, before sending that summarized content to the
person managing the interview process. Okay, great. And we also
can create a system prompt. So we want to define the role for this
particular AI agent. instructions and some rules. So we can also
get that information from here. I've already created that information for us here. So we
can just copy this here, all of this here. Let's copy
that. And let's create the system prompt. So we want to hit add option system
message, and then in the relevant field, paste that prompt
here. Okay, and we can go through what has been written for the system prompt.
So the role, this is all in Markdown, that's why it's got these hash symbols
here. So these are the headers for each of the prompt items, if you like.
So you are a human resources employee, we're telling the AI agent its role, working
for a software development company. Your role is to analyze curriculum vitae of applicants
for software. senior development position where the user must possess skills at a
senior level in C-sharp programming and have appropriate experience developing software using associated
technologies with C-sharp, for example .NET MAUI or Blazor. Instructions.
Follow these steps in analyzing a curriculum vitae and outputting relevant data in your
response. So number one, read through the provided information, get the
applicants Call name and email address from the curriculum vitae. Get the total number of
years of experience the applicant has working with C-sharp and associated technologies. Get
notable features about the applicant's qualifications. Get notable features about the applicant's work
experience. Conclude as to whether you would recommend the applicant for the position
of C-sharp developer. And then we have rules here. the most important skill
for the applicant to have. If the applicant does not have C-sharp experience, don't recommend
the applicant for the position. So these are like guardrails for our prompt. Okay,
perfect. That looks pretty good. What we do want to help
us with this process is well-defined output. So a well-defined output structure, and we can
actually do that. So we're asking through an example, we're going to provide a an
example of how we want the output formatted in JSON. So to do that we
first click this switch here, require specific output format like that. Okay,
and then we're going to use this output parser node here. So let's click plus
here for the output parser and we want structured output parser, this particular node
here. Great, and you can see this is the sort of thing that it accepts
this JSON example field. So we're providing a one shot prompt here, a one shot
example. And I've actually created that example here. So we can just copy this
here. You can see here I've already created the JSON, we want full name, email,
C sharp use experience, notable qualifications, notable work experience, recommended
true. So we want the output from our AI agent to look like this, we
wanted to output it in that format. So let's select the sample here. And let's
paste in our particular example. For the
JSON example field here. Okay, great. So let's see what happens
now. Let's go back to the agent, we've got that now done.
And we can actually try that. So let's execute the step and see that outputs
a summary of the relevant applicant CV.
So let's try that. Let's go execute step.
Look at that. Amazing. Full name Janet Claire Winslow. Janet
Winslow.dev at example.com. And that's just straight from the CV. It's obviously just a
made up but it works for our example. And
then we've got C-sharp years experience, and this has been extracted from the PDF, six
years experience, notable qualifications. So we've got BSC
honors, software engineering from University of Birmingham, Microsoft
certified .NET MAUI Developer Associate, Microsoft certified Azure
fundamentals AZ-900 and then notable work experience, six years of professional experience
with C-sharp and .NET technologies, including three plus years as a senior .NET developer. So
the AI, based on that information, the AI has recommended this applicant for a first
round interview. Recommended equals true. So our workflow is coming
together. Great. Right. So now we've got to the point
where we're going to include the human in the loop functionality where the
person in charge of the interview process is emailed a summary of the relevant
applicants CV. And then at a glance, the manager can look at that summary sent
to him via email, can look at that email, and decide whether that applicant
qualifies for a first round interview. And we can actually use this human in the
loop functionality where we can attach two buttons to the relevant email, an approve
button and a decline button. So the manager in charge of the interview process can
look at that email, decide whether that applicant qualifies, and then the
applicant does qualify press the approve button or if the applicant does not qualify press
the decline button we're going to subsequently create functionality using an ai agent that
will automatically schedule an interview for one hour at an appropriate time
and we will use the google calendar api for this purpose
and we'll use an ai agent to use the google calendar api as a tool
and automatically schedule the interview within the
person in charge of the interview processes Google Calendar. So we're going to
use an AI agent for that purpose in just a bit. But for now, we're
going to include the human in the loop functionality. So to do that, we press
the plus icon there. So we can actually see that option there human in the
loop. So this is the option we want. So let's click the human in the
loop option here, and then we've got this Gmail option. So this human in the
loop functionality is going to manifest as an email that is sent to the person
in charge of the interview process where the interviewer can press approve or decline on
the relevant email. And that will automatically integrate with our
workflow. And you'll see how this works in just a bit. So let's click the
Gmail option here. Excellent. And it's automatically defaulted to this account here,
Gmail account for, for our credentials, because we've already set up, we've already set up
appropriate credentials for a previous send a message,
Gmail node. So we can simply use this and N8N is smart enough to default
us to that particular account. So we don't have to do anything here. Resource, it's
going to be a message. Operation here must be send and wait for. response. That's
very important. So the workflow will pause until the human in the loop, which will
be the manager in charge of the interview process, clicks the approve button or the
decline button. So that's the correct option there for the operation field. And then for
the to field, I'm just going to enter my address because I'm going to stand
in just for the sake of this example as the person in charge of the
interview process.
Great, so we've got a valid Gmail address there. And then for subject,
it's going to be approval required.
So that'll be the subject of the email that is sent to the person in
charge of the interview process, which I'm standing in for that person in
this particular example. Okay, great, and now we want create, we want to construct
the message. I'm going to just delete this connection. What I want to do is
get some data that we can use for the send a message step here. So
I'm going to execute this workflow here. Perfect. And that's executing.
Great. And we should have some valid output here now. So workflow executed successfully. And
I'm going to reconnect that to send a message here. And then I'm going to
go into the send a message node and you can see now we've got lots
of data we can work with. Our AI agent has constructed the correct output for
the relevant summary of the information regarding the applicant.
And this was obviously extracted from the relevant applicants CV
in PDF format for, in this particular case, Janet Clare Winslow. Great, and now we
can use this data to construct our message to the person in charge of the
interview process, which in this particular case is me. Okay, so I've actually
created that example for you to save you some time, the example of the
email message, and you can actually just download it or copy it from this
GitHub address. So from this file, that I've uploaded to GitHub, you can just
copy it here. So you can see here applicant details, and it's got a JavaScript
expression for the name and email address. And then you've got notable qualifications.
And you've got the relevant JavaScript expression there. And that's extracted from the summary that
we created in the previous node, which is an AI agent node, and notable work
experience. And then my recommendation here, is a more interesting part of this
particular message is that we've actually got the logic here and we've
got an inline if statement here where we're checking if the output recommended is true
if the json.output.recommended field is true then we want i recommend this applicant
added to the relevant email and if it's false we want i do not recommend
this applicant appended to the relevant email that's sent to the person in charge of
the interview process. Okay, and we can just copy this here.
Copy it and paste it into the appropriate field in N8N like this.
And you can see it's already gone green here. The expressions meaning that it's
picking up the correct fields. Yeah, I'm just going to give you an example of
how you would actually build that up the combination of static and dynamic content
within this message field. you can see here you've got the fixed option we need
to set to expression because these are expressions meaning it's dynamic content included
within the message field so for example this is how you would add the dynamic
content so let's just delete that field here and we've done this before so you
would just drag this full name json field from the input in this particular case
into the message appropriately like this in the relevant position you drag and drop the
JSON fields yeah that's in schema format you can also put it into JSON format
okay so we're pretty good there approval required and we've got our
message so we could actually test that at this point what I'm going to do
is go back to canvas here open AI agent here
Okay, I'm going to pin this data here just to make testing a bit easier
here from within the AI agent that proceeds in our workflow, the send a message
node here. Okay, and now let's see what happens
when we execute the step. Oh, sorry, there's one more thing we have to do
here. So we need to make sure that both the approval button the approve button
and the decline button appears within the relevant email. So to do that, we can
add options here, approval options, and we can,
for type of approval, we want to select approve and disapprove. So we want two
buttons included within our human in the loop functionality so that the person in charge
of the interview process can either approve the relevant applicant based on the summary sent
via email to the person in charge or can also reject the applicant, can
decline the application through another button. So we've got an approve button and a
decline button and you'll see that in action right now. So let's execute this step
and see what happens. Waiting for input and now that is
correct. You see in the output here it's got waiting for input. So this means
that The subsequent nodes, we don't have any subsequent nodes at the moment, but we
will be putting in the functionality to actually schedule an interview in the next step
of this workflow. But you can see it's still working. It is working at the
moment where it's saying waiting for input, meaning it's waiting for the human in the
loop to take action, some sort of action. In this case, the action will be
either clicking the approve button or the decline button. And let's see that now. So
let's go to my emails here. So I'm gonna go to my Gmail
account where it's sending the relevant
email and you can see here it's got me, primary, it's got approval required in
the subject. And this is the email that we want to look at. So approval
required in the subject and let's open that and you can see here we've got
the summary of the applicants So we've got the summary of the details that were
included in the PDF file sent via email to the person in charge of the
interview process. Years of experience with C sharp six notable qualifications. BSc honors
software engineering from the University of Birmingham 2016 Microsoft certified and you can see
all of this has been summarized for us and notably we have this decline button
and this approve button. Do we want to approve or decline this applicant? Six years
C-sharp experience. So at a glance, you can see that we probably want to approve
this applicant. And also you can see down here, my recommendation, that's the AI agent's
recommendation. So we're including intelligence within our workflow through an AI agent. And this
particular AI agent has looked at that data and looked at the criteria that we
gave the AI agent through our prompt. And it's decided that I recommend this applicant.
So this helps us with our decision. The AI agent is helping us decide whether
to reject or decline the applicant. And I think it's clear that this applicant should
be approved. So let's press the approve button like that. And we get this. Got
it. Thanks. This page can be closed now. Great. So it's received. Our workflow has
now received the human in the loop input and a clear action from the human
in the loop is now sent to our workflow. So we've either approved the applicant
or declined the applicant. In this case, we've approved the applicant by pressing this approved
button. Let's go back to our workflow. So you can see an N8N here. We've
actually received the data. Let's put that in JSON format. And you can see here
data approved, true. So this would have been false if we had
declined the application. Okay, so let's go back here. can pin
this data let's just pin that data just makes it a lot easier because we're
stepping through our workflow step by step so makes sense to pin our
data there so we don't have to run through the entire process when we test
our nodes as we add them to our workflow okay so let's just so we
can zoom out a little bit our workflow is growing this is sometimes called flow
gramming because we're creating a workflow This is like very declarative process. We're not
literally typing out code. So it's flowgramming. But there are a lot of similarities. We're
using a lot of concepts that you learn in coding, of course. So you've got
your for loop there or your while loop, whatever you want. You've got a loop.
And then we're about to add an if condition through a node. So very similar
to programming. You've got other things that are similar to programming, like separation of concerns.
We'll look at that in just a bit. But So for now, let's add an
if condition and we can do that through the if node. Let's press the plus
icon here, type in if and there we have it. We've got an if node
like this. So this is quite an easy part. We've got our output that we
pinned here approved, true. So for our condition, we can now establish our
condition and we want to. So this
is a Boolean. want this to be a Boolean condition, because we're we are
evaluating a Boolean value.
So in this particular case, it's actually very simple, we can just go if condition
is true like that.
So here we've got a a expression here at the moment, it's just hard coded
to false. So we must go to the expression here, remove that. And then we
can just drag and drop the approved field, which is now JSON format. In this
data, this data is in JSON format. And we can see clearly the approved field
and we can just drag and drop that into the field here. So this is
very easy to read if JSON dot data dot approved. So this could be false,
but it's true in this particular case is true. then we can attach another node
to the true condition denoted by a connector connected to
this if node and we'll see that now when we go back to Canvas. So
let's go back to Canvas and you've got true here and you've got false.
So if the applicant has been approved, we want to schedule that applicant
for a first round interview. So we want to add, node and AI agent in
this particular case, because we're going to get an AI agent to actually schedule the
interview in the person who's in charge of the interviews, calendar, Google Calendar.
So that's the next step. So we can actually just go hit this plus button
on the true connector here, hit plus, and then let's go AI agent.
And let's select the AI agent node here.
Okay, we should have access to some of the other data here and we do
you see all these other nodes here, we'll have access to the data
that has been created through the execution of the previous steps. And you can see
these are all stacked up in order here. So search files and folders that
basically extracted all the names of the files, the PDF files, looped over each of
these files, downloaded the file, extracted the information from the file, the AI agent then
summarized that information and sent a summary email to the person in charge
of the interview process. The person in charge of the interview process then clicked either
approve or decline. So if we go to this node here, you can see that
the person in charge of the interview process clearly approved applicant to be to go
for the first round interview okay so we need to replace this
user prompt here so let's look at the prompt let's go here and look at
the actual prompt i've created that already for you and it's been uploaded to
github so it's this one here interview scheduler ai agent 2 underscore prompt
let's open this and see what our prompt looks like I haven't created a system
prompt for this just for expediency, but you
can, you probably should create a system prompt basically defining the instructions,
the role of the AI agent and the rules pertaining to the behavior of the
AI agent. But just for speed, I've just created this as one large
prompt that I'm gonna put into the relevant field here,
the user. So firstly, let's go connect chat trigger node. We don't have a
chat trigger node that it usually creates by default when you add an AI agent
as your first node. So we don't have that chat trigger node. So let's select
define below here. And then we want expression here. Okay.
And then we can just copy this prompt like this and paste it in to
the field here. And that is telling the AI agent to
schedule the interview on the relevant calendar and you can see there's loads of green
here within the curly braces the double curly braces and these are
dynamic fields right so you've got for example interview with and then we've got the
full name of the applicant there and as demonstrated before you can
just drag and drop those fields here you've got email one so there's two people
are part of this interview process. You've got the interviewer and the interviewee. And
so they are part of this prompt here. Let's go through the prompt. So prompt
user message. You are an AI assistant that schedules interviews in Google
Calendar. Instructions. Fetch events. Call the Get Calendar
Events tool to retrieve all existing events between Monday, 12 o'clock
AM and Friday 11.59pm
of the next calendar week after and then the current date. This expression represents the
current date. If today is within this week, you must skip it. Only
consider next week. Okay, so we're just being very clear with the prompt. And then
find availability is the heading here. Analyze the retrieved events. Identify the
earliest available one hour free slot within working hours from 8 a.m. to 6 p.m.
local time. Do not select a time that overlaps with an existing event. Do
not schedule outside the 8 a.m. to 6 p.m. timeframe.
Only use dates from next week's Monday to Friday window. So I'm trying to be
as explicit as I can with this prompt. And then we've got the schedule event
heading here. Once a free slot is found, call the create calendar event
tool. So that's what we're going to do now. We're going to create that. We're
going to add that tool to our AI agent and we're going to name it
create calendar event. So let's go down here and you can see here we've got
tool. Let's press the plus button here and let's look for the relevant tool.
So it's Google calendar tool
and let's select that.
And the operation is automatically set to create there. Okay, and
we've actually got an account already set up for our to
use our Google Calendar tool, but we probably need to, we need to make sure
that the Google Calendar API is enabled. So I'm actually going to create new credentials
and go through it step by step. We want to select the create new credential
option here. And you can see we've got the client ID and the client secret
available to us. And so we need to create a client ID and a client
secret so that we can use the Google Calendar API. So let's go to
that Google Cloud URL that we should be now quite familiar with. It's gonna go
to Google, Google Cloud Console, that's what we
want. So we want Google Cloud Console.
Great. And let's select this item here. We're going to just use the same project.
We could create a new project. I know the project name is no longer really
appropriate. N8nPanicAppProject. That was our previous project from a previous example.
But we'll just use this project because all we want is credentials to use the
Google Calendar API. So we can... that within this project just
to save time but in the real world you probably want to create a new
project so let's go to library and let's search for Google
Calendar API and there it is great
and then let's select this top option here Google Calendar API and let's click the
enable button like that
Okay, brilliant, so we're enabling the Google Calendar API. Let's go to credentials
and we're going to create a new client ID and client
secrets. So let's go create OAuth client ID here.
Let's select web application. Web client four is fine for the name and then
authorize redirect URIs. So add URI, okay, and we've got We've got our URI
here. It's the same process. We've done this before. Click to copy and let's add
that there. So we're integrating these OAuth credentials into our N8N workflow. So
that N8N can have access to the Google Calendar API through this project. That's basically
what we're doing. So let's hit the create button. And then we've got a client
ID and client secret that we can use for this tool. So let's copy that
client ID. oops let's go to client id
there let's copy the client secret like that there
okay and then let's sign in with google
okay okay continue
and of course we have to consent so that n8n can have access to the
google and api and let's select all and let's select continue
here great so that's done there and
we've we can just go out of that there and i'm actually going to add
another tool while we're here i'm going to add another tool so let's go to
the ai agent and we also want a tool that will get
all of the interviewers scheduled events for next week,
so that our AI agent knows what events have already been scheduled and avoids scheduling
the interview on those dates, the dates that have already been booked. So we need
to get all of the events that have already been booked on the relevant person's
calendar. Let's hit this tool option here. And then we've got another
plus available to us so we can add another tool. In fact, wait a second,
so we haven't named this tool. We need to name this tool in line with
what our prompt has called the tool and it's create calendar event.
So let's name this create calendar event there. Okay, perfect.
Great, let's go back to the AI agent. So that's been named and
click there and we're going to create a new tool.
a new tool here and this is going to be google
calendar tool okay and this tool
operation must be set to get many like that excellent
okay and we're going to name this tool
calendar events here you can see we're referring to this tool in the prompt so
let's name it get get calendar events
like that okay great so we're slowly getting there
okay so we've actually got google calendar account three so we can use the same
account for this particular tool as we've used for
the other tool that we're using here. So we're using the same
credentials, Google Calendar Account 3 that we created for Create Calendar Event. We're using that,
those credentials also for Get Calendar Events. Excellent.
Okay, so let's open the Create Calendar Event node that represents the Create
Calendar Event tool. You can see here we've got start set to now and
end plus one hour. We actually want to use the prompt
to determine what these values should be. So let's click on this
button here next to the start field, which has the stars icon on it.
And let's press this button here. This means that this value will
be determined by the AI agent, and that's based on the prompt that we've given
the AI agent. And let's do the same for the end field. So this is
determining the start time and end time for the relevant interview.
So we want the AI to decide when
that start and end time is, and that logic is based on the prompt that
we've given to our AI agent. We can actually determine which calendar to use through
this field. So if we click on this field, you can see that a particular
Gmail address is presented to you and that identifies the calendar to choose. And
we have this item presented to us because of the account that we've created in
the credentials here. So that is automatically displayed to us in the calendar field here.
So select that email. email or Gmail address like that.
Great. So we've got the prompt determining the start and end time for the particular
interview. And the other thing, when we have the relevant events displayed on our calendars,
we want to include certain fields. So we can actually do that by adding a
field here. So first want to add a attendees
field. And there's two attendees. I'm going to add two of these fields. But firstly,
let's click the star icon next to this first attendee field here. And this
will and this means the same thing basically that the AI agent determines
the value of this particular field. So let's click the star here. Okay, and let's
add another attendee and do the same. So it's going to determine the two attendees
that will be at the particular interview. So there'll be an interviewer and an
interviewee, obviously. And based on the prompt that we've given to our AI agent, it
will be smart enough to determine the attendees. Okay, great. And we want to add
a new field and we want the description field there. And let's click the
stars icon here. So we've got description and then we want summary.
OK, and click the stars icon here next to the summary field. Let's go back
to Canvas and let's go to the Get Calendar Events tool node here.
And of course, we want to also map this to the appropriate calendar. So let's
see if our email address is present within the list for the calendar. And
yes, we've got a valid email address because we're using the same credentials to connect
from NA10 to our Google account. So we can just select that
email address to denote which calendar to use for scheduling the relevant interview.
Okay, excellent. And then it's the same process here. We want return all. So
return everything from the relevant query here. And then we want after
before fields, and we want the AI to determine what these fields are. So let's
click the star here. to these fields after and before like that. And this is
because we want our AI agents to intelligently determine what the data for these fields
will be. So we want the AI agent to determine what has already been booked
the following week on the relevant person's calendar. So
when I say person, I mean the person in charge of the interview process. then
we also want the AI agent to intelligently determine when to schedule the interviews. And
we're using, and this is why we're pressing these, the star icon next to the
relevant fields for each of these fields, so that we're relying on the AI agent
to intelligently determine the values of these fields so that it can carry out the
task of scheduling the relevant interviews. And we're using the get calendar events to get
all the events that have currently being scheduled for the person in charge of the
interview process. So if we go back to the canvas here, and we're going to
create calendar event, we are using these
fields to be displayed on the
relevant calendar for the events. We're using this tool to schedule the
actual interview and block off the time based on the start and end
fields here, which are being intelligently determined by the AI agent. And that's denoted by
us pressing the button next to the relevant fields, which have the star icon on
those buttons. And then here we know there's two attendees. And we want
the AI agent to intelligently determine who those attendees will be based on the
prompt that we've given to the AI agent. And we also want the description and
the summary of the particular event to be extracted from the prompt and
displayed appropriately on the calendar. We could actually execute this now and see if our
AI agent does what we expect it to do. So let's execute
a workflow here.
Okay, and a chat model sub node must be connected and enabled. Okay, so we
haven't yet given AI agent, a chat model. So that's very easy to do.
We've done it before. Let's click the plus icon here for the AI agent here.
The AI agent here. And of course, we want open AI and we've got an
account set up for open AI. So it makes it easy for us to attach
the relevant chat model. So I'm just going to click plus here. Of course, the
relevant window shoots out from the right of our screens. And we've got a number
of models to choose from. But we want open AI chat model here. It's automatically
selected the credentials that we set up earlier. And we want GPT 4.1 mini selected
here from the model list. We've got a range of models to choose from here,
but we want GPT 4.1 mini. Great. Okay. Excellent. So
that was why we got that error when we tried to run this workflow. Let's
try again. Okay.
Excellent workflow executed successfully. So it should have taken the first CV, processed
it. And we've actually approved
that CV because we pinned the data there. That's why it didn't pause for the
human in the loop action when we ran our workflow. Because we pinned the data
here on this node here. So approved equals true. So it's gone through the entire
process. And we can see now whether an interview has been
appropriately scheduled. So I'm going to go to my Google Calendar.
Yeah, like this, I'm logged in with my credentials, go to my calendar. And
then we've asked it to Schedule the interview for the following week sometime and if
we go to Monday the following week. That's
Sunday, Monday. Look at that interview with Janet Claire
Winslow. Okay, eight to nine a.m. And there we have it. Those are just fake
addresses that are included in the prompt for the attendees. So it's intelligently our AI
agent has intelligently extracted those email addresses and included it part of the information pertaining
to this particular event that has been scheduled on our calendar for the following week.
So basically, our prompt is working. So that's great. So I'm just going to
delete that because we're going to run the entire process through now. So
I'm going to delete that. So don't send right, let's delete that there. Let's keep
that open. And we're going to now go back to our
8n workflow here. And so that is fundamentally working. I'm going to go back on
these nodes here and I'm going to unpin the data. Okay, so let's go back
to Canvas. Let's go to this human in the loop node here, the send a
message node here. And I want to unpin the data there so that we could
run this workflow through properly. Okay, so anything that we any
data that we've pinned, we want to unpin now. because we're gonna run through all
eight of those CVs and we wanted them to be processed
appropriately and we want the relevant interviews to be scheduled automatically. So
let's unpin any data that's been pinned. So I'm unpinning the
data here. Great, and then we need to adjust this workflow now. We
actually want to connect this, from the AI
agent. So once it's finished scheduling the interview, and this is based on whether the
human in the loop has approved the application. So it goes through the AI agent,
schedules the interview, and then we want it to go to the next item in
the loop. So to do that, we can just take that connector and connect it
to the loop over items node like that. So
subsequently moves on to the next applicant's CV to be processed.
Then we also wanted to do the same thing when the
applicant has been declined, the approved field will be false, meaning that this
connector false here becomes relevant. In the event that the human in the loop declines
a particular applicant's application, we want it also to move on to the
next item in the loop, to the next CV. We don't want an interview scheduled,
so it doesn't go to the AI agent node here. So what we can do
for the false connector is we can connect that back into the loop like this
so that it actually bypasses the AI
agent node here and then of course won't schedule an interview on the relevant
calendar. Okay. Great.
Okay. Excellent, so we're ready now to actually
run this workflow through in its entirety. So it's gonna take all eight CVs and
process them. And with each item in the process, there will be a human in
the loop. So we will have to open an email and either approve or decline
the applicant's application. Okay, so let's see this in action. I'm gonna go to
Safari here and I'm going to open a new tab here. I'm going to go
to my email. I am the person in charge of the interview process. So I'm
the human in the loop. So I should receive eight emails. And with each email
that I receive, in order for the workflow to progress, I need to either click
the approve or decline button, which denotes whether I'm accepting that
applicant for a first round interview or rejecting that applicant so that applicant doesn't go
forward for a first round interview. Okay, so before we do that, there's one
thing I'd like to actually do in NA10 within the prompt here.
And I urge you to do the same thing. So I'm just going to open
the prompt here. And
this these fake email addresses here are actually going to cause you to
receive mail delivery errors. So you can see
this portion of the prompt, we have attendees and two email addresses. I'm actually going
to include two valid email addresses here. So we don't get those mail delivery
errors because these email addresses are not real email addresses. So these are just
obviously example email addresses and they actually wouldn't be hard coded. You would drag and
drop the relevant email addresses from one of the fields
from one of the steps that's been executed here. So these would be
dynamic fields. But in this particular case, I'm just going to hard code them to
email addresses that I know are valid. Okay, so...
I'm just going to save that there. Let's go back to Canvas here.
And now it's going to we're going to execute this workflow in its entirety. So
the first thing that we're going to see is that it's going to pause and
it's going to pause for each iteration. So it's going to pause eight times, meaning
we have to open the relevant email and either approve or decline the applicant. So
let's run through this workflow, execute workflow, and off it goes.
And you can see it's paused at this point here for send email. And this
is the human in the loop part of the workflow. So let's go to I'm
going to go to Safari here, we're going to go to my emails. And just
refresh that. And you can see here I've received an email approval required. So
let's open that email. And you can see we've got the summarized information about the
applicant, Janet Claire Winslow, that's her email address. Years of experience with C Sharp,
six, okay, that's looking good. And we can go through all of the summarized information
and determine whether we want to approve this applicant or not. And we've got the
AI's recommendation, my recommendation, I recommend this applicant. So let's approve Janet
Winslow for first round interview for this role of C Sharp Senior Developer. So let's
hit the approve button here. Great, got it, thanks. The page
can be closed. So we've approved Janet Winslow and we can go back here. You
can see it's working. Great, okay. It's going through and it's
paused. Let's send a message and we should have received another email for the second
iteration. There it is, approval required for the second iteration
of the loop. Four years experience. My recommendation, I recommend this applicant. So I'm going
to approve this applicant. Okay, go back to N8N
and it's scheduling the interview for the second applicant there. That's what our AI agent
is doing here. You can see it in motion. That's very cool. Graphical user interface
feature where you can see everything in motion and it's got to send a message
and it's stopped. So this is the human in the loop part of the workflow
and we need to actually go back to our Gmail here. And we
need to approve or decline this applicant. Let's see what we've got here. Three years
experience, not too bad. Got some notable work experience here, which I'm impressed with and
qualifications. Great. So let's approve Craig Matthew Roberts. Okay, so
approve. Go back to N8N. Scheduling the interview for
Matthew Roberts. Okay, and it's going through the process. And it stopped at send a
message. we need to do the same thing. We need to either approve or decline
this applicant to the fourth iteration, fourth applicant, let's go to approval required here. Wow,
so this person's got seven years of experience, we definitely want to see this person.
And the AI has recommended the applicant. So let's approve this applicant.
Let's go back to N8N. And it's going on to the fifth applicants
application, it's going through the workflow here, you can see, It stopped at send a
message, which is predictable. So let's go here. So this is the fifth iteration of
the loop. We've got eight to go through. And let's open this. No years of
experience with C sharp. Okay, this doesn't look great. He's experienced with Python, we need
a C sharp developer. Okay, I do not recommend this applicant the AI says, so
let's decline this applicant. Let's go back to N8N. And you can see it hasn't
gone through the AI agent one here. create
an interview event within the relevant calendar and it's actually gone on to
process the next applicant and stopped at send a message this is the human in
the loop part of the process so let's go back here
and see what information has been summarized for the sixth
applicant four years c-sharp experience that's looking good i recommend this applicant right
approve okay so we're approving the sixth applicant here and as you can see
there it's going through the process of adding the interview to the calendar
scheduling a one hour first round interview for this particular candidate for the sixth iteration
of the loop the sixth applicant if you like and it stopped at send a
message which is the human in the loop part of the workflow let's go back
here Let's see what information we have for this next applicant. One, two, three,
four, five, six, seven. So this is the seventh applicant. Zero work
experience. No, we can't have that for C-sharp. I do not recommend this applicant. So
we're going to decline this applicant. And let's go back to N8N. And you can
see it's gone to the next iteration of the loop. And it hasn't scheduled an
interview for the seventh applicant. And we're now at... The eighth applicant, we're at the
human in the loop part of the workflow. So let's go back here to our
Gmail. Let's refresh this. Okay, and do we approve the eighth applicant? Five years
experience, C sharp experience, excellent credentials here. We like this applicant. My recommendation,
I recommend this applicant says our AI agent. So let's approve that. Brilliant.
And it's processing the last of our
applicants there. And that's it, our workflow is executed successfully. So
let's now go to our calendar and see what's going on.
Look at that. So it's scheduled six interviews for Monday,
each in a one hour slot. You can see Janet Claire Winslow, Andrew Michael Johnson,
Craig Matthew Roberts, Brenda Jones,
Jessica Louise Bailey, and James Edward Randall. They've all
had interviews scheduled. They all were approved by our human in the loop process here.
And they've been appropriately scheduled by our AI agents. So that is just awesome.
I'm really happy with that. And you can see that it's added a description here.
Interview with Janet Claire Winslow. Interview with... So it's extracted... AI agent has
determined the field values that we want to see on our calendar for us.
And it's also determined at which times to schedule the interview. So this is a
great example of using intelligence, AI
intelligence in your applications, in your workflows. Okay, and now the last thing I want
to do here is I want to extract these nodes here.
AI agent one node and the tools and the model, the sub nodes that are
attached to the AI agent here. And I want to put that into a sub
workflow. So this is a way that you can make your workflows look less complex.
Because as you can see, there's a lot of nodes here, it's becoming a bit
of a spider's web. And we want to neaten it up a little bit. So
we can actually do that by removing some of our nodes here into a
sub workflow. going to show you how to do that now. So I'm going to
copy this address here, I'm going to open a new tab. So we're going to
n8n through another tab and we're going to create a new workflow. So I'm
going to go to my workflows here, create workflow. And here we're actually going to
create a new workflow, a new sub workflow. Okay, so I'm
going to bin this connection here. And I'm going to bin
connection here okay and i'm going to copy all of these nodes here
so select each of these nodes i'm going to copy all of that
and i'm going to paste it here within our new sub workflow like that
i'm going to name this sub workflow ai agent
interview
because you see this sub workflow could potentially be executed with a few tweaks
executed by other parent workflows if you like. So it's good
practice to separate concerns. So this can be its own concern.
And then your workflows can actually evolve and be worked on in parallel
to the other workflows with breaking the other workflows that call this child workflow.
So it's very similar to programming concepts when it comes to separation of concerns. So
we should strive to do that when we're flowgramming with our workflows also.
So you can see there's a lot of commonality with flowgramming and programming. We've got
loops, we've got if conditions, and we've got separation of concerns now. Okay.
Let's find the execute sub workflow node. That's what we need to do. This workflow
is going to be executed from another workflow. So we need to add this
execute sub workflow node to our
sub workflow here. So when executed by another workflow, this is the node we want.
So it's a trigger node. Let's add it there like that. We need to add
two fields because two field values are going to be passed from the parent workflow
to this child workflow, to the sub workflow. So we want to add a full
name field here. So full name, and it's a string.
And we want to also add email like that. And it's also a string. Add
field, right? So those fields have been added. Let's save that. Perfect.
Let's go back to canvas. Now we want to connect that to our AI agent.
Like that. Brilliant. Okay, so
let's save that we've got AI agent interview scheduler there. So let's go back to
our workflow here. Just going to leave those there for now.
And we want to now attach instead of attaching this AI agent and all its
sub nodes here. I want to attach this to the sub workflow here.
So let's see how we can do that. So we can go hit this plus
icon here. And we need to
find the execute sub node. There it is, the execute
sub workflow option. There it is, let's select
that. So let's select that. Excellent.
And we've got a list of workflows available to us here. Click that button there.
And we've got AI Agent Interview Scheduler. So let's select that. Okay, and look at
that. Our parameters have been presented to us, full name and email that we need
to add information to. So let's do that full name. So the full name
will be the name of the
applicant. So let's go to the first AI agent here
and let's drag in full name like that. Full name there. You would want to
include the interviewees email address here. I'm just simplifying this example for
testing purposes. So I'm going to put in whatever email address here. So Craig
Johnson at hotmail.com. So this isn't even a real, as far
as I know, a real email address. Okay, johnson at hotmail.com.
Okay. Great. Let's go back here and
let's try to execute our entire workflow.
Okay, and we need to do the human in the loop thing. There it is.
I'm just going to approve. Let's go back there. Again,
reference node doesn't exist.
Let's open this here.
Okay, and it's actually erroring because of this here. So the
reason it's actually erroring, see it in red here within our prompt interview with is
because we need to wire it up to this full name field here because obviously
we've changed from using the ai agent one directly we're now using this ai agent
through a sub workflow so i'm going to remove that there from the prompt and
i'm going to drag that there so now that's turned green which means it's valid
within our workflow and that should work and we're not actually using
email address within our prompt, we've actually hard coded those values. So this is just
there for the sake of the example. In the real world, you'd want to have
this email address inserted into the prompt dynamically. Okay, let's go back
here. Let's try again, let's execute workflow.
Okay, let's go to the human in the loop part here.
arrive in our email soon.
Okay, and I'm going to just approve this. Yeah. Great.
Okay, let's go back here. Problem and call to AI scheduler
reference node doesn't exist. And we've received quite a few errors here. And the reason
is, is that I'm a reference to this full name field in more than one
place so i thought i'd fixed the issue here but we've also got a problem
down here and you can see that because this javascript expression is in red here
so let's remove that and drag and drop full name onto the prompt field here
in the appropriate place so interview with and then that's a dynamic field there right
so we're back at our workflow here So we've actually copied and pasted that to
our sub workflow, these nodes here. We'll delete them in a bit. We've got this
call AI agent interview node here now that we've created. It executes the sub workflow
and we've set this up accordingly. Now let's try and run through our
workflow again. Execute workflow and hopefully everything works
accordingly. So it'll get to the send a message. This is the human in the
loop part. A bit annoying having to go back here every time and for testing.
So you might want to pin your data when testing this process. So I'm just
going to open this email and then I'm going to approve it and go back
to N8N. Okay, and it's calling the AI agent interview
sub workflow. Note it workflow executed successfully. Great, so now we
have successfully extracted nodes that
to do with the AI scheduling, sorry, the calendar interview scheduling functionality, and we've put
it into its own sub workflow, and we're calling it from the main workflow here.
So we've created a separation of concerns. And we could actually reuse this potentially,
with a few tweaks, reuse this sub workflow from other parent workflows,
from other main workflows, to actually handle the scheduling
So we go back here and we can delete these now because we're executing those
from our sub workflow. And then we want to connect this
back to the loop. So once it's finished scheduling the interview for a
particular applicant, we want it to go to the next applicant in the loop. So
let's connect that now to the loop. And now we can just go and test
the entire workflow and it should work. expected.
Excellent. So let's do that. Let's go for it. So we're now testing the entire
workflow. And of course, it's going to pause at the human in the loop section
here.
And if we go to our calendar, you can see we've got loads of interviews
scheduled. And it seems to be working, it seems to have avoided scheduling an
interviewee for a first round interview and it's created a whole bunch more
interview events here. I'm not saying that that prompt is going to be perfect. It
might not work as expected all the time for scheduling the actual interview. This is
more about the workflows and it's a beginner's course. So I haven't gone deep into
prompt engineering. So you may have to add more detail to your prompt. And that's
what it's all about. It's about being explicit with your prompts to get the functionality
you want. of your AI agents. So you may have to be a little bit
more sophisticated with your prompt engineering for this particular part of the workflow.
But it basically works. The idea at least comes across with this example.
So in this part of the video, won't be building and demonstrating the creation of
workflows step by step. This is just to show you a few extras. Hopefully while
we do this, some ideas will come flooding to you and you can create the
next big thing. So check this out. Going back to the first example. So we
had this example here where we created a chat bot, but we're using the
integrated chat message received trigger here. converse with our chatbot
here, which is simply just sort of like a ranking app where you can ask
the AI agent questions about, you know, what are the top five best
rugby players in the world? Or what are the top five best rugby nations in
the world? Which is what we asked our chatbot earlier. What are the top five
richest countries in the world? You know, that sort of thing. So, we could ask
what are the largest mammals on
earth? Blue whale, fin whale, sperm
whale, humpback whale, African elephant. Cool. So our chatbot is working.
But what I wanted to show you here is we can integrate whatever interface we
want for our chatbot using So I've prepared this
example here, example one chatbot with WhatsApp. So we worked with WhatsApp when we created
the Panic app. But what I've done here is instead of using that integrated input
utility that we just used to converse with our chatbot, I've attached a WhatsApp trigger
here and I've set up WhatsApp appropriately. And we should be able to use WhatsApp
now to converse with our chatbot and ask our chatbot
various questions about ranked items in the world. Like for example, what are the top
five movies of all time? Okay, great. So I'm going to execute workflow there.
Okay, excellent. So that's executed. This is the desktop version of WhatsApp.
Of course, you could use your actual phone for this. Now I should be able
to converse with my chatbot. So what are the
top five fastest cars on
Earth.
Excellent. And there we have a response from our chat bot. So that seems to
be working correctly. Who are the top five movie
stars in the in the
world? Let's put that live. I'm just going to
switch that to active like that. Okay, so this
should be live now and we should be able to run that now. So who
are the top five movie
stars in the world?
Excellent. Dwayne Johnson, Scarlett Johansson. I mean, this is obviously up for debate. Leonardo DiCaprio,
Tom Cruise, Jennifer Lawrence. Okay, cool. Who would be the next
five? Remember, we've actually added memory, simple memory here. So our
chatbot should retain context. So we should be able to converse with our
chatbot. So who would be the next five? Let's see what our chatbot says.
I had Pert, Natalie Portman, Robert Downey Jr, Angelina Jolie, Chris Hemsworth. And of
course, you're not restricted to WhatsApp through N8N. You could, for example, use
Discord. You could use Telegram. And there's many integrations that you can
choose from here. So we created the registration part of our WhatsApp panic
app here. And you can see here, we created this trigger.
So you can see here it's actually using the N8N created form, but what if
we wanted to integrate this data capture form within our own website for
example, or we wanted to integrate it into a third party website for some reason
so that the user could register from another website. Well, I've prepared this example
where we can actually use a webhook to accept any data
posted via HTTP to our webhook, to a webhook that we create within our
N8N workflow. So if we open this particular example here, you can see here we
have this webhook node here. So if we go into that webhook node,
what I'm going to do here is I'm going to copy this URL here
and we can execute that workflow. And then I can use an application like
to post data
via HTTP to our webhook. That's how we can integrate our form that resides
within a third-party website with our N8N workflow. Rather than just using the default web
form that N8N provides, we can use our own web form integrated into our website
and submit this data via HTTP a webhook which
has its own URL. You can see here it's got its own URL. Okay, one
for testing and it's currently listening, one for testing and one for production. But it's
currently waiting for us to send that information, to send that data. So
if we send that, great, workflow has started.
So it should have workflow executed successfully. So let's look at our spreadsheet. There it
is. information has been registered. So this user Howie Plunk
has been registered for the WhatsApp Panic app.
So that's great. So that's kind of showing you how N8N is not restricted to
the integrations that you can use from within N8N like WhatsApp, Discord or whatever. You
can also integrate your own custom websites into your workflows.
using a webhook, for example. Okay, now I want to show you another way in
which N8n is not restricted is that you can actually make HTTP requests
from your N8n workflow. And you do that using the HTTP requests node.
So I've prepared this example here. And this is kind of was kind of experimental.
So it's a little bit messy. I just want to show you a few things
here. So we've got the HTTP request node integrated here into our application. If we
open that, you can see there's a specific URL that I want to make a
GET request to. We recently published a Go, a Gingonic Go course
on FreeCodeCamp. And this is one of the endpoints that I created using Go. And
it basically returns a list of movies with this associated genres and the
sentiment attached from movie reviews to the relevant movies. So
I just want to show you how we can actually make a call to this
particular endpoint from within an N8N workflow. So we can use that
information returned from an endpoint of a custom application that we've
created. And we can use that as the data chatbot application or
an AI agent application. So it's just starting the instance, I'm just waking it up
here. Great. And it's returned the movie information that I want. So you can see
a Shawshank redemption. And we're using the HTTP request node here. So we can execute
this step here. And you can see it makes a request to
the endpoint, the endpoint that is part of the magic stream application. and it returns
data about the movies here then i found that because of the levels in the
hierarchy here that i was unable to effectively prompt the ai
agent here i think is quite a good example of how you can use code
to reformat your data before it is sent through to another node like this ai
agent node for example if you needed intelligence to reside within your workflow so what
i was able to do so from this node is outputting the data that has
been returned from the relevant endpoint in
MagicStream. And then I was able to create this JavaScript code using the
code node from within N8n that flattens out the data
as it were. So it flattens this hierarchy into a more readable format for our
AI agent. So this is example of how you can integrate code
into your N8N workflows. And here I've integrated some JavaScript code so that I can
take the inputted data that could be returned, for example, as is the case here,
from an endpoint. And I'm flattening out that data so that
it is more digestible, if you like, for our AI agent here. And that's
all that that code does. It transforms this data one format to another. And that's
for a specific purpose, so that our AI agent can read in that data and
provide us with intelligent responses based on the data. So if we go back to
Canvas here, got another example here. So we've got this HTTP request
where we can post requests and make get requests to a specific endpoint like an
API, you could also use this HTTP request for web scraping, you could navigate to
a specific HTML web page and scrape relevant data through subsequent functionality.
But for this example here, what I was able to do was use a
HTTP request tool. So that's slightly different from the HTTP request node. We've also got
the HTTP request tool that you could add as a tool your
AI agent. And I actually found that using this tool, I didn't have to create
any JavaScript to flatten out the data in order for this AI agent to digest
the data returned from the call to the relevant MagicStream API endpoint. I found that
it was actually able to read that data effectively and make intelligent responses.
So
You can see here your role is to provide helpful insights about movies and your
instructions. Please use the HTTP request tool to get the
data for the movies, which will be a data source used for
responding to user queries. So we've got our prompt all set up there and we've
got our chat input. What do you recommend for movies in the thriller genre? And
let's execute this step and see what happens. Okay, so
this is what we get back. For thriller genre, I recommend Knives Out.
Excellent ranking with a fantastic story and sublime acting. Blitz, excellent
rating. Described as a lovely movie. Jack Reacher also rated
excellent, offering a wonderful experience. These are top rated thriller movies
from the data. So it's read in the data. it's provided
us with an intelligent response based on the data. So it's used the HTTP request
tool to read the data returned from the relevant
MagicStream API endpoint. So that's just a list of movies with associated genres and relevant
ratings and movie reviews with the sentiment extracted from those movie reviews
saved within that data. And based on that data, our chatbot
created this intelligent response to our query. What do
you recommend for movies in the thriller genre? So I just wanted to show you
those examples to hopefully illustrate how there are very few limitations
as to what you can do with these workflows. So they are very, very powerful.
I hope you've enjoyed this video as much as I enjoyed creating it. Please let
me know what workflow automation ideas you come up with so that I can steal
your idea and make a billion dollars. I would never do that. Maybe keep those
billion dollar ideas to yourself. I hope to see you soon. Thank you and take
care.
Learn n8n in this full course for beginners from @GavinLon. n8n is an open-source workflow automation platform that lets you connect different apps, APIs, and services to easily automate tasks without needing to implement extensive code. You'll learn the practical steps of setting up n8n and then dive into four comprehensive workflow examples, including an AI-powered chatbot and an emergency WhatsApp notification system. Support Files on GitHub: https://github.com/GavinLonDigital/n8n_FCC_Workflows_Support_Docs OAuth2 Explainer Video: https://youtu.be/-ENPtwwW-tQ Get a domain and hosting here: https://www.hostinger.com/start đď¸ Hostinger provided a grant to make this course possible. âď¸ Contents âď¸ - 0:00:00 Introduction - 0:10:35 Discussing Internet Standards, REST and OAuth2 - 0:14:49 Getting Started - Setup n8n on Hostinger (self-hosted) - 0:18:36 Create First Workflow Example (AI - Chatbot) - 0:21:23 Add an AIAgent Node to Workflow - 0:25:00 Add OpenAI Chat Model sub node to AiAgent Node - 0:26:49 Add Credentials to OpenAI Chat Model sub node - 0:33:40 Add a System Prompt to AIAgent Node - 0:41:00 Add Memory Sub Node to AiAgent (to Add Context) - 0:43:35 Test ChatBot WorkFlow - 0:45:27 Logging on to Hostinger and n8n - 0:46:42 Create Workflow Example 2 (WhatsApp Panic App Registration) - 0:47:10 Create Google Spreadsheet - 0:49:47 Add and Setup OnSubmission Form Trigger Node - 0:58:03 Add and Setup Google Sheets Node - 0:58:49 Setup Credentials for Google Sheets Node (using OAuth2) - 1:15:22 Create Workflow Example 3 (WhatsApp Panic Notifications) - 1:17:27 Add WhatsApp Trigger Node and Setup Credentials - 1:29:27 Setup other Workflow Nodes (WhatsApp Panic Notifications) - 1:45:32 Test WhatsApp Panic App Notifications Workflow - 1:47:43 Create Workflow Example 4 (CV Approval / Interview Scheduler) - 1:52:32 Setup Google Drive Node and Configure Credentials - 2:01:33 Setup Loop Node - 2:16:59 Setup Human in the Loop Node - 2:31:03 Setup AIAgent Node for Scheduling Interview on Google Calendar - 2:54:21 Test CV Approval / Interview Scheduler Workflow - Human in the Loop - 3:04:06 Abstract Sub-WorkFlow to Create Separation of Concerns - 3:15:39 Extra Information - 3:15:59 Use WhatsApp to Converse with ChatBot in Example 1 - 3:19:57 Use A WebHook Trigger Node to Trigger your Workflow - 3:22:32 Use the HttpRequest node to make Requests to External Web Apis From Workflow - 3:24:24 Integrate JavaScript Code into Workflow using Code Node - 3:28:58 Outro