{
  "manifest_version": "1",
  "slug": "telegram-bot",
  "title": "Telegram bot",
  "headline": "Host a Telegram bot",
  "description": "Run an AI Telegram bot on an exe.dev VM: python-telegram-bot under systemd, SQLite memory, photos and PDFs, Claude with no key, no bot token.",
  "category": "ai-agents",
  "tags": [
    "telegram bot",
    "telegram bot hosting",
    "python-telegram-bot",
    "aiogram",
    "grammy",
    "ai telegram bot",
    "chatbot",
    "claude",
    "long polling",
    "webhook"
  ],
  "url": "https://exe.dev/deploy/telegram-bot",
  "markdown_url": "https://exe-staging.dev/deploy/telegram-bot.md",
  "upstream": {
    "website": "https://core.telegram.org/bots",
    "source": "https://exe.dev/deploy/telegram-bot/bot.py",
    "docs": "https://core.telegram.org/bots/api",
    "license": "python-telegram-bot is LGPL-3.0"
  },
  "example_vm_name": "my-telegram-bot",
  "time": "10 minutes",
  "stack": [
    {
      "name": "bot.py",
      "detail": "[one Python file](https://exe.dev/deploy/telegram-bot/bot.py) on python-telegram-bot 22.8, run by uv as `telegram-bot.service`",
      "data": "~/telegram-bot"
    },
    {
      "name": "SQLite",
      "detail": "each chat's recent messages, who may use the bot, open groups",
      "data": "~/telegram-bot/data/bot.db"
    },
    {
      "name": "Telegram integration",
      "detail": "`telegram.int.exe.xyz` adds the bot token to Bot API calls and file downloads"
    },
    {
      "name": "LLM integration",
      "detail": "`llm.int.exe.xyz`, Claude Sonnet 5.5 by default"
    }
  ],
  "access": [
    {
      "url": "Telegram",
      "who": "shared",
      "what": "the bot, for you and the people you invite"
    },
    {
      "url": "https://telegram.int.exe.xyz/",
      "who": "private",
      "what": "the Bot API as your bot, from this VM only"
    },
    {
      "url": "ssh my-telegram-bot.exe.xyz",
      "who": "private",
      "what": "code, prompt, logs"
    }
  ],
  "delivers": [
    "`telegram-bot.service`, restarted on failure and reboot, long-polling Telegram through the integration and logging `connected to Telegram as @\u003cbot\u003e`.",
    "Claude answering in private chats, and when mentioned or replied to in groups, with each chat's last 20 messages remembered in SQLite.",
    "Photos, PDFs, and text files sent to the bot downloaded through the integration's `/file/` path and read by the model.",
    "The bot token held by exe.dev's Telegram integration and models from the LLM integration, with neither secret on the VM.",
    "The bot claimed by its owner through a one-time link, and ignoring everyone they haven't invited."
  ],
  "deployable": true,
  "deploy": {
    "new_vm_url": "https://exe-staging.dev/new?prompt=Set%20up%20Telegram%20bot%20on%20this%20VM%20by%20following%20the%20exe.dev%20recipe%20at%20https%3A%2F%2Fexe-staging.dev%2Fdeploy%2Ftelegram-bot.md%3Fvia%3Ddeploy%20from%20top%20to%20bottom.%0A%0AThe%20recipe%27s%20example%20VM%20name%20is%20my-telegram-bot.%20This%20VM%27s%20name%20is%20the%20output%20of%20%60hostname%60%3A%20use%20it%20wherever%20the%20recipe%20writes%20my-telegram-bot.%20Skip%20the%20step%20that%20creates%20the%20VM%3B%20you%20are%20on%20it.%0A%0AYou%20are%20done%20when%20all%20of%20these%20are%20true.%20Check%20each%20one%20yourself%3A%0A-%20%60telegram-bot.service%60%2C%20restarted%20on%20failure%20and%20reboot%2C%20long-polling%20Telegram%20through%20the%20integration%20and%20logging%20%60connected%20to%20Telegram%20as%20%40%3Cbot%3E%60.%0A-%20Claude%20answering%20in%20private%20chats%2C%20and%20when%20mentioned%20or%20replied%20to%20in%20groups%2C%20with%20each%20chat%27s%20last%2020%20messages%20remembered%20in%20SQLite.%0A-%20Photos%2C%20PDFs%2C%20and%20text%20files%20sent%20to%20the%20bot%20downloaded%20through%20the%20integration%27s%20%60%2Ffile%2F%60%20path%20and%20read%20by%20the%20model.%0A-%20The%20bot%20token%20held%20by%20exe.dev%27s%20Telegram%20integration%20and%20models%20from%20the%20LLM%20integration%2C%20with%20neither%20secret%20on%20the%20VM.%0A-%20The%20bot%20claimed%20by%20its%20owner%20through%20a%20one-time%20link%2C%20and%20ignoring%20everyone%20they%20haven%27t%20invited.%0A%0ARead%20the%20whole%20recipe%2C%20closed%20details%20included%2C%20and%20follow%20%22Set%20up%20by%0Ahand%22%20in%20order%2C%20skipping%20VM%20creation%3B%20the%20walkthrough%20above%20it%20is%20for%0Athe%20owner.%20The%20bot%20token%20must%20never%20be%20on%20this%20VM%3A%20don%27t%20ask%20for%20it.%0AFirst%20give%20the%20owner%20the%20steps%20in%20%22Make%20a%20bot%22%20and%20%22Give%20exe.dev%20the%0Atoken%22%2C%20with%20the%20connect%20link%20for%20this%20VM%27s%20name%2C%20and%20install%20the%20bot%0Awhile%20they%20do%20that%3B%20the%20service%20retries%20until%20the%20integration%20is%0Aattached.%20If%20%60curl%20-s%20https%3A%2F%2Freflection.int.exe.xyz%2Fintegrations%60%20shows%0Atheir%20Telegram%20integration%20under%20a%20name%20other%20than%20%60telegram%60%2C%20set%0ATELEGRAM_API%20in%20~%2Ftelegram-bot%2Fbot.env%20to%20match.%20When%20the%20log%20shows%20the%0Aowner%20link%2C%20give%20it%20to%20the%20owner.%20Stay%20with%20long%20polling%20unless%20they%20ask%0Afor%20webhooks.%20End%20with%20the%20owner%20link%2C%20what%20to%20try%2C%20and%20how%20to%20change%0Athe%20prompt.%0A%0AFinish%20with%20the%20URLs%20I%20should%20open.%0A",
    "terminal": "curl -fsSL https://exe-staging.dev/deploy/telegram-bot/prompt.txt | ssh exe.dev new --prompt=/dev/stdin",
    "prompt": "Set up Telegram bot on this VM by following the exe.dev recipe at https://exe-staging.dev/deploy/telegram-bot.md?via=deploy from top to bottom.\n\nThe recipe's example VM name is my-telegram-bot. This VM's name is the output of `hostname`: use it wherever the recipe writes my-telegram-bot. Skip the step that creates the VM; you are on it.\n\nYou are done when all of these are true. Check each one yourself:\n- `telegram-bot.service`, restarted on failure and reboot, long-polling Telegram through the integration and logging `connected to Telegram as @\u003cbot\u003e`.\n- Claude answering in private chats, and when mentioned or replied to in groups, with each chat's last 20 messages remembered in SQLite.\n- Photos, PDFs, and text files sent to the bot downloaded through the integration's `/file/` path and read by the model.\n- The bot token held by exe.dev's Telegram integration and models from the LLM integration, with neither secret on the VM.\n- The bot claimed by its owner through a one-time link, and ignoring everyone they haven't invited.\n\nRead the whole recipe, closed details included, and follow \"Set up by\nhand\" in order, skipping VM creation; the walkthrough above it is for\nthe owner. The bot token must never be on this VM: don't ask for it.\nFirst give the owner the steps in \"Make a bot\" and \"Give exe.dev the\ntoken\", with the connect link for this VM's name, and install the bot\nwhile they do that; the service retries until the integration is\nattached. If `curl -s https://reflection.int.exe.xyz/integrations` shows\ntheir Telegram integration under a name other than `telegram`, set\nTELEGRAM_API in ~/telegram-bot/bot.env to match. When the log shows the\nowner link, give it to the owner. Stay with long polling unless they ask\nfor webhooks. End with the owner link, what to try, and how to change\nthe prompt.\n\nFinish with the URLs I should open.\n",
    "prompt_url": "https://exe-staging.dev/deploy/telegram-bot/prompt.txt"
  },
  "updated": "2026-11-17",
  "verified": "2026-11-17",
  "related": [
    "hermes-agent",
    "sqlite",
    "agent-secrets",
    "fastapi",
    "claude-code",
    "openclaw"
  ],
  "alternatives": [
    "Railway",
    "PythonAnywhere",
    "Heroku"
  ],
  "files": [
    "https://exe-staging.dev/deploy/telegram-bot/bot.py"
  ]
}
