{
  "name": "Build a chatbot with Reinforced Learning Human Feedback (RLHF) and RAG",
  "nodes": [
    {
      "id": "e39a0b25-53ce-4ac0-9c93-7750b8e6105b",
      "name": "Knowledge Base Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        220,
        0
      ]
    },
    {
      "id": "775b7991-88f3-4959-a068-3fb2b667567e",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        200,
        180
      ]
    },
    {
      "id": "4c2e0ea6-f5d0-4d5b-a065-606b2dc2cff5",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        440,
        460
      ]
    },
    {
      "id": "2f813af6-3432-4201-93d0-ff503013642e",
      "name": "Document Section Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        580,
        -340
      ]
    },
    {
      "id": "c6386d7b-f3cb-4884-9477-a69e9743e6c6",
      "name": "Document Chunker",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        560,
        -220
      ]
    },
    {
      "id": "4ff1a843-5e1c-4a23-bdf3-2fdc91ba7032",
      "name": "OpenAI Embeddings Generator",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        440,
        -340
      ]
    },
    {
      "id": "64624ed6-cbb2-43c1-b348-df92f26d8efe",
      "name": "Google Docs Importer",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        220,
        -520
      ]
    },
    {
      "id": "09c262ab-ba89-429c-b8a8-41c3ae79d97c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -500
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": "Run this workflow manually to import and index Google Docs product documentation into MongoDB with vector embeddings for fast search."
      }
    },
    {
      "id": "f309ff4a-194f-413a-b8f5-d8210cb5e0c6",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        40
      ],
      "parameters": {
        "width": null,
        "height": 180,
        "content": "This workflow uses retrieval-augmented generation (RAG) to answer user questions by searching the MongoDB vector store and generating AI responses enhanced with Telegram-based RLHF feedback."
      }
    },
    {
      "id": "caf481b3-7a19-40df-b5fb-52e74a8edd73",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1800,
        -480
      ],
      "parameters": {
        "width": 520,
        "height": 1040,
        "content": "Documentation Search Index\n\n{\n  \"mappings\": {\n    \"dynamic\": false,\n    \"fields\": {\n      \"_id\": {\n        \"type\": \"string\"\n      },\n      \"text\": {\n        \"type\": \"string\"\n      },\n      \"embedding\""
      }
    },
    {
      "id": "8a3abf9e-6f3f-47cf-b9ec-bb9da9835e5c",
      "name": "When clicking \"Execute Workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        -520
      ]
    },
    {
      "id": "4235ba8c-d671-40b8-b3a4-d7cccac36d54",
      "name": "MongoDB Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryMongoDbChat",
      "position": [
        320,
        180
      ]
    },
    {
      "id": "000e272a-3f19-4c17-86b5-07505eba2c3b",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        160,
        440
      ]
    },
    {
      "id": "dca02c04-2921-4982-83a3-6b2f6fb32663",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1400,
        180
      ]
    },
    {
      "id": "757073e3-f8b5-42b5-ab02-d310d5f6e8a4",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1380,
        300
      ]
    },
    {
      "id": "588ef94b-9723-440a-ac13-d97d744ae26d",
      "name": "Embeddings OpenAI3",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        320,
        720
      ]
    },
    {
      "id": "355654d8-95e2-4337-9b1f-af2a08573f08",
      "name": "Search Positive Interactions",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        160,
        320
      ]
    },
    {
      "id": "84a95dfb-6cc4-4a18-be40-6fa201073750",
      "name": "Search Documentation",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        440,
        320
      ]
    },
    {
      "id": "f2001c81-081b-4417-8349-3db459c0f191",
      "name": "Search Negative Interactions",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        240,
        580
      ]
    },
    {
      "id": "1a0de194-3508-4d21-b1a2-35c3b4a998c1",
      "name": "Receive Message on Telegram",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        0,
        0
      ]
    },
    {
      "id": "92458560-feb5-40df-b52a-ec1c5156829d",
      "name": "Send Message on Telegram, Wait for Feedback",
      "type": "n8n-nodes-base.telegram",
      "position": [
        600,
        0
      ]
    },
    {
      "id": "ef40200d-5f19-4199-8ae3-9f2e0f52ac1b",
      "name": "Map feedback data",
      "type": "n8n-nodes-base.code",
      "position": [
        820,
        0
      ]
    },
    {
      "id": "d688073c-9a97-4b39-9640-c368cccf3491",
      "name": "Set feedback fields for collection storage",
      "type": "n8n-nodes-base.set",
      "position": [
        1040,
        0
      ]
    },
    {
      "id": "9907480f-3e5d-4240-adbb-790be2d68496",
      "name": "Submit embedded chat feedback",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        1260,
        0
      ]
    },
    {
      "id": "1a470ad3-845a-4890-b103-65a21b1940de",
      "name": "OpenAI Embeddings Generator1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1260,
        180
      ]
    },
    {
      "id": "fdc22256-f014-4ed0-8781-1abb20134b1a",
      "name": "MongoDB Documentation Inserter",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
      "position": [
        440,
        -520
      ]
    }
  ],
  "connections": {
    "Document Chunker": {
      "ai_textSplitter": [
        [
          {
            "node": "Document Section Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Search Documentation",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Map feedback data": {
      "main": [
        [
          {
            "node": "Set feedback fields for collection storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Search Positive Interactions",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI3": {
      "ai_embedding": [
        [
          {
            "node": "Search Negative Interactions",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Submit embedded chat feedback",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "MongoDB Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Google Docs Importer": {
      "main": [
        [
          {
            "node": "MongoDB Documentation Inserter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base Agent": {
      "main": [
        [
          {
            "node": "Send Message on Telegram, Wait for Feedback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Documentation": {
      "ai_tool": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Document Section Loader": {
      "ai_document": [
        [
          {
            "node": "MongoDB Documentation Inserter",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings Generator": {
      "ai_embedding": [
        [
          {
            "node": "MongoDB Documentation Inserter",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Receive Message on Telegram": {
      "main": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings Generator1": {
      "ai_embedding": [
        [
          {
            "node": "Submit embedded chat feedback",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Search Negative Interactions": {
      "ai_tool": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Search Positive Interactions": {
      "ai_tool": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "MongoDB Documentation Inserter": {
      "main": [
        []
      ]
    },
    "When clicking \"Execute Workflow\"": {
      "main": [
        [
          {
            "node": "Google Docs Importer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Set feedback fields for collection storage": {
      "main": [
        [
          {
            "node": "Submit embedded chat feedback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Message on Telegram, Wait for Feedback": {
      "main": [
        [
          {
            "node": "Map feedback data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}