{
  "name": "MS Data Ingestion",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "09e8483e-bd5a-430f-8bfc-d82768ac4334",
      "name": "When clicking \u2018Test workflow\u2019"
    },
    {
      "parameters": {
        "resource": "folder",
        "folderId": "01GAB4HVT7CBHKYTF2L5EZQ4GTHA5CMJPL"
      },
      "type": "n8n-nodes-base.microsoftOneDrive",
      "typeVersion": 1,
      "position": [
        200,
        0
      ],
      "id": "4b799a2f-4a44-401a-bf05-e85aeeb92fbc",
      "name": "List All Files in Folder",
      "credentials": {
        "microsoftOneDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "airtableOAuth2Api",
        "operation": "upsert",
        "base": {
          "__rl": true,
          "value": "appq2lhqFxPyuBBdN",
          "mode": "list",
          "cachedResultName": "HR Chatbot Template",
          "cachedResultUrl": "https://airtable.com/appq2lhqFxPyuBBdN"
        },
        "table": {
          "__rl": true,
          "value": "tblXidsGdPHgGpmPj",
          "mode": "list",
          "cachedResultName": "OneDrive_Files",
          "cachedResultUrl": "https://airtable.com/appq2lhqFxPyuBBdN/tblXidsGdPHgGpmPj"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "createdDateTime": "={{ $json.createdDateTime }}",
            "lastModifiedDateTime": "={{ $json.lastModifiedDateTime }}",
            "name": "={{ $json.name }}",
            "size": "={{ $json.size }}",
            "oneDriveId": "={{ $json.id }}"
          },
          "matchingColumns": [
            "name"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            },
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "oneDriveId",
              "displayName": "oneDriveId",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "createdDateTime",
              "displayName": "createdDateTime",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "lastModifiedDateTime",
              "displayName": "lastModifiedDateTime",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "name",
              "displayName": "name",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "size",
              "displayName": "size",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "vector",
              "displayName": "vector",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": true
            },
            {
              "id": "folderSnapshotDateTime",
              "displayName": "folderSnapshotDateTime",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        420,
        0
      ],
      "id": "57141782-d1aa-430f-8c8c-48df67e89072",
      "name": "Take a file list snapshot",
      "credentials": {
        "airtableOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": "={{ $('List All Files in Folder').item.json.id }}"
      },
      "type": "n8n-nodes-base.microsoftOneDrive",
      "typeVersion": 1,
      "position": [
        640,
        0
      ],
      "id": "21ce2fa2-569a-457d-870d-16e0002122db",
      "name": "Pull files",
      "credentials": {
        "microsoftOneDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "event": "folderCreated"
      },
      "type": "n8n-nodes-base.microsoftOneDriveTrigger",
      "typeVersion": 1,
      "position": [
        0,
        -200
      ],
      "id": "db6c3981-9d15-4abd-9562-6d8eec66a466",
      "name": "Microsoft OneDrive Trigger",
      "credentials": {
        "microsoftOneDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "disabled": true
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.fields.name }}",
                    "rightValue": "=.txt",
                    "operator": {
                      "type": "string",
                      "operation": "endsWith"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "a55deabf-d203-4f5a-8656-4153176de7d1",
                    "leftValue": "={{ $json.fields.name }}",
                    "rightValue": ".pdf",
                    "operator": {
                      "type": "string",
                      "operation": "endsWith"
                    }
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        820,
        0
      ],
      "id": "02559e33-d046-4090-8144-48b7366ef495",
      "name": "Switch"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        1380,
        0
      ],
      "id": "3f876093-304c-4d2e-8262-3a4a8bb231b7",
      "name": "Merge"
    },
    {
      "parameters": {
        "operation": "text",
        "options": {
          "encoding": "utf8"
        }
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        1020,
        -140
      ],
      "id": "54e61717-9b30-48c0-be70-3048c5ac5276",
      "name": "txt Files"
    },
    {
      "parameters": {
        "operation": "pdf",
        "options": {
          "joinPages": true
        }
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        1020,
        80
      ],
      "id": "f0089645-9845-4f2c-879b-59d6d6a63c76",
      "name": "pdf Files"
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "generic_hr_documents",
          "mode": "list",
          "cachedResultName": "generic_hr_documents"
        },
        "options": {
          "queryName": "match_documents"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1,
      "position": [
        2000,
        0
      ],
      "id": "71acc5d8-861d-43a5-a542-9b2c393e4362",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        2060,
        220
      ],
      "id": "e6c729ce-3e9a-49c1-adc6-f656c0f36259",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        2200,
        220
      ],
      "id": "74517a2e-bc01-40cd-945b-066bf6b7148d",
      "name": "Default Data Loader"
    },
    {
      "parameters": {
        "chunkOverlap": 200,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        2300,
        440
      ],
      "id": "9ec6bc2e-596e-40cd-ad8d-4153d2fbb3e8",
      "name": "Recursive Character Text Splitter"
    },
    {
      "parameters": {
        "fieldToSplitOut": "text",
        "options": {
          "destinationFieldName": "data"
        }
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1200,
        80
      ],
      "id": "4b8dbe18-6710-44c2-a27b-3de8c3748010",
      "name": "Split Out"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=# Role\nYou are an expert HR advisor with a solid legal background in our company Eversong AI, which is an online IT Automation Agency, serving small and medium size businesses all around the world.\n\n# Task\nYour task is to summarize this text: {{ $json.data }} and return it in markdown format.\n\n# Notes\n* It is imperative that your results are structured in Markdown format.\n* You will return your results in a json of 2 nodes. 1 with the original filename called \"filename\". 1 with your main result called \"content\", the content node will not have a json structure.\n* You will translate to English if needed\n* You will replace all references to EPAM  by Eversong AI\n* You will replace all references to UBS to Client\n* At the bottom of your response you add some metadata consisting of \"Title\", \"Author\", \"Document created\", \"Document modified\", \"Topic\" which you will populate strictly based on the information given in the text. If unable to populate an element, you return \"unknown\".\n* You will not refer to your created summary with \"document\" or \"summary\"\n* Your results isn't encapsulated in quotes.",
              "role": "system"
            }
          ]
        },
        "simplify": false,
        "options": {
          "temperature": 0.1
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1540,
        0
      ],
      "id": "355bb0a5-19fb-4f9b-bd71-3f21f4d58f90",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all();\nconst contents = items.map((item) => item?.json?.choices[0]?.message?.content);\nreturn { contents };\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1840,
        0
      ],
      "id": "0f8601da-e562-4b8b-9131-2c9a4599ec9a",
      "name": "Code"
    }
  ],
  "connections": {
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "List All Files in Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List All Files in Folder": {
      "main": [
        [
          {
            "node": "Take a file list snapshot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Take a file list snapshot": {
      "main": [
        [
          {
            "node": "Pull files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull files": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "txt Files",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "pdf Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "txt Files": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "pdf Files": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a22486d0-628d-46d8-9ae5-b41cb9ff32f6",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "2azSuvetxrmtPJPT",
  "tags": []
}