{
  "id": "IcDm4gOustCzuLFt",
  "name": "Travel Support RAG Chatbot with Pinecone and OpenAI",
  "tags": [],
  "nodes": [
    {
      "id": "cee1eb3d-6ea1-435c-a1af-b0251ae00660",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        -64
      ],
      "parameters": {
        "color": 4,
        "width": 512,
        "height": 768,
        "content": "## Travel Support RAG Chatbot\n\nThis workflow creates a simple RAG chatbot for a travel, booking, or customer support business.\n\nIt has two parts:\n\n1. Knowledge indexing: download a knowledge document from Google Drive, split it into chunks, create embeddings, and store them in Pinecone.\n\n2. Chatbot response: receive a customer question through a webhook, retrieve relevant context from Pinecone, generate a short answer with OpenAI, and return the answer to the frontend.\n\nBefore using this template, add your own Google Drive, OpenAI, and Pinecone credentials."
      },
      "typeVersion": 1
    },
    {
      "id": "9b09d6eb-24fb-4742-b353-04c60c25f0be",
      "name": "Knowledge Indexing Notes",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -48
      ],
      "parameters": {
        "color": 5,
        "width": 816,
        "height": 912,
        "content": "## 1. Knowledge indexing setup\n\nRun this section first.\n\nReplace the Google Drive file placeholder with your own document file ID. The file should contain the business knowledge you want the chatbot to answer from.\n\nReplace the Pinecone index placeholder with your own Pinecone index name. Make sure the embedding dimensions match your Pinecone index configuration."
      },
      "typeVersion": 1
    },
    {
      "id": "31c6acbb-2367-49d6-8e58-508794ff54fa",
      "name": "Chatbot Response Notes",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        -48
      ],
      "parameters": {
        "color": 4,
        "width": 1184,
        "height": 1088,
        "content": "## 2. Chatbot response setup\n\nThis section receives a POST request with a chatInput value.\n\nExample request body:\n\n{\n  \"chatInput\": \"What is your refund policy?\"\n}\n\nThe workflow retrieves relevant context from Pinecone, generates a short answer, formats the response, and returns it through Respond to Webhook.\n\nUpdate the system prompt to match your business tone and support rules."
      },
      "typeVersion": 1
    },
    {
      "id": "0746ed68-a5e1-437b-9fb4-b7fc26d5d643",
      "name": "Download Knowledge File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        528,
        320
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "REPLACE_WITH_YOUR_GOOGLE_DRIVE_FILE_ID"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "3c1716b0-3b38-4c94-97b5-1335d637316a",
      "name": "Insert Documents into Pinecone",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        736,
        320
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_PINECONE_INDEX_NAME"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "6f9ddd37-4020-4a35-881c-26bea9f4bdfd",
      "name": "Create Embeddings for Indexing",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        736,
        528
      ],
      "parameters": {
        "options": {
          "batchSize": 512,
          "dimensions": 512,
          "stripNewLines": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e9870dcf-0868-468c-83a2-a5c464daee2a",
      "name": "Load Downloaded Document",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        896,
        512
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "bd1fe332-140c-419a-92af-b0e78ebdef93",
      "name": "Split Document into Chunks",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        896,
        672
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "46bd004e-f348-4d19-9910-8a35a97284c0",
      "name": "Manual Trigger - Index Knowledge Base",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        320,
        320
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "da3046ed-e482-4966-b8a1-3854b2e810c7",
      "name": "Answer Question with Retrieved Context",
      "type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
      "maxTries": 2,
      "position": [
        1616,
        272
      ],
      "parameters": {
        "text": "={{ $json.body.chatInput }}\n{{ $json.chatInput }}",
        "options": {
          "systemPromptTemplate": "You are a helpful customer support assistant for a travel, booking, or service business. Your role is to answer customer questions about bookings, cancellations, refunds, and services using the retrieved knowledge base context.\n\nIMPORTANT RESPONSE RULES:\n1. Keep responses SHORT and focused - max 2-3 sentences per message\n2. Answer ONLY what was asked - don't volunteer extra information\n3. Use simple, conversational language\n4. One idea per message\n5. If uncertain, say \"I'm not sure - let me connect you with our team\"\n\nContext: {context}"
        },
        "promptType": "define"
      },
      "retryOnFail": true,
      "typeVersion": 1.7
    },
    {
      "id": "a24e8829-9fbf-4442-a9cd-0830c01cb870",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "maxTries": 2,
      "position": [
        1616,
        496
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1"
        },
        "options": {},
        "builtInTools": {}
      },
      "retryOnFail": true,
      "typeVersion": 1.3
    },
    {
      "id": "d449ddbc-133a-4085-a7f0-6fcd0516d469",
      "name": "Retrieve Matching Knowledge",
      "type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
      "position": [
        1824,
        528
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e8f1c760-0903-4102-b9a0-8dc7d3336fcc",
      "name": "Search Pinecone Knowledge Base",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1648,
        704
      ],
      "parameters": {
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_PINECONE_INDEX_NAME"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "00e75502-63fd-4b86-bf7a-f0875c6100c5",
      "name": "Create Query Embedding",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1648,
        848
      ],
      "parameters": {
        "options": {
          "dimensions": 512,
          "stripNewLines": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "27d6828d-c45a-43b7-bf82-f4a85e554cdc",
      "name": "Format Chatbot Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1968,
        272
      ],
      "parameters": {
        "jsCode": "// Get the response from input\nconst response = $input.all()[0].json.response;\n\n// Remove all newlines and trim extra spaces\nconst cleanedResponse = response.replace(/\\n/g, \" \").trim();\n\nreturn [\n  {\n    json: {\n      text: cleanedResponse\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "cc24081f-10d2-43b5-b39d-b963d7f9531e",
      "name": "Chatbot Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "position": [
        1328,
        272
      ],
      "parameters": {
        "path": "travel-rag-chatbot",
        "options": {
          "allowedOrigins": "*",
          "responseHeaders": {
            "entries": [
              {
                "name": "Access-Control-Allow-Headers",
                "value": "Content-Type"
              },
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              },
              {
                "name": "Access-Control-Allow-Methods",
                "value": "GET, POST, OPTIONS "
              }
            ]
          }
        },
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "46a123df-1975-4fc6-b8f2-f50d5f694bfa",
      "name": "Return Answer to Frontend",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2176,
        272
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.5
    },
    {
      "id": "f4d67e47-1491-4801-b065-40831f3a113e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1472,
        -336
      ],
      "parameters": {
        "width": 960,
        "height": 272,
        "content": "## Setup required\n\nConnect your own:\n- Google Drive account\n- OpenAI account\n- Pinecone account\n\nThen replace:\n- Google Drive file placeholder\n- Pinecone index placeholder\n- System prompt business details\n- Webhook path if needed"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "67a46195-45d4-4146-afe6-5d8fbda0c964",
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer Question with Retrieved Context",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create Query Embedding": {
      "ai_embedding": [
        [
          {
            "node": "Search Pinecone Knowledge Base",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Chatbot Webhook Trigger": {
      "main": [
        [
          {
            "node": "Answer Question with Retrieved Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Knowledge File": {
      "main": [
        [
          {
            "node": "Insert Documents into Pinecone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Chatbot Response": {
      "main": [
        [
          {
            "node": "Return Answer to Frontend",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Downloaded Document": {
      "ai_document": [
        [
          {
            "node": "Insert Documents into Pinecone",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Split Document into Chunks": {
      "ai_textSplitter": [
        [
          {
            "node": "Load Downloaded Document",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Matching Knowledge": {
      "ai_retriever": [
        [
          {
            "node": "Answer Question with Retrieved Context",
            "type": "ai_retriever",
            "index": 0
          }
        ]
      ]
    },
    "Create Embeddings for Indexing": {
      "ai_embedding": [
        [
          {
            "node": "Insert Documents into Pinecone",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Search Pinecone Knowledge Base": {
      "ai_vectorStore": [
        [
          {
            "node": "Retrieve Matching Knowledge",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger - Index Knowledge Base": {
      "main": [
        [
          {
            "node": "Download Knowledge File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer Question with Retrieved Context": {
      "main": [
        [
          {
            "node": "Format Chatbot Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}