- [Instructor] Okay.
So let's give our agent access to a third tool,
in this case the tool to generate a quotation.
Now in this workflow,
there's a lot of things going on,
so we won't be building
this workflow from scratch,
but instead import it from a workflow
that I built before for you.
So for that, go to our repository,
and navigate to the N8N workflows folder.
And in here you will find
a presales agent quote tool.JSON file.
Select this one,
and make sure to download the raw file,
and go back to N8N.
In here, create a new workflow,
and select import from file.
Select the JSON that we just downloaded.
And there you go.
You should see the entire quote generation
process in front of you.
Now let's see how this workflow
is actually working.
Open the when executed by another workflow
trigger node here,
and you can see that this is the data
that this workflow is essentially expecting.
These are two things.
The first thing here is the data object
that we got as a response
from our calculator tool.
Information about the boost type
that should be quoted.
And second, the information about the client.
This is something that the bot has to find out
by asking the client
for their contact information and their company.
When you import this into your N8N instance,
you will probably see some warning signs
on the GitHub icon here.
This is because this is by default
set up to be connected
with my personal GitHub account.
And of course, you have to replace that
with your own username.
So in this case, just update the repository owner
with your own GitHub username,
and make sure that our course repository
is listed from here.
And you would need to do this
for all the three GitHub notes
here in this workflow.
So to demonstrate what this workflow is doing,
let's execute it one time,
and then I can walk you through this.
So at the beginning you can see
there are essentially two path going on.
The first path is to get a template from GitHub.
So this HTML template
will be used to create our quotes.
Let me show you how that template looks.
If you go to our repository,
and then navigate two tools,
quotes,
and template,
you will find this HTML file here.
Now, feel free to download this HTML file.
And then let's take a look.
So this is a simple dummy document,
but you can see what's going on here.
There's some placeholders for variables
that are coming in,
like the client name, our organization's name,
the quote ID,
the date, and of course
the actual thing that should be quoted.
And what the N8N flow
is essentially doing is just replace
those variables with the variables
that are coming in in our workflow.
So let's see how that works.
So we need two things.
The first thing is the HTML document,
which we get from this simple HTTP request.
This is just downloading the HTML source code
from GitHub.
And then second,
the variables that came in
from our workflow execution.
In this code sale,
we're actually modifying them a little bit
to for example,
generate a quote ID automatically
based on the current date,
and also calculate the date
until which the quote should be valid.
All the other information
are pulled in from the incoming documents
or they are defined with standard values
like for example,
our own sales email address here.
So let's close this for now.
This merge node
is then bringing everything together,
the data from the HTML document
plus our variables.
And then in the next code node,
this is simply a regular expression
that is replacing the variables
with the variable placeholders
in our HTML document.
And it returns an HTML document
that now contains the replaced variables.
So you can see how that looks here
because on GitHub,
it will automatically create a file
with the updated quote,
and we can take a look how that quote looks.
So if we go to quotes and go to new,
this is where these quotes have been stored,
and let's take a look at the quote
that we just generated.
Let's download this one.
And
there you go.
This is the quote that was just generated
on the fly.
Just to make sure,
there is no large language model
involved here at this stage.
The large language model
is really just giving the information
to this workflow,
and then this workflow is doing a simple search,
and replace option.
This is done by design.
We don't want the LLM
to generate the quote on the fly.
There could be too many sources of error
or manipulation.
We want to leave this encapsulated
into a deterministic workflow
where no AI is involved.
This is just really
putting in all the information
that we already collected
into the quote process here.
Now, what's actually coming out of the workflow
that we have in N8N?
Because we can't simply give a binary file
back to the agent,
it couldn't work with that binary file,
or it would be really, really complicated
for the agent to do this.
So instead, what we return is just a URL.
In this case,
it's a URL to the HTML file hosted on GitHub
with this little prefix here that is allowing us
to render this file on the fly.
So to show you how that works,
let me just execute this workflow once more
so we get a fresh URL that is being generated.
And you can see this is the URL
that would now be returned to the agent.
If we copy this URL,
and paste it into the browser,
we will automatically get a rendered version
of this quotation.
And this is now something we can
either give to the client directly
inside the chat,
or this is something we could plug into an email
that we send out to that person,
which is exactly
what we're gonna do in the next steps.
But before we get there,
let's first go back,
and see how we now bring this workflow
back to N8N and give our agent
access to this little quote tool
that we have just built.
And I'll see you on the next video for that.