{
  "name": "Retrieve and answer Gmail email queries with Llama 3.2, mxbai-embed, and Qdrant",
  "nodes": [
    {
      "id": "5dddd013-33eb-4d44-b9b0-19825944060c",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -320,
        -208
      ]
    },
    {
      "id": "3de5c51c-02a4-4d0b-b3cd-1a2228a3f5ee",
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -128,
        -208
      ]
    },
    {
      "id": "6dc2432f-90af-4c20-897f-459196ce4e85",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        48,
        -208
      ]
    },
    {
      "id": "a420b373-77e1-465a-92e2-2509b6a823c7",
      "name": "Create Collection",
      "type": "n8n-nodes-qdrant.qdrant",
      "position": [
        576,
        -448
      ]
    },
    {
      "id": "9ad05ae8-e8fd-40da-bee6-a89066fd9817",
      "name": "Check If Collection Exists",
      "type": "n8n-nodes-qdrant.qdrant",
      "position": [
        32,
        -464
      ]
    },
    {
      "id": "d4a30be5-1e1b-4e89-9f47-3400b8a99a36",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        208,
        -464
      ]
    },
    {
      "id": "9b00c385-c89b-4086-8cf1-36d1bd017a51",
      "name": "Delete Collection",
      "type": "n8n-nodes-qdrant.qdrant",
      "position": [
        384,
        -576
      ]
    },
    {
      "id": "342e50cc-c02f-4be6-94db-2e9de5da2325",
      "name": "Upsert Points",
      "type": "n8n-nodes-qdrant.qdrant",
      "position": [
        816,
        -448
      ]
    },
    {
      "id": "b97f6489-35b6-4954-8557-33570f47a8d8",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -336,
        416
      ]
    },
    {
      "id": "12a35073-822e-4e1c-bdf4-83d29edcbd7f",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        224,
        400
      ]
    },
    {
      "id": "e725a619-28bf-450b-b254-ac1a36411d3b",
      "name": "Fetch Collection Name",
      "type": "n8n-nodes-base.code",
      "position": [
        -144,
        -464
      ]
    },
    {
      "id": "cf2e97a9-e0d2-4575-9fd3-cfe1e92bf974",
      "name": "Data Preprocessing",
      "type": "n8n-nodes-base.code",
      "position": [
        400,
        -208
      ]
    },
    {
      "id": "676476dd-79de-4c1b-b1db-2f0ac58df3d1",
      "name": "Embedding Generation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        592,
        -208
      ]
    },
    {
      "id": "d55fe456-10a8-4125-bda7-d083628a8ed3",
      "name": "Data Fetch",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        -208
      ]
    },
    {
      "id": "c5551fa5-6ac7-422e-96c4-17b6269e32ea",
      "name": "Query Embedding",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        48,
        224
      ]
    },
    {
      "id": "0da98ba8-9633-461e-855c-d670e111e5ed",
      "name": "Fields Preparation",
      "type": "n8n-nodes-base.set",
      "position": [
        -144,
        416
      ]
    },
    {
      "id": "ce84d2bd-ad68-41bf-b5f2-282a3a664d9d",
      "name": "Collection Name Fetch",
      "type": "n8n-nodes-base.code",
      "position": [
        48,
        416
      ]
    },
    {
      "id": "7408cf72-bd53-4ccd-96bd-237e7b44ac27",
      "name": "Similarity Search",
      "type": "n8n-nodes-qdrant.qdrant",
      "position": [
        400,
        400
      ]
    },
    {
      "id": "580a03f7-d870-46c2-b0f2-4411990eb24a",
      "name": "Send Repy Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        224
      ]
    },
    {
      "id": "9dda2726-3d88-404d-96cb-f01b1c292c20",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        608,
        224
      ]
    },
    {
      "id": "71575f27-a42c-4d54-b298-3af0aeb7736e",
      "name": "Email Format",
      "type": "n8n-nodes-base.set",
      "position": [
        928,
        224
      ]
    },
    {
      "id": "0fc58067-be90-46b8-92b4-e11b66957da7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -304
      ],
      "parameters": {
        "width": 640,
        "height": 624,
        "content": "## How it works\n1. **Knowledge Ingestion**: Monitors Google Drive for FAQ file updates, converts them into embeddings, and stores them in Qdrant.\n2. **Email Trigger**: Activates automatically whenever"
      }
    },
    {
      "id": "c4c50b1d-c723-417f-9d53-c44d2ffc63f5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        -256
      ],
      "parameters": {
        "width": 1152,
        "height": 352,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Knowledge Base Ingestion\nMonitors Google Drive for updates, downloads the FAQ file, and transforms the text into vector embeddings."
      }
    },
    {
      "id": "e3b71e76-3596-4c7e-87bb-fd56aa03793a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        -240
      ],
      "parameters": {
        "width": 368,
        "height": 240,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nYou must explicitly select your FAQ JSON file ID for the workflow to pull the correct data."
      }
    },
    {
      "id": "fb641e30-0415-481e-a849-82c7b73fdd81",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -656
      ],
      "parameters": {
        "width": 1088,
        "height": 368,
        "content": "## Vector Database Management\nChecks for existing Qdrant collections, recreates them to prevent duplicates, and upserts the new FAQ "
      }
    },
    {
      "id": "39090ff9-0e2e-4108-8914-e39d8f5b0768",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        112
      ],
      "parameters": {
        "width": 704,
        "height": 368,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## AI Reply Generation\nPrompts the local LLM to draft a professional HTML response and sends it back to the original email thread."
      }
    },
    {
      "id": "729f29e0-296f-4652-b893-51ca930cf243",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        144
      ],
      "parameters": {
        "width": 288,
        "height": 224,
        "content": "Ensure LM Studio is actively running the LLaMA model server; otherwise, the response generation will fail."
      }
    },
    {
      "id": "c236fa31-8d68-4345-8b5a-1ad70a7007e0",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        128
      ],
      "parameters": {
        "width": 224,
        "height": 240,
        "content": "The embedding URL must point to your host machine's actual local IP address so Docker can reach it."
      }
    },
    {
      "id": "28955379-182f-4053-a82d-531fd6bd9bde",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        112
      ],
      "parameters": {
        "width": 912,
        "height": 544,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Incoming Email Processing\nCatches incoming emails, generates an embedding for the user's question, and searches Qdrant for the best answer."
      }
    },
    {
      "id": "82e18e87-e13b-4a52-8752-16fd58362614",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -240
      ],
      "parameters": {
        "width": 224,
        "height": 272,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe embedding URL must point to your host machine's actual local IP address so Docker can reach it."
      }
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Delete Collection",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Collection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Similarity Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Fetch": {
      "main": [
        [
          {
            "node": "Data Preprocessing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Format": {
      "main": [
        [
          {
            "node": "Send Repy Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Fields Preparation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert Points": {
      "main": [
        []
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Email Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Embedding": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Collection": {
      "main": [
        [
          {
            "node": "Create Collection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Data Fetch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Similarity Search": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Preprocessing": {
      "main": [
        [
          {
            "node": "Embedding Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fields Preparation": {
      "main": [
        [
          {
            "node": "Query Embedding",
            "type": "main",
            "index": 0
          },
          {
            "node": "Collection Name Fetch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embedding Generation": {
      "main": [
        [
          {
            "node": "Upsert Points",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Collection Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collection Name Fetch": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Fetch Collection Name": {
      "main": [
        [
          {
            "node": "Check If Collection Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Collection Exists": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}