NxCreateDocs

Python Bots

Build Telegram bots in Python on the NxCreate runtime.

NxCreate can also run bots written in Python.

Overview

A Python bot is built from separate commands. Each command has a trigger — like /start, a word the user types, or a button they tap — and some code that runs when that trigger happens.

You don't need to set up a bot or connect it to Telegram yourself — that part is already done. Your code just gets handed everything it needs about the message: who sent it, what they typed, and so on.

Command-based structure

This works differently from NxCreate's JavaScript bots. In JavaScript, you write one script that lists out every command by hand (bot.command('start', ...), bot.hears(...), and so on).

In Python, there is no single script. Each command is added on its own, separately, with its own trigger and its own code. You don't need to register it anywhere else — add the command and it just works.

# The "start" command — runs when a user sends /start
def start(message, u, text, command, args, call, params):
    bot.replyText(u, "Welcome!")

# The "help" command — a completely separate command
def help(message, u, text, command, args, call, params):
    bot.replyText(u, "Here's how this bot works...")
Want one command to trigger another? Use Bot.runCommand().

Bot / User / libs globals

Three ready-to-use names cover most of what a bot needs:

NameWhat it’s for
BotThings that apply to the whole bot — saving settings, running another command, sending a delayed message, or messaging all your users at once.
UserSaving information about one user, like their name or score. It automatically applies to whoever sent the current message, unless you say otherwise.
libsSmall helpers — counters, random numbers, the current date and time, and a few others.
def start(message, u, text, command, args, call, params):
    User.saveData('joined', True)
    count = libs.Resources.globalRes('starts').add(1)
    bot.replyText(u, f"Welcome! You're visitor #{count}.")
u is the user's chat id — use it whenever a method asks for a chat id.

Telegram methods

Send and edit messages with bot.sendMessage, bot.sendPhoto, bot.editMessageText, bot.answerCallbackQuery, and more — see Telegram Methods for the full list. Bold, links, and other formatting work automatically, so tags like <b> and <a href> show up correctly without extra setup.

bot.sendMessage(u, "<b>Order confirmed</b>\nWe'll notify you when it ships.")

Dedicated reference pages

Full Python bot reference: pydocs.nxcreate.com
Last updated August 11, 2026
Was this page helpful?