{
  "name": "Create a Telegram bot with Mistral Nemotron AI and conversation memory",
  "nodes": [
    {
      "id": "ad61fda0-c5a3-4945-89a0-c015460d1cb5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2120,
        180
      ],
      "parameters": {
        "width": 400,
        "height": 380,
        "content": "# 🤖 AI Telegram Bot Workflow\n\n**Overview:**\nThis workflow creates an intelligent Telegram bot that:\n- Remembers conversation history\n- Responds to commands (/start, /clear)\n- Uses NVIDIA's mistralai/m"
      }
    },
    {
      "id": "4cf4e12f-0545-4f5b-9171-a11618780b19",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1680,
        460
      ]
    },
    {
      "id": "76f5bbcc-92ee-4928-bdb7-07b5d0478ed9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1560,
        -260
      ],
      "parameters": {
        "width": 450,
        "height": 310,
        "content": "## 🔀 Message Routing Logic\n\n**Step 1:** All incoming messages are processed through multiple IF nodes to determine the appropriate response:\n\n1. **Start Command** → Welcome message\n2. **Clear Command*"
      }
    },
    {
      "id": "448f7ad6-797e-4578-979c-09633668038f",
      "name": "Check Start Command",
      "type": "n8n-nodes-base.if",
      "position": [
        -1360,
        60
      ]
    },
    {
      "id": "021a44ce-b973-4bc3-a8b3-0dd3dc6e3333",
      "name": "Check Clear Command",
      "type": "n8n-nodes-base.if",
      "position": [
        -1360,
        240
      ]
    },
    {
      "id": "40d044e9-c11a-4aa0-88da-23b90bd3cbd2",
      "name": "Filter Regular Messages",
      "type": "n8n-nodes-base.if",
      "position": [
        -1360,
        380
      ]
    },
    {
      "id": "25495fbc-7b32-4b6a-8668-583322306fd4",
      "name": "Check Non-Text Messages",
      "type": "n8n-nodes-base.if",
      "position": [
        -1360,
        600
      ]
    },
    {
      "id": "f0c4260e-3c1d-4f0f-b65f-2f25eb9435f2",
      "name": "Send Welcome Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1060,
        -20
      ]
    },
    {
      "id": "8b2174fb-293d-4780-bb50-a432762d3461",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        160
      ],
      "parameters": {
        "width": 350,
        "height": 300,
        "content": "## 🗂️ Chat History Management\n\n**Key Features:**\n- Stores conversation per user ID\n- Limits to last 10 messages (5 exchanges)\n- Prevents token limit issues\n- Maintains context across messages\n\n**Clear"
      }
    },
    {
      "id": "07866025-b899-44dd-9427-7d824882222c",
      "name": "Clear Chat History",
      "type": "n8n-nodes-base.code",
      "position": [
        -1080,
        220
      ]
    },
    {
      "id": "df4f3420-f7bf-4368-84de-d3687ada4be2",
      "name": "Send Clear Confirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -440,
        80
      ]
    },
    {
      "id": "487e247b-a1be-41dd-8d2c-c28ba1839075",
      "name": "Manage Chat History",
      "type": "n8n-nodes-base.code",
      "position": [
        -1100,
        400
      ]
    },
    {
      "id": "317db760-9ea5-4810-9a56-03609a624896",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -460,
        440
      ],
      "parameters": {
        "width": 400,
        "height": 300,
        "content": "## 🧠 AI Processing Pipeline\n\n**Step 2:** Regular messages go through AI processing:\n\n1. **Prepare Request** → Format for NVIDIA API\n2. **API Call** → Send to mistralai/mistral-nemotron model\n3. **Save"
      }
    },
    {
      "id": "d75f4b21-e3fc-4691-8638-069ddc9ae91e",
      "name": "Prepare API Request",
      "type": "n8n-nodes-base.code",
      "position": [
        -820,
        640
      ]
    },
    {
      "id": "8f22b609-451c-4b2f-9e8f-e74e620166f1",
      "name": "NVIDIA LLaMA Chat Model",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -320,
        760
      ]
    },
    {
      "id": "570d45bb-7110-48a5-80f2-796cc9876304",
      "name": "Save AI Response to History",
      "type": "n8n-nodes-base.code",
      "position": [
        40,
        760
      ]
    },
    {
      "id": "f5151aaf-1b31-446e-b8da-c7c1282ddfa9",
      "name": "Send AI Response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        320,
        620
      ]
    },
    {
      "id": "07d96072-56e9-4742-98c2-49d162fea6aa",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1420,
        780
      ],
      "parameters": {
        "width": 350,
        "height": 270,
        "content": "## ⚠️ Error Handling\n\n**Non-text Messages:**\nImages, videos, documents, etc. are not supported and receive a friendly error message directing users to send text only.\n\n**Future Enhancement:**\nCould be"
      }
    },
    {
      "id": "542bd5d0-6752-40d3-9b8a-005abb3ed1af",
      "name": "Send Error Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1100,
        580
      ]
    },
    {
      "id": "47bb0a28-c853-42c7-bd43-d5ce44c3663b",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        120
      ],
      "parameters": {
        "width": 400,
        "height": 460,
        "content": "## 🔧 Setup Instructions\n\n**Required Credentials:**\n1. **Telegram Bot Token:**\n   - Create bot with @BotFather\n   - Get API token\n   - Add to Telegram credentials\n\n2. **NVIDIA API Key:**\n   - Register "
      }
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check Start Command",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check Clear Command",
            "type": "main",
            "index": 0
          },
          {
            "node": "Filter Regular Messages",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check Non-Text Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clear Chat History": {
      "main": [
        [
          {
            "node": "Send Clear Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Clear Command": {
      "main": [
        [
          {
            "node": "Clear Chat History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Start Command": {
      "main": [
        [
          {
            "node": "Send Welcome Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manage Chat History": {
      "main": [
        [
          {
            "node": "Prepare API Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare API Request": {
      "main": [
        [
          {
            "node": "NVIDIA LLaMA Chat Model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Non-Text Messages": {
      "main": [
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Regular Messages": {
      "main": [
        [
          {
            "node": "Manage Chat History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NVIDIA LLaMA Chat Model": {
      "main": [
        [
          {
            "node": "Save AI Response to History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save AI Response to History": {
      "main": [
        [
          {
            "node": "Send AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}