{
  "name": "🐋🤖 DeepSeek AI agent + Telegram + LONG TERM memory 🧠",
  "nodes": [
    {
      "id": "23b50c07-39a8-4166-ab13-9683b3ee25e6",
      "name": "Check User & Chat ID",
      "type": "n8n-nodes-base.if",
      "position": [
        -80,
        160
      ]
    },
    {
      "id": "ecbc13fe-305d-4cdd-b35c-3e119e8e8b5d",
      "name": "Error message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        160,
        440
      ]
    },
    {
      "id": "be722bc7-0b22-4892-967c-fdd398a7b129",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -540,
        -20
      ],
      "parameters": {
        "width": 949,
        "height": 652,
        "content": "# Receive Telegram Message with Webhook"
      }
    },
    {
      "id": "a3866585-bfee-4025-a8f4-f06fde16171a",
      "name": "Listen for Telegram Events",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -480,
        160
      ]
    },
    {
      "id": "f70571d5-3680-4616-90fa-3358b0883368",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1380,
        -20
      ],
      "parameters": {
        "width": 800,
        "height": 860,
        "content": "# How to set up a Telegram Bot WebHook\n\n## WebHook Setup Process\n\n**Basic Concept**\nA WebHook allows your Telegram bot to automatically receive updates instead of manually polling the Bot API.\n\n**Setu"
      }
    },
    {
      "id": "2b6149d5-ffd6-46ef-9840-149508251a77",
      "name": "Validation",
      "type": "n8n-nodes-base.set",
      "position": [
        -260,
        160
      ]
    },
    {
      "id": "41c965ea-b67d-4d6b-82e4-0e57f5fc13bb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        100
      ],
      "parameters": {
        "width": 420,
        "height": 260,
        "content": "## Validate Telegram User\n"
      }
    },
    {
      "id": "164f5e91-1958-4dc5-b38c-db1cec0579d4",
      "name": "Message Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        160,
        160
      ]
    },
    {
      "id": "7947173d-39fa-4d4b-9b1e-60de809a9950",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        860,
        340
      ]
    },
    {
      "id": "6111c771-d8af-4586-8829-213d86dc4f47",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        860,
        100
      ]
    },
    {
      "id": "94a01b4f-549d-4e49-88e0-143c90dd200e",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        920,
        780
      ]
    },
    {
      "id": "d1182e11-025e-4885-abb1-b76a9b617b84",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -480,
        420
      ]
    },
    {
      "id": "97d4cdcd-b016-44aa-882c-eb2ec38968eb",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        -20
      ],
      "parameters": {
        "width": 1033,
        "height": 1029,
        "content": "# Process Text Message"
      }
    },
    {
      "id": "73156ecc-af5f-4e3d-82c6-4668db52b511",
      "name": "Telegram Response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1240,
        160
      ]
    },
    {
      "id": "5f342299-40fe-44cf-9b58-8a9d3bfac1df",
      "name": "Save Long Term Memories",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        1260,
        780
      ]
    },
    {
      "id": "aba001a8-68f9-4870-9cd0-60a4c59ecd5b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        220
      ],
      "parameters": {
        "width": 300,
        "height": 340,
        "content": "## Retrieve Long Term Memories\nGoogle Docs"
      }
    },
    {
      "id": "e5ec71ec-9527-4ccd-87c3-3aa2f09192e8",
      "name": "Retrieve Long Term Memories",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        560,
        360
      ]
    },
    {
      "id": "4764383a-3c4b-4e64-b391-5dc9fb4b9de6",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        820,
        660
      ],
      "parameters": {
        "width": 280,
        "height": 320,
        "content": "## Save To Current Chat Memory (Optional)"
      }
    },
    {
      "id": "e11995b8-e061-4b40-b4b6-9ec03c7e5a06",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1160,
        660
      ],
      "parameters": {
        "width": 280,
        "height": 320,
        "content": "## Save Long Term Memories\nGoogle Docs"
      }
    },
    {
      "id": "1b53aef2-ca99-409b-bd10-3fc1fd87f540",
      "name": "Response Error message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1240,
        360
      ]
    },
    {
      "id": "e5d79084-d7f1-44fd-a1db-73cc76a148ec",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        660
      ],
      "parameters": {
        "width": 820,
        "height": 600,
        "content": "# DeepSeek API Call\n\nThe DeepSeek API uses an API format compatible with OpenAI. By modifying the configuration, you can use the OpenAI SDK or softwares compatible with the OpenAI API to access the De"
      }
    },
    {
      "id": "af14e803-44a5-4b0e-a675-b1e860bf6d29",
      "name": "DeepSeek-R1 Reasoning",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        440,
        880
      ]
    },
    {
      "id": "e8be6a32-ba4c-4895-b34b-c5e7d0ded5e8",
      "name": "DeepSeek-V3   Chat",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        600,
        880
      ]
    }
  ],
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Response Error message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validation": {
      "main": [
        [
          {
            "node": "Check User & Chat ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message Router": {
      "main": [
        [],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          },
          {
            "node": "Retrieve Long Term Memories",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [
          {
            "node": "Error message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeepSeek-V3   Chat": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check User & Chat ID": {
      "main": [
        [
          {
            "node": "Message Router",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        []
      ]
    },
    "Save Long Term Memories": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Listen for Telegram Events": {
      "main": [
        [
          {
            "node": "Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        []
      ]
    },
    "Retrieve Long Term Memories": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}