{
  "name": "Telegram AI Chatbot",
  "nodes": [
    {
      "parameters": {
        "content": "## Telegram AI Chatbot Powered by GPT\n\nYour own private AI assistant inside Telegram - or a customer-facing FAQ bot - without paying for a chatbot platform.\n\n**Setup time:** 15 minutes  ·  **Level:** Intermediate\n\n**You'll need accounts/credentials for:** Telegram, OpenAI\n\n**Setup steps:**\n1. Create a bot with @BotFather in Telegram (send /newbot, copy the token).\n2. Add your OpenAI API credential to the AI node - or swap in the Anthropic or Google node.\n3. Edit the system prompt in the AI node to define your bot's personality and rules.\n4. Activate the workflow and message your bot on Telegram.\n\nFree templates and updates: navkhan103.github.io",
        "height": 530,
        "width": 400,
        "color": 4
      },
      "id": "sticky-setup",
      "name": "Setup — read me first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -440,
        -40
      ]
    },
    {
      "parameters": {
        "content": "### How it runs\n\nStarts from **Telegram Message In**.\n\n1. A Telegram Trigger fires whenever someone messages your bot.\n2. An AI node sends the message to GPT with a system prompt you control (support agent, tutor, sarcastic friend - your call).\n3. A Telegram node sends the AI's answer back to the same chat.\n4. Replies land in a couple of seconds and each exchange costs a fraction of a cent.",
        "height": 348,
        "width": 400,
        "color": 7
      },
      "id": "sticky-how",
      "name": "How it runs",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -440,
        530
      ]
    },
    {
      "parameters": {
        "content": "### If something breaks\n\nThe read and AI nodes here **retry 3× automatically** (5s apart), which absorbs rate limits and brief timeouts.\n\nNodes that **send or write deliberately do not retry** — a send that reached the far end but lost its response would otherwise fire twice, so you'd get duplicate messages or duplicate rows.\n\nTo be told when one of those fails, build a workflow starting with an **Error Trigger** node that posts to Slack or email, then set it under **three-dot menu > Settings > Error Workflow**. Do it once and point every workflow at it.",
        "height": 400,
        "width": 400,
        "color": 3
      },
      "id": "sticky-fail",
      "name": "If something breaks",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -440,
        918
      ]
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "e5f6a7b8-0001-4000-8000-000000000001",
      "name": "Telegram Message In",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.6-luna"
        },
        "messages": {
          "values": [
            {
              "content": "You are a helpful, concise assistant chatting on Telegram. Answer in plain text, no markdown headers. Keep answers under 200 words unless asked for detail.",
              "role": "system"
            },
            {
              "content": "={{ $json.message.text }}",
              "role": "user"
            }
          ]
        }
      },
      "id": "e5f6a7b8-0002-4000-8000-000000000002",
      "name": "AI Reply",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        220,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Message In').item.json.message.chat.id }}",
        "text": "={{ $json.message.content }}",
        "additionalFields": {}
      },
      "id": "e5f6a7b8-0003-4000-8000-000000000003",
      "name": "Send Reply",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        440,
        0
      ]
    }
  ],
  "connections": {
    "Telegram Message In": {
      "main": [
        [
          {
            "node": "AI Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Reply": {
      "main": [
        [
          {
            "node": "Send Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}