{
  "id": "xA9J9DImm49HURF3",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Outlook and Notion knowledge base",
  "tags": [],
  "nodes": [
    {
      "id": "72f3f684-2c5f-4660-8adb-19174e82ef32",
      "name": "Microsoft Outlook Trigger",
      "type": "n8n-nodes-base.microsoftOutlookTrigger",
      "position": [
        544,
        208
      ],
      "parameters": {
        "output": "raw",
        "filters": {
          "foldersToInclude": [
            "AQMkADAwATMwMAItMmYwYS01YjkyLTAwAi0wMAoALgAAAxOU_onpis9NmFJuGkXBI8UBAGQVofbxt59GpSnWTziHe9kABPqpFlEAAAA="
          ]
        },
        "options": {
          "downloadAttachments": true
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "82792010-19d2-491d-927e-610ab1cccb28",
      "name": "Get many messages",
      "type": "n8n-nodes-base.microsoftOutlook",
      "position": [
        752,
        208
      ],
      "parameters": {
        "output": "raw",
        "options": {},
        "filtersUI": {
          "values": {
            "filters": {
              "custom": "=conversationId eq '{{ $json.conversationId }}'"
            }
          }
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "256a55fc-6625-4388-9389-94184848c544",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1216,
        208
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "emails"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n",
          "cachedResultName": "n8n"
        },
        "embeddingBatchSize": 50
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "3c1cfd55-b6e1-4adf-8ee1-c25b5202018b",
      "name": "Embeddings Cohere",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1168,
        384
      ],
      "parameters": {
        "modelName": "embed-multilingual-v3.0"
      },
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d8a46692-2af5-477c-acb1-1b6390c0c359",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1312,
        400
      ],
      "parameters": {
        "options": {},
        "jsonData": "={{ $json.body.content }}",
        "jsonMode": "expressionData",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "bda4ca91-117f-4527-b25d-c85908e50892",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1392,
        544
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 100
      },
      "typeVersion": 1
    },
    {
      "id": "ba74aea5-ec1c-4f63-92d8-98d6bb65805b",
      "name": "Notion Trigger",
      "type": "n8n-nodes-base.notionTrigger",
      "position": [
        160,
        -16
      ],
      "parameters": {
        "simple": false,
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "6ec8b622-d5bf-4c6a-80d9-7d668494f82b",
          "cachedResultUrl": "https://www.notion.so/6ec8b622d5bf4c6a80d97d668494f82b",
          "cachedResultName": "test database"
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7dcc8513-8db2-4f86-828f-35d02df20276",
      "name": "Pinecone Vector Store1",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        160,
        192
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "knkowledgebase"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n",
          "cachedResultName": "n8n"
        },
        "embeddingBatchSize": 50
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "fb314465-be01-4153-ae6b-21c20b24bff2",
      "name": "Embeddings Cohere1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        112,
        368
      ],
      "parameters": {
        "modelName": "embed-multilingual-v3.0"
      },
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8eb8639d-ef28-46e9-ab53-a1f80439e7d0",
      "name": "Default Data Loader1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        256,
        384
      ],
      "parameters": {
        "options": {},
        "jsonData": "={{ $json.plain_text }}",
        "jsonMode": "expressionData",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "11de6d57-20fc-4992-91e5-86bdb33ce145",
      "name": "Recursive Character Text Splitter1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        352,
        544
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 100
      },
      "typeVersion": 1
    },
    {
      "id": "8ac03efa-6af8-4139-837d-05adc99f1c79",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        960,
        208
      ],
      "parameters": {
        "compare": "selectedFields",
        "options": {},
        "fieldsToCompare": "body.content"
      },
      "typeVersion": 2
    },
    {
      "id": "8a1a6569-f578-4037-8464-728a52ea0d3e",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1312,
        -16
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "paragraph.text"
      },
      "typeVersion": 1
    },
    {
      "id": "36e5c0f6-7c24-442c-95c2-f88d23c1c83f",
      "name": "Get many child blocks",
      "type": "n8n-nodes-base.notion",
      "position": [
        368,
        -16
      ],
      "parameters": {
        "blockId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "resource": "block",
        "operation": "getAll",
        "returnAll": true,
        "simplifyOutput": false,
        "fetchNestedBlocks": true
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8015c6e9-7cd8-4e09-86ee-206cae5e2ab6",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        576,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "79a2b3f0-09f8-42b5-911d-85a27d04f121",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.type }}",
              "rightValue": "synced_block"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d4780200-8ee0-4fe4-bbaf-defac32f558f",
      "name": "Get many child blocks1",
      "type": "n8n-nodes-base.notion",
      "position": [
        848,
        -144
      ],
      "parameters": {
        "blockId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.synced_block.synced_from.block_id }}"
        },
        "resource": "block",
        "operation": "getAll",
        "returnAll": true,
        "simplifyOutput": false,
        "fetchNestedBlocks": true
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d81a6b16-36dd-4b3a-b1f8-937bf0a6f67a",
      "name": "Remove Duplicates1",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1520,
        -16
      ],
      "parameters": {
        "compare": "selectedFields",
        "options": {},
        "fieldsToCompare": "plain_text"
      },
      "typeVersion": 2
    },
    {
      "id": "c66e5310-f1b7-4591-9f62-a3c10b12d494",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1104,
        -16
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "437d367e-b497-4a47-974a-ca2e992723b7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        192
      ],
      "parameters": {
        "width": 1056,
        "height": 496,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "284ec18f-19dc-4168-b209-19b9f4869ad6",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        448
      ],
      "parameters": {
        "color": 5,
        "width": 496,
        "height": 208,
        "content": "## Outlook knowledge base\n\nthis workflow triggers when you put an email or thread into a specific folder (e.g knoledgebase). It captures the content of the thread, remove duplicates if any and store it in Pinecone vector store in a namespace called \"emails\" so your agent can look at those emails and understand the tone, looking for information and draft answers based on it's knowledge base and previous emails."
      },
      "typeVersion": 1
    },
    {
      "id": "8e739795-7835-4739-ba22-b55aa7cdb646",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1744,
        432
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful assistant. Your role is to answer the customer questions based on the knowledge base you have access to through the tools you have. If you don't find the answer in the knowledge base or previous emails don't come up with answer just tell the customer that you don't have this information."
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6d9a6b4c-6ba1-4c2f-9dbd-a7ee2c7ae881",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1696,
        208
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "85c8d7d3-e978-49f1-b4c5-ed0fcd9922af",
      "name": "Pinecone Vector Store2",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        2000,
        640
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "knowledgebase"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n",
          "cachedResultName": "n8n"
        },
        "toolDescription": "use this tool to look at your knowledge base."
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "2e1dad6b-adc1-43df-ab9a-af763fdb6021",
      "name": "Embeddings Cohere2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1936,
        784
      ],
      "parameters": {
        "modelName": "embed-multilingual-v3.0"
      },
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ce453bb0-fdb7-4170-9a15-2a3a154e12cb",
      "name": "Pinecone Vector Store3",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1744,
        640
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "emails"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n",
          "cachedResultName": "n8n"
        },
        "toolDescription": "use this tool to look at similar emails."
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "7329af25-ba0d-445d-9318-fb63991a19e9",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1632,
        640
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e0aee61b-469e-40cb-b609-8e4f641cecc8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        192
      ],
      "parameters": {
        "color": 4,
        "width": 688,
        "height": 736,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "39399055-a8e4-4dd7-8ac2-e46868d9aa6a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1936,
        208
      ],
      "parameters": {
        "color": 5,
        "width": 272,
        "height": 208,
        "content": "## Customer Support Agent\n\nit uses the knowledge base and emails you put into Pinecone vector store as it's reference to answer questions."
      },
      "typeVersion": 1
    },
    {
      "id": "17553913-1e31-4bbd-8acb-3d8586761814",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 496,
        "height": 192,
        "content": "## Notion knowledge base\n\nthis workflow triggers when you add a page to your Notion database, it captures the content of the page and store it in Pinecone vector store in a namespace called knowledgebase. The agent can access this data as it's knowledge base, get information from it and answers the question based on the information it has."
      },
      "typeVersion": 1
    },
    {
      "id": "31ff5834-459d-4081-a20f-3c3965469c4d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -256
      ],
      "parameters": {
        "color": 3,
        "width": 816,
        "height": 960,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "044d57f3-cb61-4f1c-a584-fc1b2aed3c59",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -256
      ],
      "parameters": {
        "color": 3,
        "width": 800,
        "height": 432,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a7a7243c-19b4-4006-a8a0-3c28e542e66f",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1712,
        784
      ],
      "parameters": {},
      "typeVersion": 1.3
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0f6bfeb3-c551-41ef-9cce-351a0ce86f09",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Get many child blocks1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Remove Duplicates1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Notion Trigger": {
      "main": [
        [
          {
            "node": "Get many child blocks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Get many messages": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere1": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere2": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store2",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Pinecone Vector Store3",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates1": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Get many child blocks": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many child blocks1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store2": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store3": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Microsoft Outlook Trigger": {
      "main": [
        [
          {
            "node": "Get many messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}