← All N8N workflows
AI & researchAggregateChat TriggerCodeHTTP RequestMarkdown

Make OpenAI Citation for File Retrieval RAG

Configured with Aggregate, Chat Trigger, HTTP Request, Markdown, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TransformAggregateAggregateData storeWindow Buffer MemoryMemory Buffer WindowTriggerCreate a simple Triggerto have the Chat button…Chat TriggerAI & modelsOpenAI Assistant withVector StoreOpen AiWeb / APIGet ALL Thread ContentHTTP RequestTransformSplit all messageiterations from a…Split OutTransformSplit all content froma single messageSplit OutTransformSplit all citationsfrom a single messageSplit OutWeb / APIRetrieve file name froma file IDHTTP RequestTransformRegularize outputEdit FieldsTransformOptional Markdown toHTMLMarkdownCodeFinnaly format theoutputCode

Node categories in this workflow

  • Transform
  • Data store
  • Trigger
  • AI & models
  • Web / API
  • Code

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
AggregateTransformAggregateSee node parameters
Window Buffer MemoryData storeMemory Buffer WindowSee node parameters
Create a simple Trigger to have the Chat button within N8NTriggerChat TriggerSee node parameters
OpenAI Assistant with Vector StoreAI & modelsOpen Aiassistant
Get ALL Thread ContentWeb / APIHTTP RequestSee node parameters
Split all message iterations from a threadTransformSplit OutSee node parameters
Split all content from a single messageTransformSplit OutSee node parameters
Split all citations from a single messageTransformSplit OutSee node parameters
Retrieve file name from a file IDWeb / APIHTTP RequestSee node parameters
Regularize outputTransformEdit FieldsSee node parameters
Optional Markdown to HTMLTransformMarkdownSee node parameters
Finnaly format the outputCodeCodeSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • openAiApi

Workflow notes

Make OpenAI Citation for File Retrieval RAG

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 necessary because the assistant sometimes generates strange characters, and we can also use dynamic references such as citations 1, 2, 3, for example.

What this workflow does

In this workflow, we will use an OpenAI assistant created within their interface, equipped with a vector store containing some files for file retrieval.

The assistant will perform the file search within the OpenAI infrastructure and will return the content with citations.

  • We will make an HTTP request to retrieve all the details we need to format the text output.

Setup

Insert an OpenAI Key

How to adjust it to your needs

At the end of the workflow, we have a block of code that will format the output, and there we can add Markdown tags to create links. Optionally, we can transform the Markdown formatting into HTML.

by Davi Saranszky Mesquita https://www.linkedin.com/in/mesquitadavi/

Create a simple Trigger to have the Chat button within N8N

https://www.npmjs.com/package/@n8n/chat

Setup

Setup

  • Configure OpenAI Key

In this step, we will use an assistant created within the OpenAI platform that contains a vector store a.k.a file retrieval

A file retrieval request contains a lot of information, and we want only the text that will be substituted and the file name.

A file retrieval request contains a lot of information, and we want only the text that will be substituted and the file name.

  • id
  • filename
  • text
Make OpenAI Citation for File Retrieval RAG

Make OpenAI Citation for File Retrieval RAG

Purpose and structure

This folder contains the Make OpenAI Citation for File Retrieval RAG workflow. Its executable nodes use aggregate, chatTrigger, code, httpRequest, markdown, memoryBufferWindow, openAi, set, splitOut. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Create a simple Trigger to have the Chat button within N8N

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Splitout/1059_Splitout_Code_Automation_Webhook.json MIT; preserve source notices.

Canvas section labels

These name areas of the original canvas; they do not include explanatory instructions.

  • Within N8N, there will be a chat button to test
  • Retrieving all thread content is necessary because the OpenAI tool does not retrieve all citations upon request.
  • With the last three splits, we may have many citations and texts to substitute. By doing an aggregation, it will be possible to handle everything as a single request.
  • This simple code will take all the previous files and citations and alter the original text, formatting the output. In this way, we can use Markdown tags to create links, or if you prefer, we can add an HTML transformation node.

More in AI & research