{
  "name": "E-commerce AI Agent with Real-Time Stock Check",
  "nodes": [
    {
      "parameters": {
        "content": "## Try It Out!\n\n**Shop chat agent that calls Feedpipe catalog tools before it quotes price or stock.**\n\n### To get started:\n1. **Connect OpenAI** (see red sticky note below)\n2. In **both** tools, replace `YOUR_SHOP` in the URL and `PASTE_SHOP_KEY` with your shop key from [feedpipe.app](https://feedpipe.app/ui/enter)\n3. Click **Open chat** and try asking:\n    * “Do you have a drill, and what’s the price?”\n    * “Find in-stock items under 2000”\n    * “Get product SKU-123”\n\n### Need a catalog?\nConnect a feed at [feedpipe.app](https://feedpipe.app/ui/welcome), run Collect, then paste the shop idn and key into the tools.\n\nDocs: [feedpipe.app/n8n.html](https://feedpipe.app/n8n.html)",
        "height": 460,
        "width": 392
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000001",
      "name": "Introduction Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-752, -256]
    },
    {
      "parameters": {
        "content": "## [Video Tutorial](https://youtu.be/REPLACE_WITH_YOUTUBE_ID)\n@[youtube](REPLACE_WITH_YOUTUBE_ID)\n\nReplace `REPLACE_WITH_YOUTUBE_ID` with your walkthrough video ID (the part after `v=` in the YouTube URL).",
        "height": 352,
        "width": 512,
        "color": 7
      },
      "id": "a1b2c3d4-0010-4000-8000-000000000010",
      "name": "Video Tutorial",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [592, -256]
    },
    {
      "parameters": {
        "content": "💡 Later, activate this workflow and share the public chat URL so customers can ask about products in your feed.",
        "height": 252,
        "width": 300,
        "color": 7
      },
      "id": "a1b2c3d4-0011-4000-8000-000000000011",
      "name": "Chat Trigger Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-272, -160]
    },
    {
      "parameters": {
        "content": "Your catalog agent can:\n1. **Receive** messages from the chat\n2. **Select** the right Feedpipe tool (search or product by SKU)\n3. **Respond** with live price and stock from the last collect\n\n\n**Open the AI agent node** and edit the **System Message** to adjust language, tone, and when it must call tools.",
        "height": 348,
        "width": 396,
        "color": 7
      },
      "id": "a1b2c3d4-0012-4000-8000-000000000012",
      "name": "Agent Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [112, -256]
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n1. Create an [OpenAI API key](https://platform.openai.com/api-keys).\n\n2. Open the ```Connect OpenAI``` node:\n   * **Select Credential → Create New**\n   * Paste the key and **Save**\n\nUse a model that supports tools (e.g. `gpt-4.1-mini`).",
        "height": 316,
        "width": 294,
        "color": 3
      },
      "id": "a1b2c3d4-0013-4000-8000-000000000013",
      "name": "Model Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-272, 176]
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\nThis node helps your agent remember the last few messages so follow-ups like “and the cheaper one?” stay on topic.",
        "height": 260,
        "width": 308,
        "color": 7
      },
      "id": "a1b2c3d4-0014-4000-8000-000000000014",
      "name": "Memory Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [112, 176]
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\nThese tools call Feedpipe (`GET /v1/catalog/{shop}/tools`):\n- **search_shop_catalog** — free-text / filters\n- **get_shop_product** — exact SKU\n\nReplace `YOUR_SHOP` and `PASTE_SHOP_KEY` in both nodes. Add more tools (Gmail, Calendar) under the agent’s Tool input if you want.",
        "height": 324,
        "width": 420,
        "color": 7
      },
      "id": "a1b2c3d4-0015-4000-8000-000000000015",
      "name": "Tools Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [480, 176]
    },
    {
      "parameters": {
        "public": true,
        "options": {}
      },
      "id": "a1b2c3d4-0002-4000-8000-000000000002",
      "name": "Example Chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [-176, -64],
      "webhookId": "ecommerce-stock-check"
    },
    {
      "parameters": {
        "promptType": "auto",
        "options": {
          "systemMessage": "You are a shop assistant. You can answer only by calling the catalog tools. search_shop_catalog and get_shop_product read a feed snapshot.\n\nWhen the customer asks about a product, a price, or availability:\n1. In the same reply, say \"Зараз перевірю наявність.\" (or the equivalent in the customer's language).\n2. Call a tool before you name any price, stock state, or product. If they give an exact article, call get_shop_product. Otherwise call search_shop_catalog and put their words in q.\n3. Leave sku as an empty string, and leave min_price and max_price null, unless they named an article or a price range. Set in_stock_only only when they want confirmed in-stock items. Keep limit at 5.\n\nThe tool returns JSON. Read items for the customer. Take price, stock, and url from items. Never invent them. stock \"unknown\" means the feed said nothing — do not promise that item is available. stock \"out_of_stock\" means it is not available. If catalog.stale is true, say the price must be confirmed. If count is 0 or the product tool returns 404, say nothing matched. Do not paste raw JSON into the chat.",
          "maxIterations": 6
        }
      },
      "id": "a1b2c3d4-0003-4000-8000-000000000003",
      "name": "Catalog AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [192, -64]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "id": "a1b2c3d4-0004-4000-8000-000000000004",
      "name": "Connect OpenAI",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [-176, 224]
    },
    {
      "parameters": {
        "contextWindowLength": 10
      },
      "id": "a1b2c3d4-0005-4000-8000-000000000005",
      "name": "Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [224, 224]
    },
    {
      "parameters": {
        "toolDescription": "Search the shop catalog by the customer's words, an article, or a price range. Call this before any answer about price, availability, or which product to buy. Pass q in the customer's words. Leave sku empty and min_price/max_price null when not asked. Returns items (exact price, stock, url) and catalog.stale.",
        "method": "POST",
        "url": "https://feedpipe.app/v1/catalog/YOUR_SHOP/search",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer PASTE_SHOP_KEY"
            }
          ]
        },
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ q: $fromAI('q', 'What the customer asked, in their own words', 'string'), sku: $fromAI('sku', 'Exact article. Empty string when the customer did not name one', 'string', ''), min_price: $fromAI('min_price', 'Lower price bound, or null when the customer did not set one', 'number', null), max_price: $fromAI('max_price', 'Upper price bound, or null when the customer did not set one', 'number', null), limit: $fromAI('limit', 'How many products to return, from 1 to 5', 'number', 5), in_stock_only: $fromAI('in_stock_only', 'True only when the customer wants confirmed in-stock items', 'boolean', false) }) }}",
        "options": {}
      },
      "id": "a1b2c3d4-0006-4000-8000-000000000006",
      "name": "search_shop_catalog",
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [544, 224]
    },
    {
      "parameters": {
        "toolDescription": "Fetch one product by its exact article number (SKU). Use this when the customer names an article. Returns the same JSON as search: items and catalog.stale. A 404 means that article is not in the catalog.",
        "method": "GET",
        "url": "={{ 'https://feedpipe.app/v1/catalog/YOUR_SHOP/products/' + encodeURIComponent($fromAI('sku', 'Exact article number the customer named', 'string')) }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer PASTE_SHOP_KEY"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0007-4000-8000-000000000007",
      "name": "get_shop_product",
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [688, 224]
    }
  ],
  "connections": {
    "Example Chat": {
      "main": [
        [
          {
            "node": "Catalog AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Connect OpenAI": {
      "ai_languageModel": [
        [
          {
            "node": "Catalog AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "Catalog AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "search_shop_catalog": {
      "ai_tool": [
        [
          {
            "node": "Catalog AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_shop_product": {
      "ai_tool": [
        [
          {
            "node": "Catalog AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "tags": []
}
