n8n workflow: OpenAI Personal Shopper with RAG and WooCommerce

Nodes:
name: When chat message received
type: @n8n/n8n-nodes-langchain.chatTrigger
name: Window Buffer Memory
type: @n8n/n8n-nodes-langchain.memoryBufferWindow
parameters: sessionKey: ={{ $('Edit Fields').item.json.sessionId }}
sessionIdType: customKey
name: Calculator
type: @n8n/n8n-nodes-langchain.toolCalculator
name: Edit Fields
type: n8n-nodes-base.set
parameters: assignments: assignments: name: sessionId
type: string
value: ={{ $json.sessionId }}
name: chatInput
type: string
value: ={{ $json.chatInput }}
name: OpenAI Chat Model
type: @n8n/n8n-nodes-langchain.lmChatOpenAi
name: RAG
type: @n8n/n8n-nodes-langchain.toolVectorStore
parameters: name: informazioni_negozio
description: Informazioni relative al negozio: orari di apertura, indirizzo, contatti, informazioni generali
name: Qdrant Vector Store
type: @n8n/n8n-nodes-langchain.vectorStoreQdrant
parameters: qdrantCollection: __rl: yes
mode: list
value: scarperia
cachedResultName: scarperia
name: Embeddings OpenAI
type: @n8n/n8n-nodes-langchain.embeddingsOpenAi
name: OpenAI Chat Model1
type: @n8n/n8n-nodes-langchain.lmChatOpenAi
name: personal_shopper
type: n8n-nodes-base.wooCommerceTool
parameters: options: sku: ={{ $('Information Extractor').item.json.output.SKU }}
search: ={{ $('Information Extractor').item.json.output.keyword }}
maxPrice: ={{ $('Information Extractor').item.json.output.price_max }}
minPrice: ={{ $('Information Extractor').item.json.output.price_min }}
stockStatus: instock
operation: getAll
name: Information Extractor
type: @n8n/n8n-nodes-langchain.informationExtractor
parameters: text: ={{ $json.chatInput }}
options: systemPromptTemplate: You are an intelligent assistant for a shoe and accessories store (mainly bags). Your task is to analyze the input text coming from a chat and determine if the user is looking for a product. If the user is looking for a product, you need to extract the following information:
1. The keyword (keyword) useful for the search.
2. Any minimum or maximum prices specified.
3. An SKU (product code) if mentioned.
4. The name of the category to search in, if specified.

Instructions:
1. Identify the intent: Determine if the user is looking for a specific product.
2. Extract the information:
- If the user is looking for a product, identify:
- Set the type "search" to true. Otherwise, set it to false
- The keywords.
- Any minimum or maximum prices (e.g. "less than 50 euros", "between 30 and 60 euros").
- An SKU (e.g. "ABC123 code").
- The category name (e.g. "t-shirts", "jeans", "women", "men").
3. Output format: Return a JSON object with the given structure
schemaType: manual
inputSchema: {
       "search_intent": true,
       "search_params": [
         { "type": "search", "value": "ture or false" },
         { "type": "keyword", "value": "valore_keyword" },
         { "type": "min_price", "value": "valore_min_price" },
         { "type": "max_price", "value": "valore_max_price" },
         { "type": "sku", "value": "valore_sku" },
         { "type": "category", "value": "valore_categoria" }
       ]
     }
name: OpenAI Chat Model2
type: @n8n/n8n-nodes-langchain.lmChatOpenAi
name: Google Drive2
type: n8n-nodes-base.googleDrive
parameters: filter: driveId: __rl: yes
mode: list
value: My Drive
cachedResultUrl: https://drive.google.com/drive/my-drive
cachedResultName: My Drive
folderId: __rl: yes
mode: list
value: 1lmnqpLFKS-gXmXT92C5VG0P1XlcoeFOb
cachedResultUrl: https://drive.google.com/drive/folders/1lmnqpLFKS-gXmXT92C5VG0P1XlcoeFOb
cachedResultName: Scarperia Salò - RAG
resource: fileFolder
name: Google Drive1
type: n8n-nodes-base.googleDrive
parameters: fileId: __rl: yes
mode: id
value: ={{ $json.id }}
options: googleFileConversion: conversion: docsToFormat: text/plain
operation: download
name: Embeddings OpenAI3
type: @n8n/n8n-nodes-langchain.embeddingsOpenAi
name: Default Data Loader2
type: @n8n/n8n-nodes-langchain.documentDefaultDataLoader
parameters: dataType: binary
name: Token Splitter1
type: @n8n/n8n-nodes-langchain.textSplitterTokenSplitter
parameters: chunkSize: 300
chunkOverlap: 30
name: When clicking ‘Test workflow’
type: n8n-nodes-base.manualTrigger
name: HTTP Request
type: n8n-nodes-base.httpRequest
parameters: url: https://QDRANTURL/collections/NAME/points/delete
method: POST
jsonBody: {
  "filter": {}
}
sendBody: yes
sendHeaders: yes
specifyBody: json
authentication: genericCredentialType
genericAuthType: httpHeaderAuth
headerParameters: parameters: name: Content-Type
value: application/json
name: Sticky Note
type: n8n-nodes-base.stickyNote
parameters: width: 259.7740863787376
height: 234.1528239202657
content: Replace the URL and Collection name with your own
name: Qdrant Vector Store1
type: @n8n/n8n-nodes-langchain.vectorStoreQdrant
parameters: mode: insert
qdrantCollection: __rl: yes
mode: list
value: scarperia
cachedResultName: scarperia
name: Sticky Note1
type: n8n-nodes-base.stickyNote
parameters: color: 3
width: 1301.621262458471
height: 105.6212624584717
content: ## Step 1 
Create a collectiopn on your Qdrant instance. Then create a basic RAG system with documents uploaded to Google Drive and embedded in the Qdrant vector database
name: Sticky Note2
type: n8n-nodes-base.stickyNote
parameters: color: 3
width: 1301.621262458471
height: 105.6212624584717
content: ## Step 1 
Create a basic RAG system with documents uploaded to Google Drive and embedded in the Qdrant vector database
name: Sticky Note3
type: n8n-nodes-base.stickyNote
parameters: color: 3
width: 1301.621262458471
height: 105.6212624584717
content: ## Step 2 
The Information Extractor tries to understand if the request is related to products and if so, it extracts the useful information to filter the products available on WooCommerce by calling the "personal_shopper". If it is a general question, the RAG system is called
name: AI Agent
type: @n8n/n8n-nodes-langchain.agent
parameters: text: ={{ $('When chat message received').item.json.chatInput }}
options: systemMessage: =You are an intelligent assistant for a clothing store. Your task is to analyze the input text from a chat and determine if the user is looking for a product.

Behavior:
- If the user is looking for a product the "search" field of the following JSON is set to true and you must pass the following JSON as input to the "personal_shopper" tool to extract:

```json
{{ JSON.stringify($json.output) }}
```

- If the user asks questions related to the store such as address or opening hours, you must use the "RAG" tool
promptType: define

Connections:
RAG: ai_tool: node: AI Agent
type: ai_tool
Calculator: ai_tool: node: AI Agent
type: ai_tool
Edit Fields: main: node: Information Extractor
type: main
HTTP Request: main: node: Google Drive2
type: main
Google Drive1: main: node: Qdrant Vector Store1
type: main
Google Drive2: main: node: Google Drive1
type: main
Token Splitter1: ai_textSplitter: node: Default Data Loader2
type: ai_textSplitter
personal_shopper: ai_tool: node: AI Agent
type: ai_tool
Embeddings OpenAI: ai_embedding: node: Qdrant Vector Store
type: ai_embedding
OpenAI Chat Model: ai_languageModel: node: AI Agent
type: ai_languageModel
Embeddings OpenAI3: ai_embedding: node: Qdrant Vector Store1
type: ai_embedding
OpenAI Chat Model1: ai_languageModel: node: RAG
type: ai_languageModel
OpenAI Chat Model2: ai_languageModel: node: Information Extractor
type: ai_languageModel
Qdrant Vector Store: ai_vectorStore: node: RAG
type: ai_vectorStore
Default Data Loader2: ai_document: node: Qdrant Vector Store1
type: ai_document
Window Buffer Memory: ai_memory: node: AI Agent
type: ai_memory
Information Extractor: main: node: AI Agent
type: main
When chat message received: main: node: Edit Fields
type: main
When clicking ‘Test workflow’: main: node: HTTP Request
type: main