Always show source url in "n8n-agentic-rag-agent"

Hi, I implemented the following workflow:ottomator-agents/n8n-agentic-rag-agent at main · coleam00/ottomator-agents · GitHub (which I found via the following video: https://www.youtube.com/watch?v=mQt1hOjBH9o ) .

This is fascinating & works in a small test of mine!

I want to modify it, to ALWAYS give the source file & URL, so that the user can verify the answer and may find additional informationen.

I tried to modify the RAG prompt with the following:

When presenting source information, always include both:

Source File: the exact title of the document you retrieved information from
Source URL: the exact value from the url field, shown as plain text
Never generate or guess a URL. . If you do not have access to the url, leave it out or indicate it is missing.

(here is my complete system message: pastebin *dot* com/qwFCcxiy - sorry, as a new user I can only post 2 links in a post…)

The result is unfortunately, that it always mentioned the file name, but not the URL.

E.g.
Question:
Was was I in Balve?

Response:

You were in Balve on the 5th April 2025.
Source File: kb1.txt
Source URL: missing

Can someone point me in the right direction?

1 Like

I believe this implementation doesn’t include the URL in the metadata. In the RAG pipeline (the bottom part of the workflow), at the end in the “data document loader” node, you’ll have to add a metadata field for the file URL, similar to what is done for the file ID.

2 Likes

Thank you!

This was the “golden hint” for me :slight_smile:

For everyone to follow:
In


I added:

(Sorry, I am only allowed to post one picture as a new user)

and changed my system message to:

You are a helpful personal assistant designed to answer questions using a corpus of uploaded documents. These documents can be either:

Text-based (e.g., TXT, DOCX, extracted PDFs, etc.), or

Tabular data (e.g., CSV or Excel files).

You have access to:

documents: used for retrieval-augmented generation (RAG)

document_metadata: stores document titles and their associated URLs (as text)

document_rows: allows SQL queries on tabular documents

Always begin by attempting a RAG lookup using documents, unless the user question clearly involves tabular data that requires a SQL-based calculation (e.g., totals, averages, max/min values).

If the RAG does not return a clear answer, examine the metadata and contents of available documents to identify relevant ones and analyze them further.

:mag: When presenting an answer, always include:

Source File: The title of each document used (from document_metadata.title)

Source URL: the exact value from the url field, shown as plain text (e.g., https://drive.google.com/…).
Never generate or guess a URL. Do not return blob://, file://, or internal links. If you do not have access to the url, leave it out or indicate it is missing. Make the link clickable (hyperlink)

If no relevant information is found, say so honestly. Do not fabricate an answer or pretend to know.

1 Like

Looks perfect, thanks for sharing!