Build a Telegram bot with Claude Code, running 24/7
Build a Telegram bot with Claude Code and keep it answering 24/7 with your laptop closed. Paste one paragraph; your agent writes, deploys and checks it.
Let your agent build this
Copy one prompt and paste it into Claude Code, Codex or Cursor. Your agent builds what this page describes and puts it online on aidrop.it.
See the prompt
Build me a Telegram bot and run it on aidrop.it, 24/7. Use my existing aidrop.it Project, or create one called "Telegram bot" if I have none. What it does: when someone sends /start in a private chat, it replies "Hello from my bot." It ignores everything else. How it works: - Use the official Telegram Bot API with a webhook, not polling. - Protect the webhook with a random secret token and reject any request that does not carry it. - The bot registers its own webhook when it starts, using its public aidrop.it address. After the first build, store that address as a Project secret and build again. - Read aidrop.it's runtime rules before writing code and follow them. Outgoing requests must go through the proxy the platform sets; make sure your HTTP client uses it (Node's built-in fetch does not by default). Secrets: before building, ask me for the bot token, and make up the webhook secret token yourself. Store each one with project_secret_set under a clear name, and list those names in required_secret_names when you build. Never print a value back to me, and never write one into code, the repository, a commit or a log. Build it, check it runs, fix anything that fails, and tell me when I can send /start. Report the bot's address and what you checked. This task comes from the aidrop.it guide "Build a Telegram bot with Claude Code, running 24/7": https://docs.aidrop.it/playbooks/telegram-bot-with-claude-code. Read that page if you need more detail; it says what to ask me for, what it costs and what will not work. Use the aidrop.it MCP tools (server: https://aidrop.it/mcp). If you do not have them, stop and tell me to connect them first, as described at https://docs.aidrop.it/quickstart#1-connect-your-agent.
On this page
- What you will have at the end
- Words you will meet
- What you need
- Say this to your agent
- What your agent does to put the Telegram bot online
- Check that your Telegram bot answers
- When the bot does not answer
- FAQ
- Should my Telegram bot use polling or a webhook?
- What do I do if my bot token leaks?
- Can Claude Code build an AI Telegram bot that answers with Claude?
- Can my bot send a message on its own, every morning?
- Can I host a Telegram bot for free?
- Related
You can have a Telegram bot that answers around the clock, built and put online by Claude Code, Codex or Cursor from one paragraph you paste. You create the bot inside Telegram, give its key to your agent once, and your agent does the rest: it writes the bot, puts it online and connects it to Telegram. Plan on about 20 minutes, mostly waiting for the first build. Keeping it online costs $5 a month on the Starter plan, after a free 7-day trial.
The bot lives on aidrop.it, not on your computer. Telegram passes every new message straight to the bot’s own web address, so nothing has to stay open on your side. If you are a developer and want the technical side of that, read our Telegram webhook guide on the blog.
Not sure you need your own bot at all? A ready-made assistant may be enough; Grok vs your own bot compares the cost and control of each. And if what you want is a personal AI assistant you chat with, not a bot you write, you can run OpenClaw instead of writing a bot or run Hermes Agent.
What you will have at the end
- A Telegram bot, found by its name, that replies to /start within a second or two.
- A bot that keeps answering when your laptop is closed and after every update.
- The bot’s code saved in a repository, so your agent can change it later.
Words you will meet
- BotFather — Telegram’s own official bot that creates new bots for you.
- Bot token — the key Telegram gives your bot. Anyone who has it can act as your bot, so treat it like a password.
- Webhook — the web address Telegram calls each time someone writes to your bot.
- Secret — where the bot token lives: a private value in your aidrop.it project that the bot reads when it starts. It never appears in the bot’s code.
What you need
- An aidrop.it account — start free: a 7-day trial, no card. To keep the bot running after that, Starter at $5/month is enough, because this bot needs no database.
- Your agent connected to aidrop.it. The Quickstart shows how.
- A Telegram account.
- A bot token. In Telegram, open @BotFather, send it /newbot, choose a name and a username ending in “bot”, and copy the token it gives you (Telegram’s guide).
Keep the token to yourself until your agent asks for it. Then paste it into the chat with your agent once. The agent saves it as a secret in your aidrop.it project, where only your bot can read it, and never shows it again or writes it into the code. Under Secrets in your Project on the aidrop.it dashboard you can check which secrets exist, by name only.
Say this to your agent
Build me a Telegram bot and run it on aidrop.it, 24/7. Use my existing aidrop.it Project, or create one called "Telegram bot" if I have none.
What it does: when someone sends /start in a private chat, it replies "Hello from my bot." It ignores everything else.
How it works:- Use the official Telegram Bot API with a webhook, not polling.- Protect the webhook with a random secret token and reject any request that does not carry it.- The bot registers its own webhook when it starts, using its public aidrop.it address. After the first build, store that address as a Project secret and build again.- Read aidrop.it's runtime rules before writing code and follow them. Outgoing requests must go through the proxy the platform sets; make sure your HTTP client uses it (Node's built-in fetch does not by default).
Secrets: before building, ask me for the bot token, and make up the webhook secret token yourself. Store each one with project_secret_set under a clear name, and list those names in required_secret_names when you build. Never print a value back to me, and never write one into code, the repository, a commit or a log.
Build it, check it runs, fix anything that fails, and tell me when I can send /start. Report the bot's address and what you checked.What your agent does to put the Telegram bot online
- Picks your aidrop.it project, or creates one.
- Asks you for the bot token and saves it as a secret, together with a webhook password it makes up itself.
- Writes the bot, including a small “I’m alive” page that aidrop.it checks to know the bot is running.
- Saves the code to a repository on aidrop.it and builds it there.
- Follows the first build to the end. A bot that does not start usually has a missing secret or a wrong token, and the agent sorts that out with you before trying again.
- Gives the bot its public web address, and the bot tells Telegram to deliver messages there.
Check that your Telegram bot answers
- Your agent says the bot is running and gives you its address.
- Open the bot in Telegram and send /start. It answers “Hello from my bot.”
- Close your laptop and message the bot from your phone. It still answers.
When the bot does not answer
| What you see | What to tell your agent |
|---|---|
| The agent says the build is waiting for secrets | “Which secret names is the build waiting for?” Then give it the bot token again and say “Store it under that name and build again.” |
| The build finished, but aidrop.it says the app is not running | “Read the logs, find why the bot does not start or its “I’m alive” page fails, fix it and build again.” |
| The bot never answers /start | “The bot gets no messages or cannot reply. Check the webhook is set up and that the bot’s outgoing requests can leave aidrop.it.” |
| The bot crashes, saying it cannot write a file | “The app’s disk is read-only. Write nothing to disk; keep anything lasting in a database.” |
| The bot sometimes answers twice | “Telegram retried a slow reply. Answer Telegram at once and skip messages you already handled.” |
FAQ
Should my Telegram bot use polling or a webhook?
Both are official. With polling, the bot keeps asking Telegram for new messages. With a webhook, Telegram calls the bot whenever a message arrives, which suits a bot living at a public web address. One bot cannot do both at once: while a webhook is set, polling stops working (Telegram Bot API).
What do I do if my bot token leaks?
Open @BotFather and send it /token to get a new token for your bot (Telegram docs). Give the new token to your agent, ask it to store it in place of the old one, then ask it to build the bot again so it uses the new key.
Can Claude Code build an AI Telegram bot that answers with Claude?
Yes. Ask your agent to send each message to the Claude API and reply with the answer. You will need an Anthropic API key, which your agent asks you for and saves as one more secret. Ask it to answer Telegram at once and send the reply when the model is done.
Can my bot send a message on its own, every morning?
Yes. A task that runs on a timetable is called a cron job; our page on what a cron job is explains how to write the timetable. Ask your agent to add one to the bot, for example “send me the weather at 8 every morning”.
Can I host a Telegram bot for free?
The Telegram Bot API costs nothing, and a webhook bot uses almost no computer time while it waits. What you pay for is a server that is always reachable, so Telegram can deliver each message the moment it is sent. On aidrop.it the first 7 days are free; after that, Starter at $5 a month runs this bot. All plans are on the pricing page.