Python Telegram bot hosting, free.
Write your bot as a few small Python scripts. NxCreate runs them around the clock with storage, keyboards and delayed commands built in, and nothing to install or configure.
Host a Python bot freeSee how NxCreate works
How a Python bot works on NxCreate
A Python bot is a set of command scripts. Each script has a name and a type, and NxCreate runs it when its trigger fires. A script is plain Python statements: no function wrapper, no imports and no polling loop.
| Type | Runs when | Example name |
|---|---|---|
| command | the user sends /word | /start |
| callback | an inline button with that callback_data is pressed | verify |
| text | the message text matches exactly | 💰 Balance |
| regex | the message text matches a pattern | ^\d{10}$ |
| any | nothing else matched | * |
| error | another command crashed | ! |
A complete example
A /start command that sends a button, and the callback command that handles the press:
# command: /startname = message.from_user.first_namem = InlineKeyboardMarkup()m.add(InlineKeyboardButton("✅ Verify", callback_data="verify"))bot.replyText(u, f"Hi {name}! Tap to continue.", reply_markup=m)# callback: verifybot.answerCallbackQuery(call.id, "Verified")User.saveData("verified", True)bot.editMessageText("You're verified.", chat_id=u, message_id=call.message.message_id)What is already there
- bot: the Telegram API, with both camelCase and snake_case method names
- u: the chat id of the user who wrote to your bot
- message, text, params, args and call: the incoming message, its text and any callback
- User and Bot: per-user and bot-wide storage
- libs: counters for balances and points, random helpers and date helpers
- env: your private variables, such as API keys and admin ids
- requests: HTTP calls to public URLs
- InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup and KeyboardButton, with no import
Storage without a database
Keep data with User.saveData and Bot.saveData, and use libs.Resources for anything numeric such as coins or stock.
count = int(User.getData("visits") or 0) + 1User.saveData("visits", count)libs.Resources.userRes("coins").add(5)bot.replyText(u, f"Visit {count}")Multi-step flows and delayed commands
Ask a question and route the next message to another command with Bot.handleNextCommand. Schedule a command for later with Bot.runCommandAfter, which survives restarts. Send a message to every user with Bot.broadcast.
# command: /feedbackbot.replyText(u, "What should we improve?")Bot.handleNextCommand("save_feedback")Â # command: save_feedbackUser.saveData("feedback", text)bot.replyText(u, "Thanks, noted.")Secrets and limits
Keep tokens and keys out of your code. Add them under Environment / Private Variables and read them with env.get("KEY_NAME").
Scripts should finish quickly: 4 seconds on the free plan and 12 seconds on Pro. Avoid long loops and time.sleep, and use a delayed command instead.
What Python bots on NxCreate do not use
Because NxCreate runs your scripts for you, there is no import statement, no polling loop and no webhook code. Modules such as os, sys, subprocess and threading, and file access, are not available.
Get a Python bot online in three steps
- 1
Create the bot with BotFather
Copy the token @BotFather gives you.
- 2
Create a Python bot
Add it in NxCreate with your token, then add one script for each command, button and text you want to handle.
- 3
Deploy
NxCreate registers the webhook and starts your bot. Edit a script and it is live straight away.
Questions and answers
Can I host a Python Telegram bot for free?
Yes. Python is a first-class runtime on NxCreate and the Starter plan is free, with no credit card.
Do I need to install libraries or write imports?
No. bot, User, Bot, libs, env and requests are already there, and common modules such as json, re, math, random and datetime are pre-loaded.
Where does my bot store data?
In NxCreate storage. Use User.saveData for per-user values, Bot.saveData for bot-wide values and libs.Resources for counters such as balances.
Can I use python-telegram-bot or aiogram?
Not directly. Those frameworks run their own polling or webhook loop, while NxCreate calls a separate script for each command. You can port your handlers into command scripts.
How long can a script run?
Up to 4 seconds on the free plan and 12 seconds on Pro. For longer work, split it up or schedule a delayed command.
How do I keep an API key out of my code?
Add it as a private variable and read it with env.get("NAME"). Never put keys or tokens in a script.