NxCreateDocs

Python: Bot Object

The Bot global — bot-wide data, running commands, scheduling, and broadcasting.

Use Bot for anything that applies to the whole bot rather than a single user.

Bot-wide data

Store and read values that apply to the whole bot — settings, counters, feature flags.

Bot.saveData('maintenance_mode', False)
is_maintenance = Bot.getData('maintenance_mode')
Bot.deleteData('old_flag')

Running commands

Trigger another command from inside your current one, or hand off to the "waiting for next message" flow used for multi-step input.

Bot.runCommand('/menu')
Bot.handleNextCommand('collect_email')

Scheduling

Run a command later. runCommandAfter survives a restart, so use it for reminders, timeouts, and delayed follow-ups.

job_id = Bot.runCommandAfter(60000, '/follow_up')
Bot.cancelCommandAfter(job_id)

Broadcasting

Send a message to every user of the bot.

Bot.broadcast({
    'type': 'text',
    'text': 'We just shipped a new feature!'
})

Pass callback_url to get a webhook notification once the broadcast finishes, with delivery totals.

Bot.broadcast({'type': 'text', 'text': 'Reminder!'}, callback_url='https://example.com/broadcast-done')

Bot info

Bot.info() returns your bot's Telegram profile — id, username, and token.

me = Bot.info()
print(me.username, me.token)

Method reference

MethodSignatureNotes
Bot.getDatagetData(key)Read a bot-wide value.
Bot.saveDatasaveData(key, value)Write a bot-wide value.
Bot.deleteDatadeleteData(key)Remove a bot-wide value.
Bot.runCommandrunCommand(name)Run another command immediately.
Bot.handleNextCommandhandleNextCommand(name)Route the user’s next message to a given command.
Bot.runCommandAfterrunCommandAfter(timeout_ms, command, options=None)Schedule a command to run later. Survives a restart.
Bot.cancelCommandAftercancelCommandAfter(job_id)Cancel a scheduled command.
Bot.broadcastbroadcast(payload, callback_url=None)Send a message to every user of the bot.
Bot.infoinfo()Returns the bot’s Telegram profile, including `.token`.
Last updated August 11, 2026
Was this page helpful?