Templates / Make OpenAI citation for file retrieval RAG

Make OpenAI citation for file retrieval RAG

Ready for 3.0

by Davi Saranszky Mesquita ✓ · 3,989 views · created 2025-01-02 · Engineering, AI RAG

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 12 nodes and runs when a chat message arrives. Along the way it connects OpenAI.

How it runs

Trigger: When a chat message arrives.

  1. OpenAI: work with assistant, with memory: Window Buffer Memory
  2. Get ALL Thread Content (HTTP Request): calls an HTTP API
  3. Split all message iterations from a thread (Split Out): splits a list into separate items
  4. Split all content from a single message (Split Out): splits a list into separate items
  5. Split all citations from a single message (Split Out): splits a list into separate items
  6. Retrieve file name from a file ID (HTTP Request): calls an HTTP API
  7. Regularize output (Edit Fields (Set)): sets 3 fields: id, filename, text
  8. Aggregate: combines items into one
  9. Finnaly format the output (Code): runs custom JavaScript code
  10. Optional Markdown to HTML (Markdown): converts between Markdown and HTML

Services it uses

OpenAI

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Nodes used (9)

From the author

Make OpenAI Citation for File Retrieval RAG Use case In this example, we will ensure that all texts from the OpenAI assistant search for citations and sources in the vector store files. We can also format the output for Markdown or HTML tags. This is…

Excerpt from Davi Saranszky Mesquita's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.