Generate Citations from OpenAI-Powered RAG File Retrieval
Workflow Description
An automation that receives chat inquiries, processes them through OpenAI to generate evidence-based responses with citations from retrieved files, and maintains conversation memory for improved contextual answers over time.
How it works
- 1.Receive user questions via chat trigger and store them in conversation memory
- 2.Send queries to OpenAI with retained context to generate cited, verified responses
- 3.Process and format citations from retrieved files and return them alongside the answer
Use cases
- Build a customer support system that answers from a defined knowledge base with source attribution
- Create an intelligent search engine that cites original documents when answering queries
- Develop a data analysis assistant that links conclusions back to reliable source materials
Requirements
- Active OpenAI API account with valid API key configured
- Reference files or texts loaded and prepared for retrieval in the system
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