- [Instructor] In this lesson, we'll build a simple
knowledge retrieval workflow from scratch.
This is the first tool our agent will be able to access.
Create a new workflow,
and let's name this, knowledge tool.
So quick heads up, this is a very lightweight example.
Perfect for short documents with just a few pages
that don't require a complex RAG,
retrieval augmented generation setup.
For a full retrieval setup,
see my other course, build a custom chat bot with n8n.
The goal of this workflow is to grab a file
from an external source, in this case GitHub.
Let's see our file.
Navigate to tools,
knowledge, docs,
and then the conference details markdown file.
So this is the file we want our agent to be able to query
to get information about our conference as needed.
So let's head back to n8n
and start with a workflow trigger.
We want to choose when executed by another workflow.
For input data mode, make sure you select
define using fields below,
and then add one field, which you call question.
Make sure type is set to string.
Click execute step.
And as you can see, this is currently empty.
Now we want to pin a simple test question,
so we can actually use that during development.
Hit edit,
and then enter a small test question like
what halls are available.
Hit save, and you can now see that this data
is pinned for test executions.
Great.
Next, let's close this and add the next node.
So next, let's add a node to GitHub
so we can download our documents.
Search for GitHub,
and then select list files.
Here make sure you're connected to a GitHub account.
If that's not the case,
just click this little dot drop menu,
click create new credentials,
select this one OAuth2
and select connect my account.
Make sure you already logged into GitHub,
and then you should see this success message.
Let's close this window for now
and then put your own GitHub username in this field.
Next, select the forked repository here from your list.
Then we put in the path to our knowledge documents.
In this case that's
tools/knowledge/docs.
Hit execute step.
Let's fix the typo here.
Hit execute step.
And there we are.
So you should now see the markdown document
listed here on the right side.
Let's close this window.
And next, let's add a node to download this file actually.
We don't have to insert everything manually,
just duplicate this node
and let's wire them up.
Open this one, and instead of listing file operation,
now select Get.
We now have to replace the file path with the file path
of the actual document.
We can simply pull that over from here.
And there we go.
That's it.
Just hit execute step.
And you should see that we have now downloaded
this markdown file.
So let's close this.
And since this is a binary file,
let's now extract the text from this file.
Search for extract from file,
and then select extract from text file.
We can leave the standard settings here, hit execute.
And there you see, this is our file content
in plain text format.
So what do we do with this?
We now feed in this entire text file into
the context of an LLM, so the LLM can then answer questions
based on that information.
In this case, we don't need an agent,
we just need a call to a simple model.
So look for Gemini and select this Google Gemini node.
This will allow us to message a model
and just send text to it and get some text back.
Select message a model, make sure it's connected
to your Gemini API key.
The resource should be text, operation is message a model.
And then let's pick a model from list.
We are also using Gemini 2.5 flash here.
These models support context windows up to 1 million tokens.
So there's plenty of text you can put in here.
Now, as a prompt, we want to insert the question
that we got at the beginning of the workflow.
Let's pull that over and you can see the user
asks now what halls are available.
And to answer that, of course, we need the context,
which is the document information.
And to do this, let's add options, the system message,
and you can see the system message prompt here.
Let's make this a little bigger and leave this open
and go to our GitHub repository.
So in here, under tools, knowledge,
you will see the knowledge system prompt text file.
This is a pretty short system prompt to just prompt the LLM
to behave like a Q&A chatbot in this case.
So given a question,
it'll provide an answer given the provided document.
So let's copy this one.
Go over here and put it into the system message.
There you go.
So this is how the system message right now looks.
It contains the original prompt and our information here
because it pulls that from the previous node.
Now, let's try this out.
Click execute step.
And you can see the answer to our question
that the convention center features two, exhibition halls
A and B.
Great, the heavy lifting is done.
What's remaining now is to return this information
in a nice and clean way.
So what we wanna do is to add a simple set field node
where we define a field that is maybe named response,
and it contains the text value from the LLM.
Execute this step.
And you can see this is the output of our whole workflow.
So if we zoom out a little bit,
what this workflow is doing is it takes a question
that is coming in, it pulls information
from an external file.
In this case GitHub.
The model will generate the answer,
the question given the information,
and then it returns the answer as a simple text response.
And that's exactly the answer that our agent needs.
When it asks a question to their tool,
it gets the answer back.
In the next video, we will give our agent
access to this tool.