{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "08545593-4695-4026-ba55-d1d58a01fbf6",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        640,
        -800
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFile",
        "fileToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1qz6aQrwo6LyWhPLlij-v0RZE4DtZe85L",
          "cachedResultUrl": "https://drive.google.com/file/d/1qz6aQrwo6LyWhPLlij-v0RZE4DtZe85L/view?usp=drivesdk",
          "cachedResultName": "restaurant_full_rag_dataset.pdf"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cd8f31f5-dd48-40f0-9138-2a4924709eab",
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        848,
        -800
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "6214c5d2-8cfe-45c7-b0b1-95323120bb24",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1072,
        -800
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "restaurant",
          "cachedResultName": "restaurant"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0982afed-4193-4c5d-aa98-a9df27d2113f",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1968,
        -416
      ],
      "parameters": {
        "options": {
          "dimensions": 512
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4aaa3a79-ef9d-4a61-ad29-dbde97b2d61d",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1040,
        -640
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "file-name",
                "value": "={{ $('Download file').item.json.name }}"
              }
            ]
          }
        },
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "e832710a-38fa-4251-8fca-24ab3e4dc5c7",
      "name": "Recursive Character Text Splitter1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1040,
        -496
      ],
      "parameters": {
        "options": {},
        "chunkSize": 100,
        "chunkOverlap": 20
      },
      "typeVersion": 1
    },
    {
      "id": "500adcb8-c88f-42ce-a304-b56af4ef9051",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "disabled": true,
      "position": [
        1488,
        -704
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "ce938ad4-cc83-4435-b23f-8c06adf845dc",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1776,
        -800
      ],
      "parameters": {
        "text": "=User : {{ $json.messages[0].text.body }}",
        "options": {
          "systemMessage": "You are a friendly assistant. When a question comes in, use only the information retrieved from the vector database to answer. Speak casually and naturally, like a real person helping a customer. Keep replies short, clear, and to the point. If something isn\u2019t in the retrieved context, just say you\u2019re not sure instead of guessing. Do not make up details."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "7effc941-5403-4b4d-9ac3-41255c845179",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1712,
        -576
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e6d9c355-971f-49a0-9bd5-d849639a7684",
      "name": "Pinecone Vector Store1",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1968,
        -576
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 5,
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "restaurant",
          "cachedResultName": "restaurant"
        },
        "toolDescription": "Stores restaurant menu, dish, order, customer and info embeddings for fast semantic retrieval to support RAG-based restaurant queries."
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "33a196f5-8a72-4b63-af9d-ff8a08a09db1",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1840,
        -576
      ],
      "parameters": {
        "sessionKey": "1",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "d88601d1-f83c-46ea-9ab3-c5158d1aeb89",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1184,
        -496
      ],
      "parameters": {
        "options": {
          "dimensions": 512
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b5f80994-429a-4685-95d6-6ff3d9c45758",
      "name": "Send message",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2128,
        -800
      ],
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "Enter sender phone number id",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('WhatsApp Trigger').item.json.messages[0].from }}"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ac8f0ef7-5a1e-4642-8d5f-c078ffe25fd6",
      "name": "WhatsApp Trigger",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        1488,
        -896
      ],
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6e720df6-9ff0-4737-8700-e02919461fe2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        -1424
      ],
      "parameters": {
        "width": 480,
        "height": 528,
        "content": "## How it Works\nThis workflow creates a RAG-based WhatsApp chatbot using your own documents.\n\nStep 1 -\nautomatically processes documents you upload to a Google Drive folder and generates embeddings and stores them inside a Pinecone Database. This prepares your knowledge base.\n\nStep 2 -\nlistens for incoming WhatsApp messages. When someone sends a message, the AI Agent fetches relevant context from Pinecone and uses the selected model to generate a helpful response. The final answer is then sent back to the user through WhatsApp.\n\n\n## Setup Steps\n\n-Connect Google Drive and select your source folder.\n-Add your Pinecone API key + index name.\n-Add your OpenAI API key for embeddings.\n-Connect your WhatsApp trigger and sender nodes.\n-Configure the AI Agent with your model.\n-Upload a test document and send a WhatsApp message to verify."
      },
      "typeVersion": 1
    },
    {
      "id": "7f411f6a-5cb7-4355-9e4f-73ec9e6fce9c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -960
      ],
      "parameters": {
        "color": 7,
        "width": 512,
        "height": 96,
        "content": "### Document Processing & Embeddings\nProcesses uploaded Drive files, splits text into chunks, creates embeddings with OpenAI, and stores them in the Pinecone vector index."
      },
      "typeVersion": 1
    },
    {
      "id": "c6e8cacf-86e2-4e64-ac79-e4426a2620f4",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1680,
        -992
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 96,
        "content": "### WhatsApp Message Flow\nReceives incoming WhatsApp messages, sends the query to the AI Agent, and returns the generated answer to the user."
      },
      "typeVersion": 1
    },
    {
      "id": "aeeb9736-3cf6-4464-819d-bd602db85a65",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2128,
        -448
      ],
      "parameters": {
        "color": 7,
        "width": 448,
        "height": 96,
        "content": "### AI Retrieval & Response Logic\nThe AI Agent retrieves relevant vectors from Pinecone and uses them as context to generate accurate answers through RAG."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}