{
  "name": "AI-powered document chat with Nextcloud files using LangChain and OpenAI",
  "nodes": [
    {
      "id": "9745c907-14fe-49b8-9acf-b4e847bf2ebc",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1060,
        -200
      ]
    },
    {
      "id": "aa540b75-cb88-4f09-b76a-c1a66b2eb34b",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1000,
        40
      ]
    },
    {
      "id": "fcb5b3c9-c0d4-41b1-8f76-58c2bb1bf822",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -840,
        40
      ]
    },
    {
      "id": "da680124-9c4e-4bb7-9d70-8ae0d5515bb0",
      "name": "AI Nextcloud",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -860,
        -200
      ]
    },
    {
      "id": "cce0ea8a-5bd1-48ad-9e2c-bca053755278",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1620,
        580
      ]
    },
    {
      "id": "d382c346-4f35-4772-a3e3-2104be66ffce",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -720,
        500
      ]
    },
    {
      "id": "14addc84-0661-4913-bf6b-9870cce876bf",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -60,
        500
      ]
    },
    {
      "id": "e7a14c39-5853-4e2f-8549-47917eedd3ac",
      "name": "output",
      "type": "n8n-nodes-base.set",
      "position": [
        120,
        500
      ]
    },
    {
      "id": "dc6ee0ee-b2e8-433d-8acb-b182dc6e8529",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1700,
        260
      ],
      "parameters": {
        "width": 2080,
        "height": 700,
        "content": "# Subworkflow \n\n## Nextcloud\n\nList Files in a gigven path and returns Dile contents form docs\n\nRequired Community Node:\nhttps://www.npmjs.com/package/n8n-nodes-word2text\n"
      }
    },
    {
      "id": "858059e4-6a66-4442-8a04-d9cd4fd6dcc0",
      "name": "If readable",
      "type": "n8n-nodes-base.if",
      "position": [
        -1120,
        580
      ]
    },
    {
      "id": "e3341daa-f89d-4666-848a-1dbcfb7a9f74",
      "name": "Get Files",
      "type": "n8n-nodes-base.nextCloud",
      "position": [
        -1300,
        580
      ]
    },
    {
      "id": "23d1168d-c0f1-412c-bfe2-fc229cd0567a",
      "name": "Download File",
      "type": "n8n-nodes-base.nextCloud",
      "position": [
        -900,
        500
      ]
    },
    {
      "id": "9aaeb43a-6156-4c72-a090-9eb07fb2a85c",
      "name": "add path 1",
      "type": "n8n-nodes-base.code",
      "position": [
        -320,
        300
      ]
    },
    {
      "id": "fe21734c-e0e5-43f3-8bb9-4fd976ab61a9",
      "name": "add path 2",
      "type": "n8n-nodes-base.code",
      "position": [
        -320,
        500
      ]
    },
    {
      "id": "46bb7f6b-7a0d-4761-b50b-50ed8a0fd01a",
      "name": "add path 3",
      "type": "n8n-nodes-base.code",
      "position": [
        -320,
        720
      ]
    },
    {
      "id": "6124f284-2846-4c88-b075-2a2fec028664",
      "name": "test data",
      "type": "n8n-nodes-base.code",
      "position": [
        -1460,
        580
      ]
    },
    {
      "id": "7b11ef64-3887-4baa-a8ca-3c76c8f4eb02",
      "name": "Nextcloud Tool",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        -700,
        40
      ]
    },
    {
      "id": "c78d765f-b6fe-40bb-9245-3ce50cb009b4",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1700,
        -260
      ],
      "parameters": {
        "width": 1260,
        "height": 460,
        "content": "# Main Workflow\n\n## AI Agent\n\nAnswers question to  folder contents. \n\nPut the Path to the folder into your question."
      }
    },
    {
      "id": "147fe75b-022f-4fb0-8259-bc91286f54ca",
      "name": "PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -500,
        300
      ]
    },
    {
      "id": "1bd71897-738a-46a2-b7e3-700e4ad9db8f",
      "name": "Markdown",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -500,
        500
      ]
    },
    {
      "id": "9ed19c46-55aa-4109-85c7-a8b9cf068568",
      "name": "DOCX",
      "type": "n8n-nodes-word2text.word2text",
      "position": [
        -500,
        740
      ]
    }
  ],
  "connections": {
    "PDF": {
      "main": [
        [
          {
            "node": "add path 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DOCX": {
      "main": [
        [
          {
            "node": "add path 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Markdown",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "DOCX",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown": {
      "main": [
        [
          {
            "node": "add path 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Files": {
      "main": [
        [
          {
            "node": "If readable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "test data": {
      "main": [
        [
          {
            "node": "Get Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "add path 1": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "add path 2": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "add path 3": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If readable": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Nextcloud",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Nextcloud Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Nextcloud",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Nextcloud",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Nextcloud",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "test data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}