{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d817df16-9cdf-4da1-a4d9-618955ca33ba",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 1218,
        "height": 627,
        "content": "## Load Information from a Google Drive File into a Pinecone Vector Database\nFetch the file from Google Drive, split it into chunks, and insert the chunks into a Pinecone index."
      },
      "typeVersion": 1
    },
    {
      "id": "55e78874-5611-47a0-8050-5a88d1b8b316",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -20
      ],
      "parameters": {
        "width": 480,
        "height": 145,
        "content": "## Step 1: Connect Your Google Drive  \nFollow the instructions in the official n8n docs to set up your Google Drive credentials: \n\ud83d\udc49 [Google Drive Credentials Guide](https://docs.n8n.io/integrations/builtin/credentials/google/)"
      },
      "typeVersion": 1
    },
    {
      "id": "985c9095-5db4-40ff-afcf-fd28cddc789c",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        320,
        220
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "e68f329c-903c-497a-a154-088759abf376",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        400,
        340
      ],
      "parameters": {
        "options": {},
        "chunkSize": 3000,
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "59bdd73c-2ce0-4445-9f13-08daab0c878e",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        200,
        220
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "54b62825-fe42-45ff-8312-7b33ee5716b2",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1100,
        900
      ],
      "parameters": {
        "sessionKey": "={{ $json.from_number }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "73afa665-e178-419a-9134-0f7c85cc6c3b",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        860,
        920
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5d707996-888c-42e2-8b83-8f5d05f9b8fb",
      "name": "Question & Answer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        980,
        680
      ],
      "parameters": {
        "text": "=Sender Name: {{ $json.from_name }}\nMessage: {{ $json.from_name }}\n",
        "options": {
          "systemMessage": "Your custom prompt goes here"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "2ec9a53f-ef3a-4db2-97ca-f1cf92767d25",
      "name": "Respond to Whatsapp Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1320,
        680
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "63624687-3e24-4ba0-a8e1-590e01bcd616",
      "name": "Prepare chunks",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        680
      ],
      "parameters": {
        "jsCode": "let out = \"\"\nfor (const i in $input.all()) {\n  let itemText = \"--- CHUNK \" + i + \" ---\\n\"\n  itemText += $input.all()[i].json.document.pageContent + \"\\n\"\n  itemText += \"\\n\"\n  out += itemText\n}\n\nreturn {\n  'context': out,\n  'text': $('Listen to Whatsapp webhook').first().json.body.text,\n  'from_number': $('Listen to Whatsapp webhook').first().json.body.from_number,\n  'from_name': $('Listen to Whatsapp webhook').first().json.body.from_name\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "62cf7766-3262-4f65-8382-4f939e6d91cc",
      "name": "Get top chunks matching query",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        440,
        680
      ],
      "parameters": {
        "mode": "load",
        "topK": "={{ $json.chunks }}",
        "prompt": "={{ $json.body.text }}",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "3vansales",
          "cachedResultName": "3vansales"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "87c3fccf-725e-4c6b-a104-f4d751183ff8",
      "name": "Set max chunks to send to model",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        680
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "33f4addf-72f3-4618-a6ba-5b762257d723",
              "name": "chunks",
              "type": "number",
              "value": 4
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "7d1ca107-b6c5-4f00-ac67-0c171511ccfa",
      "name": "Embeddings OpenAI2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        440,
        900
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7b24f21d-cb06-4136-8215-40267957ee22",
      "name": "Check for individual or group messages",
      "type": "n8n-nodes-base.if",
      "position": [
        -60,
        700
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5a946369-3f38-4dcb-b5d9-3d24024d08b0",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.thread_type }}",
              "rightValue": "individual"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "935d9028-7e3b-4410-af8a-80b7470ef84f",
      "name": "Listen to Whatsapp webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -280,
        700
      ],
      "parameters": {
        "path": "d1629cd7-6e05-413a-bac0-3c435d4e43b9",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "a1002e9d-f2fa-4d26-85b5-8a64e870c77e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        580
      ],
      "parameters": {
        "color": 7,
        "width": 2034,
        "height": 627,
        "content": "### Chat with Your Vector Database Using a Custom WhatsApp Webhook (with Group Support)\nThis workflow takes incoming WhatsApp messages, embeds the content, retrieves relevant chunks from your vector store, and passes them to the model to generate a response."
      },
      "typeVersion": 1
    },
    {
      "id": "6a8d1f13-b940-42aa-8b86-596294b414f1",
      "name": "Download the file from Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -40,
        0
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "fdac8257-5a25-4a69-bb08-f133bbe32e4e",
      "name": "Index Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        220,
        0
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "clearNamespace": true
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "3vansales",
          "cachedResultName": "3vansales"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "eefbd2a8-cb76-4762-964a-05843e42ed83",
      "name": "Every minute check if file is updated",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -260,
        0
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFile",
        "fileToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1-AZrzOeeZFATUsY-xGD0m_oYkq4ekiSHn3e8Aof9pyU",
          "cachedResultUrl": "https://docs.google.com/document/d/1-AZrzOeeZFATUsY-xGD0m_oYkq4ekiSHn3e8Aof9pyU/edit?usp=drivesdk",
          "cachedResultName": "Knowladge Base FlatPack"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e43aeb7d-ba75-4c58-8032-0f04082edc42",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        160
      ],
      "parameters": {
        "width": 480,
        "height": 325,
        "content": "## Step 2: Set Up Your Pinecone Vector Database \n1. Log in to your Pinecone account and create an index: \n\ud83d\udea8 Dimensions: 1536\n2. In the workflow, make sure to select this index in **both Pinecone nodes**.\n3. Click \"Test Workflow\" to load your data into the vector database.\n4. Modify the connected document to fit your use case.\n\n**Note:** Once the bot is live, the vector database updates automatically every minute when changes are made. You can customize this update frequency if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "a2705d7c-c5cd-456f-898d-8845fb0668e2",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        520
      ],
      "parameters": {
        "color": 2,
        "width": 480,
        "height": 205,
        "content": "## Step 3: Connect your WhatsApp to N8N. \n1. Go to https://whaparound.pro/ \n2. Follow the steps to connect WhatsApp number to N8N. \n3. Once connected, come back here and customize the **AI agent's system prompt** to match your use case.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ba3ef38e-d594-4d8d-9860-755cf00e00e1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        760
      ],
      "parameters": {
        "color": 2,
        "width": 480,
        "height": 345,
        "content": "## Step 4: Test the WhatsApp Integration\n#### One-on-One Testing\n1. Use a different WhatsApp number to send a message to the connected number.\n2. You should receive a reply from the AI based on:\n  \u2705 Your system prompt\n  \u2705 The content in your vector database\n#### Group Testing\n1. Add the bot to a WhatsApp group. \n2. The bot will only reply when tagged or addressed directly, to avoid responding to every message in the group"
      },
      "typeVersion": 1
    },
    {
      "id": "3961d11e-34ae-4090-9b35-2b9ce62b9c13",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1560,
        -20
      ],
      "parameters": {
        "width": 480,
        "height": 645,
        "content": "## \ud83d\udd11 Key Benefits\n#### 1. No Meta Account Needed\n\ud83d\udc49 Works with regular WhatsApp numbers \u2014 no Facebook Business setup or official API required.\n\n#### 2. Group Chat Support\n\ud83d\udc49 Add the bot to any group. It only replies when tagged to avoid cluttering conversations.\n\n#### 3. Custom AI Responses\n\ud83d\udc49 Connect your own documents (via Google Drive + Pinecone) to deliver context-aware replies.\n\n#### 4. Auto-Syncing Knowledge Base\n\ud83d\udc49 Updates every minute when your source document changes \u2014 always fresh, always relevant.\n\n#### Use cases are endless\n\u2705 Customer support\n\u2705 Internal team assistant\n\u2705 Community group bot\n\u2705 Personal knowledge brain\n\nAnd so on "
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Question & Answer",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Prepare chunks": {
      "main": [
        [
          {
            "node": "Question & Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Index Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Question & Answer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Question & Answer": {
      "main": [
        [
          {
            "node": "Respond to Whatsapp Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI2": {
      "ai_embedding": [
        [
          {
            "node": "Get top chunks matching query",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Index Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Listen to Whatsapp webhook": {
      "main": [
        [
          {
            "node": "Check for individual or group messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get top chunks matching query": {
      "main": [
        [
          {
            "node": "Prepare chunks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set max chunks to send to model": {
      "main": [
        [
          {
            "node": "Get top chunks matching query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Download the file from Google Drive": {
      "main": [
        [
          {
            "node": "Index Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every minute check if file is updated": {
      "main": [
        [
          {
            "node": "Download the file from Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for individual or group messages": {
      "main": [
        [
          {
            "node": "Set max chunks to send to model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}