OpenAI citation generation for RAG file retrieval
Workflow Description
An automation that leverages OpenAI to generate accurate citations from files retrieved in RAG systems. It maintains conversation context through memory buffering, processes user queries, and returns responses with documented sources.
How it works
- 1.Receive user query via Chat Trigger
- 2.Store context in memory buffer and maintain conversation history
- 3.Send query with context to OpenAI for processing
- 4.Analyze retrieved data and generate structured citations
- 5.Format response in Markdown with documented sources
- 6.Return response to user while preserving context
Use cases
- Generate data-driven answers with complete citations from reference documents
- Build intelligent Q&A systems that track and verify information sources
- Create research workflows that cite every statement to its original file
Requirements
- Valid OpenAI API key with sufficient quota
- Source files or database configured for retrieval
- Structured data format for tracking citations and sources
- Memory buffer configuration for context depth management
Service Value
Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (19)
Aggregate
Aggregate
Window Buffer Memory
Memory Buffer Window
Sticky Note4
Sticky Note
Sticky Note
Sticky Note
Create a simple Trigger to have the Chat button within N8N
Chat Trigger
OpenAI Assistant with Vector Store
OpenAI
Sticky Note1
Sticky Note
Get ALL Thread Content
HTTP Request
Sticky Note2
Sticky Note
Split all message iterations from a thread
Split Out
Split all content from a single message
Split Out
Split all citations from a single message
Split Out
Retrieve file name from a file ID
HTTP Request
Regularize output
Set
Sticky Note3
Sticky Note
Sticky Note5
Sticky Note
Sticky Note6
Sticky Note
Optional Markdown to HTML
Markdown
Finnaly format the output
Code