This workflow follows the Agent → OpenAI Embeddings recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "eworld_chat_final",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "eworld-chatbot",
"responseMode": "responseNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-260,
-340
],
"id": "1ea75b5a-3cc6-4f2e-ac31-da850358939f",
"name": "Webhook"
},
{
"parameters": {
"promptType": "define",
"text": "={{ $('Webhook').item.json.body.message }}",
"options": {
"systemMessage": "=You are a helpful assistant for DXN Company. \n----\nKnowledge Data:\nMember/Distributor Information\nMember Code : {{ $('Webhook').item.json.body.member_data.member_code }}\nMember Name : {{ $('Webhook').item.json.body.member_name }}\nCountry : {{ $('Webhook').item.json.body.member_data.country }}\nRank : {{ $('Webhook').item.json.body.member_data.rank }}\nPV : {{ $('Webhook').item.json.body.member_data.pv }}\nGPV : {{ $('Webhook').item.json.body.member_data.gpv }}\nE-Wallet / E-point : {{$('Webhook').item.json.body.member_data.ewallet }}\nNTGPV : {{ $('Webhook').item.json.body.member_data.ntgpv }}\nBonus : {{ $('Webhook').item.json.body.member_data.bonus }}\nJoin Date : {{ $('Webhook').item.json.body.member_data.join_date }}\n{{ $('Webhook').item.json.body.member_data.additional_info }}\n\n---\nRANK SYMBOLS:\nSD = STAR DIAMOND\nCA = CROWN AMBASSADOR\nSR = STAR RUBY\nSD = STAR DIAMOND\nSA = STAR AGENT\n\n---\nPromotion Requirements Overview\n\nCurrent Rank: DISTRIBUTOR \nNext Rank: STAR AGENT (SA) \nPromotion Criteria: \n1. Achieve a minimum of 100 Personal Point Value (PV). \n2. Accumulate a total of 4,500 Group Sales PV.\n\n---\n\nCurrent Rank: STAR AGENT (SA) \nNext Rank: STAR RUBY (SR) \nPromotion Criteria: \n1. Maintain a minimum of 100 Personal PV. \n2. Personally sponsor 3 STAR AGENTS (first-generation).\n\n---\n\nCurrent Rank: STAR RUBY (SR) \nNext Rank: STAR DIAMOND (SD) \nPromotion Criteria: \n1. Maintain a minimum of 100 Personal PV. \n2. Personally sponsor 6 STAR AGENTS (first-generation). \n3. Qualify for the 37% commission level by meeting one of the following options: \n - Option 1: Sponsor 6 STAR AGENTS and achieve a Downline Group PV (DGPV) of 5,000. \n - Option 2: Sponsor 6 STAR AGENTS, including 4 Qualified SA, with a DGPV of 2,500.\n\n\nCurrent Rank: STAR DIAMOND (SD) \nNext Rank: CROWN AMBASSADOR (CA) \nPromotion Criteria: \n1. Maintain a minimum of 100 Personal PV. \n2. Personally sponsor 20 STAR DIAMONDS, recognized through the dynamic compression structure.\n\n---\n\nCurrent Rank: CROWN AMBASSADOR (CA) \nNext Rank: Already top level rank \n----\n\nRESPONSE GUIDELINES:\n1. Additional Knowledge can retrieve from 'Postgres PGVector Store' Tool\n2. Language: ALWAYS respond as same as user prompt\n3. Response Format:\n - Keep responses friendly and clear\n - For lists, use numbered format (1., 2., etc.) and add title above the list\n - Use clear formatting without markdown symbols (**)\n \n4. Content Restrictions:\n - ONLY provide information about DXN products, business, and company\n - NEVER create creative content (poems, songs, stories)\n - Provide information about own self member data if asked\n \n5. Question Handling:\n - Answer questions directly without greetings or introductions\n - For DXN-related questions: Provide clear, factual answers\n - For non-DXN topics: Politely redirect to DXN-related questions\n - For product questions: Include basic benefits and official information only\n - For business questions: Focus on public, official information\n\n "
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.9,
"position": [
480,
-580
],
"id": "89ffd49f-756d-4ea0-897f-55361f684354",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "gpt-4.1-mini-2025-04-14",
"mode": "list",
"cachedResultName": "gpt-4.1-mini-2025-04-14"
},
"options": {
"maxTokens": 500,
"temperature": 0.1
}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
480,
-300
],
"id": "25370987-da44-415a-8dad-96a5c257ea49",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $('Webhook').item.json.body.sessionId }}"
},
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1.3,
"position": [
640,
-300
],
"id": "7efd1a1a-c53b-43a9-ae76-5c049b0f1c8e",
"name": "Pg localhost eworldchat chatmem",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"mode": "retrieve-as-tool",
"toolName": "vector_store",
"toolDescription": "work with your data in postgre with pg_vector extension",
"tableName": "pdf_vectors",
"topK": 3,
"options": {
"distanceStrategy": "cosine"
}
},
"type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
"typeVersion": 1.1,
"position": [
860,
-360
],
"id": "c3213589-1f99-4a06-88ea-07123b99f76f",
"name": "Postgres PGVector Store",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"model": "text-embedding-ada-002",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.2,
"position": [
880,
-140
],
"id": "b74aae1f-abaf-4571-9fe0-203c91f9e9f9",
"name": "Embeddings OpenAI",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"table": {
"__rl": true,
"value": "cachex",
"mode": "name"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"output": "={{ $json.output }}",
"code": "={{ $('Webhook').item.json.body.member_code }}",
"input": "={{ $('Webhook').item.json.body.message }}"
},
"matchingColumns": [],
"schema": [
{
"id": "code",
"displayName": "code",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "input",
"displayName": "input",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "output",
"displayName": "output",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "timestamp",
"displayName": "timestamp",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {
"replaceEmptyStrings": true
}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
980,
-580
],
"id": "ac42337b-ecda-4993-bbfb-3456dc9ce3f0",
"name": "Postgres",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1220,
-20
],
"id": "8a3aa081-4419-46b6-8877-4a3464e8125a",
"name": "Respond to Webhook"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1200,
-580
],
"id": "9e112b70-e217-4af4-bc72-795ef870388b",
"name": "Respond to Webhook1"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "6bead3dd-0523-4dba-ab2a-17fa2a62bfcb",
"leftValue": "={{ $json.count }}",
"rightValue": "0",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
100,
-420
],
"id": "cbd9467a-0596-4bf0-a6b7-6c6bbc6fd6ab",
"name": "If"
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT *\nFROM public.cachex\nWHERE code = '{{ $('Webhook').item.json.body.member_data.member_code }}'\n AND input = '{{ $('Webhook').item.json.body.message }}'\n AND timestamp >= NOW() - INTERVAL '4 hour' ORDER BY timestamp DESC LIMIT 1;",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
520,
-20
],
"id": "ab01444b-43c6-4cc9-8cec-8c509dda757e",
"name": "Pg Get last Chat",
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT COUNT(*)\nFROM public.cachex\nWHERE code = '{{ $json.body.member_code }}'\n AND input = '{{ $json.body.message }}'\n AND timestamp >= NOW() - INTERVAL '4 hour';",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-120,
-340
],
"id": "f537cead-975e-44c4-8e4d-272dee653fe2",
"name": "Pg Count Cache",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 3
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-260,
-700
],
"id": "d7ac0288-57ba-4684-97ca-56fe915428fd",
"name": "Schedule Trigger"
},
{
"parameters": {
"operation": "executeQuery",
"query": "DELETE FROM public.cachex\nWHERE timestamp < NOW() - INTERVAL '5 day';",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-40,
-700
],
"id": "fb6b5f51-5bc8-469f-b526-e99be491aae3",
"name": "Pg Remove cachex",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
}
],
"connections": {
"Webhook": {
"main": [
[
{
"node": "Pg Count Cache",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Pg localhost eworldchat chatmem": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Postgres PGVector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Postgres PGVector Store": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Postgres",
"type": "main",
"index": 0
}
]
]
},
"Postgres": {
"main": [
[
{
"node": "Respond to Webhook1",
"type": "main",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
],
[
{
"node": "Pg Get last Chat",
"type": "main",
"index": 0
}
]
]
},
"Pg Get last Chat": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Pg Count Cache": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Pg Remove cachex",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "66f1bc28-b927-4eb6-8e0a-61ab1a29bab9",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "hLge1s0RS1a8mkaa",
"tags": []
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
openAiApipostgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
eworld_chat_final. Uses agent, lmChatOpenAi, memoryPostgresChat, vectorStorePGVector. Webhook trigger; 14 nodes.
Source: https://github.com/donairl/new_chat_ui/blob/64b540af6c0a407df6b0b27ca244ffee16607c20/n8n/eworld_chat_final.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
dxnweb_chat. Uses agent, lmChatOpenAi, memoryPostgresChat, embeddingsOpenAi. Webhook trigger; 12 nodes.
Hi! I’m Amanda, a creator of intelligent automations using n8n and Make. I’ve been building AI-powered workflows for over 2 years, always focused on usability and innovation. This one here is very spe
RAG AI Agent Template V5. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, googleDrive. Event-driven trigger; 56 nodes.
Corvus 3.2 Beta. Uses httpRequest, agent, lmChatOpenAi, vectorStoreSupabase. Webhook trigger; 48 nodes.
Agente AI RAG. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, googleDrive. Event-driven trigger; 42 nodes.