{
  "name": "Transform chatbots into AI advisors with memory and real-time context",
  "nodes": [
    {
      "id": "481dfc28-ff80-4041-b160-b3a793228a39",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        -864
      ]
    },
    {
      "id": "824a2fe4-81cf-437b-af4e-529b90666055",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -432,
        -864
      ]
    },
    {
      "id": "97b40d4f-b79f-47b4-b996-3abdcc176cd2",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1344,
        -864
      ]
    },
    {
      "id": "0c5c9907-652d-4dab-a6c4-fab1521da07a",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        -576
      ]
    },
    {
      "id": "c51b8e6a-99af-4b48-8d01-1c8423acc3f1",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        528,
        -864
      ]
    },
    {
      "id": "e82ddd5b-060b-4fe1-9368-45427751d300",
      "name": "Get many products",
      "type": "n8n-nodes-base.shopify",
      "position": [
        128,
        -864
      ]
    },
    {
      "id": "6b457ea9-4f40-4c3b-bf91-6ee8d20c70e0",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        608,
        -592
      ]
    },
    {
      "id": "e3e1281d-4353-4e41-83a8-1e6e341e3872",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1184,
        -1296
      ],
      "parameters": {
        "width": 576,
        "height": 496,
        "content": "## AI Advisor with Memory and Real-Time Context\n\n### How it works\nThis workflow turns a generic chatbot into an AI advisor that remembers users and responds using real business data.\n\nIt combines user"
      }
    },
    {
      "id": "7e4c6da8-895b-43f8-a3c3-5aad74b63561",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -1168
      ],
      "parameters": {
        "width": 432,
        "height": 480,
        "content": "## Section 1 — Input & User Identification\n\nReceives the incoming message and extracts the chat_id used to uniquely identify the user.\n\nThis ensures every message can be linked to the correct conversa"
      }
    },
    {
      "id": "808a70ec-8092-4c8c-ba29-8e950bbb5e39",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -1168
      ],
      "parameters": {
        "width": 336,
        "height": 512,
        "content": "## Section 2 — Real-Time Context\n\nFetches the live product catalog directly from the store.\n\nThis prevents the AI from hallucinating product names or prices.\n"
      }
    },
    {
      "id": "9d6f718e-b2ab-4c67-aec9-339a85512863",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -1168
      ],
      "parameters": {
        "width": 512,
        "height": 720,
        "content": "## Section 3 — AI Reasoning & Memory\n\nCombines user input, historical memory, and real-time data to generate a contextual response.\n\nThis is where personalization, rules, and long-term memory are appl"
      }
    },
    {
      "id": "0120d21c-e550-4e57-9030-66779283d6ef",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        -1168
      ],
      "parameters": {
        "width": 704,
        "height": 544,
        "content": "## Section 4 — Output & Delivery\n\nValidates that the AI response is valid JSON and applies a fallback if needed.\n\nSends the final, safe response back to the user via Telegram.\n"
      }
    },
    {
      "id": "e5d3f936-e207-40f1-a51e-54d07bcc1632",
      "name": "Code in JavaScript 2",
      "type": "n8n-nodes-base.code",
      "position": [
        1088,
        -864
      ]
    },
    {
      "id": "2c15000e-c941-4b79-af53-32bf3ae07009",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        -672
      ],
      "parameters": {
        "width": 272,
        "height": 192,
        "content": "⚠️ Important\n\nThis workflow requires valid JSON output from the AI.\n\nIf you modify the system prompt, make sure the response format is preserved to avoid parsing errors.\n"
      }
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code in JavaScript 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many products": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Get many products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript 2": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  }
}