{
  "name": "Facebook Messenger Chatbot That Learns From Your Documents",
  "nodes": [
    {
      "id": "866ee81f-f01b-4f5f-a1b8-d4d005a262ea",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5008,
        3056
      ],
      "parameters": {
        "width": 520,
        "height": 800,
        "content": "# Facebook Messenger AI Chatbot with Pinecone RAG\n\n## Who is this for?\nBusinesses who want to automate customer interactions on Facebook Messenger using AI that can answer questions from your document"
      }
    },
    {
      "id": "cda30df8-a761-4dfa-b655-2b8a07288261",
      "name": "Sticky Note - Webhook Verification",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5600,
        2768
      ],
      "parameters": {
        "width": 520,
        "height": 280,
        "content": "## 1. Webhook Verification\n\nFacebook sends a GET request to verify your webhook URL during setup.\n\n**How it works:**\n1. Facebook sends `hub.verify_token` and `hub.challenge`\n2. We validate the token m"
      }
    },
    {
      "id": "12b7a811-0266-40f7-9b71-479d2407e9b2",
      "name": "Sticky Note - Message Receipt",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5616,
        3728
      ],
      "parameters": {
        "width": 540,
        "height": 332,
        "content": "## 2. Receive & Filter Messages\n\nHandles incoming POST requests from Facebook when users send messages.\n\n**How it works:**\n1. Immediately acknowledge with `EVENT_RECEIVED` (required by Facebook)\n2. Fi"
      }
    },
    {
      "id": "3164fd54-2389-4e8c-9bf1-b6e3d5d9949f",
      "name": "Sticky Note - Message Batching",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6320,
        3040
      ],
      "parameters": {
        "width": 740,
        "height": 300,
        "content": "## 3. Message Batching (Smart Feature!)\n\nUsers often send multiple quick messages. This section combines them into one request.\n\n**How it works:**\n1. Store each message in workflow static data\n2. Send"
      }
    },
    {
      "id": "63db4412-d223-4a93-8f6d-be45941301c3",
      "name": "Sticky Note - AI Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7536,
        2784
      ],
      "parameters": {
        "width": 480,
        "height": 480,
        "content": "## 4. AI Agent with Pinecone RAG\n\nThe brain of the chatbot - powered by OpenAI + Pinecone.\n\n**Components:**\n- **OpenAI Chat Model:** Uses GPT-4o-mini for responses\n- **Conversation Memory:** Remembers"
      }
    },
    {
      "id": "a0f6ec23-6bc9-45ee-b1f0-944f06d6d5e1",
      "name": "Sticky Note - Pinecone Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7856,
        3712
      ],
      "parameters": {
        "width": 400,
        "height": 280,
        "content": "### Pinecone Setup\n\n1. Create account at [pinecone.io](https://www.pinecone.io)\n2. Create an Assistant named `n8n-assistant`\n3. Upload your documents to the Assistant\n4. Get your API key from the Pine"
      }
    },
    {
      "id": "1ae54fd5-b47a-4f87-b94c-4c5535ddac0e",
      "name": "Sticky Note - OpenAI Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7168,
        3760
      ],
      "parameters": {
        "width": 380,
        "height": 216,
        "content": "### OpenAI Credential Setup\n\n1. Go to [OpenAI API Keys](https://platform.openai.com/api-keys)\n2. Click **Create new secret key**\n3. Copy the key\n4. In n8n: Click the OpenAI node -> Credential -> Creat"
      }
    },
    {
      "id": "a1965c3c-2d3b-4a67-b10f-197ebca239b8",
      "name": "Sticky Note - Response",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        8064,
        2976
      ],
      "parameters": {
        "width": 540,
        "height": 280,
        "content": "## 5. Format & Send Response\n\n**How it works:**\n1. Format AI response for Messenger (remove markdown)\n2. Truncate if over 1900 characters\n3. Send via Facebook Graph API\n\n**Response includes:**\n- Prope"
      }
    },
    {
      "id": "67a7da1b-8110-48be-824c-d3429a8f8054",
      "name": "Sticky Note - Facebook Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6384,
        3632
      ],
      "parameters": {
        "width": 460,
        "height": 240,
        "content": "### Facebook Graph API Credential Setup\n\n1. Create a Facebook App at [developers.facebook.com](https://developers.facebook.com)\n2. Add **Messenger** product to your app\n3. Connect a Facebook Page\n4. G"
      }
    },
    {
      "id": "5c1c1a54-5e97-429f-a944-8264882d9dc7",
      "name": "Facebook Verification Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        5632,
        3168
      ]
    },
    {
      "id": "cd320e99-8f67-4499-827c-f440cc49bd40",
      "name": "Facebook Message Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        5648,
        3520
      ]
    },
    {
      "id": "9ea3708e-d19c-4c40-819c-77fa7e709154",
      "name": "Is Token Valid?",
      "type": "n8n-nodes-base.if",
      "position": [
        5856,
        3168
      ]
    },
    {
      "id": "d21d92ed-91b8-44f9-bef2-6d9694d285f1",
      "name": "Respond with Challenge",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        6080,
        3088
      ]
    },
    {
      "id": "80e766d3-414c-4597-bf8e-9ae5ce9c47a8",
      "name": "Respond Forbidden",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        6080,
        3248
      ]
    },
    {
      "id": "20969b8e-8f11-4881-a0a9-4df73532bc52",
      "name": "Acknowledge Event",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        5872,
        3520
      ]
    },
    {
      "id": "dbd43cd0-f776-49e8-9071-d191a6c48389",
      "name": "Filter Valid Messages",
      "type": "n8n-nodes-base.if",
      "position": [
        6096,
        3520
      ]
    },
    {
      "id": "d16aa51b-896a-4660-9da3-a8a9c5dcc4cc",
      "name": "Store Message for Batching",
      "type": "n8n-nodes-base.code",
      "position": [
        6320,
        3424
      ]
    },
    {
      "id": "afd69549-cb23-4fa6-9312-df2694e3fa2e",
      "name": "Send Seen Indicator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6544,
        3424
      ]
    },
    {
      "id": "71c1f6fc-aeb8-43e2-95a3-fc6e2971e518",
      "name": "Wait 3 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        6768,
        3424
      ]
    },
    {
      "id": "12f6e864-7a6f-471a-b321-70eb5fbdfcc3",
      "name": "Retrieve Batched Messages",
      "type": "n8n-nodes-base.code",
      "position": [
        6992,
        3424
      ]
    },
    {
      "id": "9475f390-beed-4654-9883-ac2940b79233",
      "name": "Has Messages to Process?",
      "type": "n8n-nodes-base.if",
      "position": [
        7216,
        3424
      ]
    },
    {
      "id": "54254117-c8b2-4ff6-becd-7ae6c8b4db8d",
      "name": "Send Typing Indicator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        7440,
        3328
      ]
    },
    {
      "id": "0e8e3e5f-c153-4dd0-913b-94cfba179f66",
      "name": "Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        7632,
        3632
      ]
    },
    {
      "id": "7f12fd6e-392c-48bd-b247-31e4e7582ba0",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        7296,
        3632
      ]
    },
    {
      "id": "3ada67ba-1bf5-4e72-8947-09a0b15e55c6",
      "name": "Format Response",
      "type": "n8n-nodes-base.code",
      "position": [
        8064,
        3328
      ]
    },
    {
      "id": "2cdd999c-7068-4d74-8a7b-7842ce6fc6e7",
      "name": "Send Response to User",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        8288,
        3328
      ]
    },
    {
      "id": "a53563d7-2886-456e-880e-8c3474f09a8b",
      "name": "Success",
      "type": "n8n-nodes-base.set",
      "position": [
        8512,
        3328
      ]
    },
    {
      "id": "7e31988e-4371-4770-a4dc-37a2d95a1361",
      "name": "Get context snippets in Pinecone Assistant",
      "type": "@pinecone-database/n8n-nodes-pinecone-assistant.pineconeAssistantTool",
      "position": [
        8000,
        3552
      ]
    },
    {
      "id": "187d190c-512f-41b6-a7fe-05863d5e3e04",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        7712,
        3328
      ]
    }
  ],
  "connections": {
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 3 Seconds": {
      "main": [
        [
          {
            "node": "Retrieve Batched Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Send Response to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Token Valid?": {
      "main": [
        [
          {
            "node": "Respond with Challenge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Forbidden",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Acknowledge Event": {
      "main": [
        [
          {
            "node": "Filter Valid Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Send Seen Indicator": {
      "main": [
        [
          {
            "node": "Wait 3 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Valid Messages": {
      "main": [
        [
          {
            "node": "Store Message for Batching",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Response to User": {
      "main": [
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Typing Indicator": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Facebook Message Webhook": {
      "main": [
        [
          {
            "node": "Acknowledge Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Messages to Process?": {
      "main": [
        [
          {
            "node": "Send Typing Indicator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Batched Messages": {
      "main": [
        [
          {
            "node": "Has Messages to Process?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Message for Batching": {
      "main": [
        [
          {
            "node": "Send Seen Indicator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Facebook Verification Webhook": {
      "main": [
        [
          {
            "node": "Is Token Valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get context snippets in Pinecone Assistant": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}