Free telebot hosting, always on.
Run your pyTelegramBotAPI bot without a server. Keep your handler logic, drop the polling loop, and let NxCreate host and run it for you.
Host a telebot bot freeSee how NxCreate works
What changes when you move a telebot bot
NxCreate runs Python bots on the python-telebot framework. Your handler logic stays much the same. What you stop doing is creating the bot, registering decorators and polling, because NxCreate registers the webhook and calls the right script for each update.
Before and after
A telebot bot that answers /start:
import telebot bot = telebot.TeleBot(TOKEN) @bot.message_handler(commands=['start'])def start(message): bot.reply_to(message, 'Hello!') bot.infinity_polling()# command: /startbot.replyText(u, 'Hello!')From decorators to commands
| In telebot | On NxCreate |
|---|---|
| @bot.message_handler(commands=['start']) | A command named /start |
| @bot.callback_query_handler on a callback_data value | A callback command named exactly that value |
| A handler matching a button label | A text command named exactly like the label |
| A regex handler | A regex command |
| bot.reply_to(message, text) | bot.replyText(u, text) |
| bot.register_next_step_handler | Bot.handleNextCommand("command_name") |
| A dict or database for user state | User.saveData and User.getData |
| os.environ or dotenv | env.get("KEY_NAME") |
Keyboards and callbacks
Keyboard classes are already available, so there is no telebot.types import. Each callback_data must match the name of a callback command exactly, without spaces or extra data.
# command: /menum = InlineKeyboardMarkup()m.add(InlineKeyboardButton("Help", callback_data="help"))bot.replyText(u, "Choose:", reply_markup=m) # callback: helpbot.answerCallbackQuery(call.id)bot.replyText(u, "Here is some help.")What to leave behind
- import statements
- telebot.TeleBot(...) and the token constant
- bot.polling() and bot.infinity_polling()
- set_webhook and remove_webhook
- Threads, os, sys and file access
Move a telebot bot in three steps
- 1
Create a Python bot
Add it in NxCreate with the token from @BotFather.
- 2
Turn each handler into a command
One script for each decorator, using the table above. The editor has Check syntax and Format buttons.
- 3
Deploy
NxCreate registers the webhook and starts the bot. Stop your old polling process.
Questions and answers
Can I host a telebot (pyTelegramBotAPI) bot for free?
Yes. Python bots on NxCreate use the python-telebot framework and the Starter plan is free, with no credit card.
Do I have to change my code?
Yes, the structure. Each decorator becomes a command script and the polling loop goes away. The logic inside your handlers stays much the same.
Does infinity_polling work on NxCreate?
You do not need it. Telegram sends updates to a webhook that NxCreate registers, and NxCreate runs the matching script.
Can I keep using import telebot?
No. There are no import statements in command scripts. The bot object, keyboard classes and helpers are already there.
How do I keep state between messages?
Use User.saveData and User.getData for per-user state, or Bot.handleNextCommand to send the next message to a specific command.
Where do I put my token and API keys?
In Environment / Private Variables. Read them with env.get("KEY_NAME") and keep them out of your scripts.