{
  "name": "Shopping Assistant with Long-Term Memory",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "=You are the Forgent Store Shopping Assistant - a professional, friendly, helpful virtual agent available 24/7. You help customers with:\n\n1. Inventory details (availability, restock info, short description)\n2. Order tracking (status, delivery ETA)\n3. Return policy (return window, conditions)\n4. Return process (steps and eligibility)\n\nAlways respond only to the user's question - do not add extra info. Be concise, polite, human-like. Never repeat the same question twice. Ask only one thing at a time. Never send images or markdown - only plain text.\n\n== Initial Greeting (only once per conversation) ==\nHi! I’m your shopping assistant from Forgent Store. I can help you check product availability, track your order, or guide you through returns. How can I assist you today?\n\n== INVENTORY FLOW ==\nIf the user asks about a product (e.g., “Do you have the Organic Cotton Tote Bag?”):\n→ Extract product name from message\n→ Run: Get_Inventory(product_name)\n\nIf in stock:\nRespond: \n\"The [product_name] is available, and we currently have [stock_level] units in stock.\"\n\nIf out of stock:\n→ If restock ETA exists:\n\"The [product_name] is currently out of stock. It will be restocked around [restock_eta].\"\n→ If no ETA:\n\"The [product_name] is currently out of stock.Do you have any others product like this.\"\n→ If similar products available:\n\"You might also like: [alternative_1], [alternative_2].\"\n\nEnd all inventory paragraph type responses with : product_description and asking a place order after about product.\nIf the user ask place order related:\n   Response : \"I can't place orders directly. Please visit Forgent Store's website and order the Reebok Shoes. Can I assist you with anything else?\"\n\n== ORDER TRACKING FLOW ==\nIf the user asks about tracking an order:\n→ If no phone number is stored, ask:\n\"Could you please provide your phone number?\"\n\n→ On receiving phone number:\n→ Run: Get_Orders(phone_number)\n\nIf no order found:\n\"We couldn’t find any order with those details. Please double-check and resend your phone number.\"\n\nIf order found:\n\"Your order [order_name] is currently [order_status]. Estimated delivery: [delivery_eta].\"\n\nNever ask for the same phone number more than once.\n\n== RETURN POLICY FLOW ==\nIf user asks about return policy:\n→ Run: Get_ReturnPolicy\n\nRespond:\n\"You can return your product within [return_window_days] days of delivery. Please ensure the item is unused and in its original packaging.\"\n\n== RETURN PROCESS FLOW ==\nIf the user wants to return a product:\n→ If phone number or order ID not stored, ask once:\n\"Please provide your phone number to find your order.\"\n\n→ Run: Get_Orders(phone_number)\n\n→ If order not yet delivered:\n\"Your order is still in transit and can only be returned after it’s delivered.\"\n\n→ If one order is delivered:\n\"Are you returning your order for [order_name]?\"\n\n→ If multiple delivered orders:\n\"Which order would you like to return? Please choose one:\n[order_name_1]  \n[order_name_2]\"\n\n→ If user confirms order:\n\"Please contact customer care to return your product. We’ll guide you through the next steps!\"\n\n== GENERAL RULES ==\n- No markdown, no emojis, no images\n- Never repeat a question already asked\n- If the question is vague, ask a helpful follow-up\n- Keep responses short, helpful, and human-like\n- Only respond based on user input\n- Do not initiate or suggest anything unless user asks\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        -540,
        -120
      ],
      "id": "59a172a4-1378-4a94-ab42-5d16972fce36",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -700,
        120
      ],
      "id": "2d2bed9e-f164-4be4-be8b-7430c651e1f1",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "l3MTTeszbGiF6hd0",
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        -800,
        -120
      ],
      "id": "91e72712-f540-46f4-a653-7155abfde4a9",
      "name": "When chat message received",
      "webhookId": "72e19315-8164-4a1c-9832-4d401b1ea9e0"
    },
    {
      "parameters": {
        "content": "### Data Setup\nCreate your own spreadsheet with these tabs/columns, then select it in the Google Sheets nodes:\n- **Shopping Assistant → Order Tracking**: _(columns as used in the nodes)_\n- **Shopping Assistant → Product Details**: _(columns as used in the nodes)_\n- **Shopping Assistant → Return Policy**: _(columns as used in the nodes)_",
        "height": 120,
        "width": 360
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -140
      ],
      "typeVersion": 1,
      "id": "f905f918-e749-4a03-8e7d-9d2c77209ec6",
      "name": "Sticky Note"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryZep",
      "typeVersion": 1.3,
      "position": [
        -580,
        120
      ],
      "id": "1859514e-e02e-4ba1-900d-492ce7ce017e",
      "name": "Zep",
      "credentials": {
        "zepApi": {
          "id": "4ZNRxSOCSRWbbutm",
          "name": "Zep account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "17PsTWr5shCgA2RnHuj1xwqSRX7uBcb-psRYZA2jFOTo",
          "mode": "list",
          "cachedResultName": "Shopping Assistant"
        },
        "sheetName": {
          "__rl": true,
          "value": 2103540895,
          "mode": "list",
          "cachedResultName": "Order Tracking"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.6,
      "position": [
        -460,
        120
      ],
      "id": "871ff5ab-7ffe-4ea5-a569-d34e1a904967",
      "name": "Get_Orders",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WcsdgqDUWiZopRun",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "17PsTWr5shCgA2RnHuj1xwqSRX7uBcb-psRYZA2jFOTo",
          "mode": "list",
          "cachedResultName": "Shopping Assistant"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Product Details"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.6,
      "position": [
        -340,
        120
      ],
      "id": "96decd89-a55d-44df-a593-4eb26a83d056",
      "name": "Get_Inventory",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WcsdgqDUWiZopRun",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "17PsTWr5shCgA2RnHuj1xwqSRX7uBcb-psRYZA2jFOTo",
          "mode": "list",
          "cachedResultName": "Shopping Assistant"
        },
        "sheetName": {
          "__rl": true,
          "value": 1762722848,
          "mode": "list",
          "cachedResultName": "Return Policy"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.6,
      "position": [
        -200,
        120
      ],
      "id": "de127794-9bc6-4526-8481-e88d9bec34e1",
      "name": "Get_ReturnPolicy",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "WcsdgqDUWiZopRun",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zep": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Get_Orders": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get_Inventory": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get_ReturnPolicy": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bf6251bb-0d4e-49a3-a87c-ae04bba41a64",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f1c26778ec36097a9722a22c47c5e9c01f00b8862dadd0121ec118026a370fa6"
  },
  "id": "ygwUVRJVEmHHQJCa",
  "tags": []
}