Handlers Commands, text matching, callbacks and fallbacks in Python.
Commands Each command is a separate handler with a trigger. Create them in the dashboard editor; the code is the handler body.
# Trigger: command "/start"
bot.replyText(u, "Welcome!")
# Trigger: command "/help"
bot.replyText(u, "Available: /start, /help")Text matching Use trigger type "text" with an exact value, or "regex" with a pattern. Callbacks use trigger type "callback".
# Trigger: text "hello"
bot.replyText(u, "Hi!")
# Trigger: regex "order #(\d+)"
import re
m = re.search(r"order #(d+)", text)
bot.replyText(u, "Order " + (m.group(1) if m else "?"))Callback actions # Trigger: callback "confirm_pay"
bot.answerCallbackQuery(call.id, "ok")
bot.editMessageText("Payment confirmed", chat_id=u, message_id=message.message_id)Command navigation # Run another command
Bot.runCommand("helper", options="opt1")
# Chain input: ask then handle next message
bot.replyText(u, "age?")
Bot.handleNextCommand("age")
# Schedule a command later
Bot.runCommandAfter(60000, "reminder", options="p1")
Was this page helpful?
✓ Clear ~ Okay ! Missing
Last updated March 22, 2026