For the complete documentation index, see llms.txt. This page is also available as Markdown.

Advanced Features

Telebot Creator Documentation — Platform v7.1.2 · Telegram Bot API 10.1

7. Advanced Features

Telebot Creator offers powerful advanced features that extend basic bot functionality. This section explores these capabilities, including custom data storage, scheduled tasks, integration with external systems, and managing user interactions, among others.


7.1 Scheduled Commands

Telebot Creator allows you to schedule commands to run at specific intervals, creating chatbots that can perform time-based tasks.

Bot.runCommandAfter

The Bot.runCommandAfter function lets you schedule a command to run after a specific time delay.


Function Syntax:

Bot.runCommandAfter(timeout, command, options=None)

Parameters:

  • timeout: The delay before the command runs. Either a number of seconds or a datetime object. Allowed range: 1 second minimum to 366 days maximum.

  • command (str): The command to execute when the timer fires.

  • options (Optional): A value passed through to the scheduled command, available there as the options global.

The call returns a dict like {"id": "<job_id>", "command": "<command>", "timeout": <seconds>}. Save the id if you may want to cancel the task.

Limits:

  • 60 schedules per minute per user (rate limited).

  • 50,000 outstanding scheduled tasks per user.

  • The bot must be in the working state when you schedule.

Examples:

  1. Basic Scheduling:

  2. Passing data through:

  3. Long-term Scheduling:

  4. Scheduling at a specific time (pass a datetime):

Bot.cancelScheduledTask

Cancel a task you previously scheduled, using the id returned by runCommandAfter.


7.2 Command Chaining for Workflows

Command chaining allows bots to create step-by-step workflows, guiding users through complex processes such as registration, surveys, or multi-step forms.

Example: Multi-Step Registration

  1. Start the Workflow:

  2. Process Name:

  3. Complete Registration:


7.3 Custom API Integrations

With libs.customHTTP, bots can interact with external APIs, enabling dynamic data fetching or triggering external processes.

Example: Weather Bot:


7.4 Webhook Management

The libs.Webhook library facilitates real-time event handling, such as receiving external updates or triggering bot commands.

Example: Webhook for Payment Confirmation:


7.5 Bot.Transfer Function

The Bot.Transfer function allows you to transfer a bot from one Telebot Creator account to another. It ensures that the transferred bot retains its commands, configurations, and status while validating points and ownership.

Function Syntax

Parameters

  • email: The email address of the new owner.

  • bot_id: The unique ID of the bot to be transferred.

  • bot_token (optional): The Telegram Bot API token. Required if run_now is True.

  • run_now (optional): If True, starts the bot immediately under the new owner.

Validation and Requirements

  • The transferring user must own the bot (bot_id) being transferred.

  • The new owner's email must exist on Telebot Creator.

  • The original account must have at least 200 points to initiate the transfer.

Usage Example


7.6 Bot.info() Function

The Bot.info() function retrieves detailed information about a specific bot, including its status, owner details, points, and usage statistics.

Function Syntax

Parameters

  • bot_id (optional): The ID of the bot to retrieve information for. If not provided, retrieves info for the current bot.

  • api_key (optional): The API key of the bot owner. Used for validation if bot_id is provided.

Information Returned

  • token: The bot's API token.

  • bot_id: The unique ID of the bot.

  • owner_email: The email of the current bot owner.

  • status: The bot's current status (e.g., "Working", "Stopped").

  • username: The bot's Telegram username.

  • first_name: The bot's first name.

  • account_points: Remaining points in the owner's account.

  • userstat: Number of users interacting with the bot.

Usage Example

Validation

  • Returns structured and human-readable details about the bot.


7.7 Multi-Bot Management

For users managing multiple bots, Telebot Creator allows seamless integration between them.

Example: Interaction Between Two Bots

  1. Bot A triggers Bot B via a webhook:

  2. Bot B handles the webhook and sends a response:


7.8 Advanced Error Handling

Implement advanced error-handling techniques to ensure smooth workflows.

Example:

7.9 Bot.Transfer (Expanded Use Cases)

1. Bot Migration Between Users

The Bot.Transfer function allows seamless migration of bots from one account to another, ensuring no loss of functionality or data.

Real-World Scenario:

  • Use Case: A developer transfers a bot to a business partner who will manage the bot moving forward.

  • Example:

2. Batch Transfer

Use the Bot.Transfer function for multiple bots by iterating through bot IDs.


7.10 Bot.info() (Expanded Details)

The Bot.info() function is a powerful tool for retrieving comprehensive bot details. It provides insight into bot usage, configurations, and ownership.

Advanced Usage Scenarios

  1. Bot Status Monitoring:

    • Periodically fetch and log bot statuses for analytics or troubleshooting.

  2. Ownership Verification:

    • Verify bot ownership before performing sensitive operations.

  3. Integration with Dashboards:

    • Fetch bot stats for visual dashboards.


7.11 Advanced API Integrations

1. Fetch and Process Data

Integrate third-party APIs dynamically using libs.customHTTP.

Example: Fetching cryptocurrency prices.

2. Post Data to External Systems

Use POST requests to send data to external APIs.

3. Automate Tasks Using Webhooks

Automatically trigger bot actions based on webhook updates.


7.12 Multi-Bot Management (Expanded)

1. Orchestrating Bots

Enable communication between bots for advanced workflows.

  • Scenario: Bot A collects user data and triggers Bot B to send notifications.

Example:

  1. Bot A collects data and calls Bot B's webhook:

  2. Bot B processes the webhook:

2. Delegating Tasks

Use a primary bot to assign tasks to secondary bots.


7.13 Enhanced Error Handling

Logging Errors for Debugging

Save errors to a persistent log for later review.

Custom Error Handlers

Define custom actions for specific errors.


7.14 Combining Features for Real-World Applications

Use Case: Survey Bot with API Integration

  1. Step 1: Collect User Input

  2. Step 2: Process and Store Data

  3. Step 3: Send Data to an API

Use Case: Reward Bot with Multi-Bot Management

  1. Bot A verifies user actions and updates points.

  2. Bot B notifies the user via a secondary bot:


7.15 The Account Class

The Account object (available in every command as Account) operates on your whole account rather than a single chat. Use it to manage bots, commands, blocked users, account-wide data, and stats. Methods generally return a dict shaped like {"ok": True/False, "result": ...}.

Bot lifecycle

delete_bot is rate-limited to guard against malicious templates that loop over your bots; a normal user calling it a few times is fine.

Export / import

See 7.16 for the export/import round-trip workflow.

Command management

User management

Account-wide data (shared across all your bots)

Statistics


7.16 Bot Export / Import and the AI Round-Trip

Telebot Creator can export a bot's commands and (optionally) its global data to a portable file in JSON, YAML, or TXT format, and import it back. This is the basis of the "edit with AI" workflow.

Export formats

  • json / yaml — structured: a bot block, a commands list (command + code), optional global_data, and an export_info block.

  • txt — human-friendly. Each command is written as:

    The --- lines fence each command's code; the importer reads commands back out of exactly this structure.

The AI round-trip

  1. Open the bot's Manage tab and Export its commands (the backend route is POST /v2/bots/{botid}/export-bot).

  2. Hand the exported file to an AI assistant and ask it to add, fix, or refactor commands — keeping the Command: … / --- / code / --- structure (for TXT) or the commands list shape (for JSON/YAML).

  3. Bring the edited file back through Import Commands in the Manage tab (backend route POST /v2/bots/{botid}/import-commands). Tick "remove old commands" if you want a clean replace; otherwise existing commands with the same name are updated and new ones are added.

import_bot builds a brand-new bot from an export, while import_commands only merges commands into a bot that already exists.


7.17 Folders

Telebot Creator supports two kinds of folders to keep large accounts organized:

  • Bot folders — group bots on your dashboard. Managed via the dashboard (backend routes under /v2/bot-folders and /v2/bots/{botid}/move-to-folder).

  • Command folders — group commands inside a single bot's Commands view (backend routes under /v2/bots/{botid}/commands/folders).

Folders are an organizational layer only; they do not change how commands run.


7.18 Recycle Bin and Bot Recovery

Deleting a bot is a soft delete: the bot is stopped and moved to a recycle bin instead of being erased. You have a 90-day window to restore it (commands and data come back with it).

  • From the dashboard: Recycle Bin lists deleted bots with the days remaining; restore or permanently delete from there.

  • From TPY: Account.get_deleted_bots(), Account.recover_bot(botid), and Account.permanent_delete_bot(botid).

After 90 days a deleted bot becomes eligible for permanent cleanup and can no longer be recovered.


7.19 The .env Command (Injected Globals)

Create a command named .env to define configuration that is injected as global variables into every command's execution. Each line is KEY = value; values are parsed as Python literals when possible (strings, numbers, lists, dicts, tuples), otherwise kept as text. Multi-line list/dict values are supported, and # lines are comments.

Then use them directly in any command:

Keys cannot start with __ (e.g. __builtins__ is rejected), and values cannot contain forbidden/unsafe expressions.


7.20 Built-in Globals Reference

Beyond bot, Bot, User, Account, message, msg, params, u, options, command, left_points, and libs, every command runs with these helpers already available — no import needed:

Global
What it is

HTTP

A ready-to-use HTTP client for outbound requests.

CSV

CSV helper for building/reading CSV data.

bunchify

Wraps a dict so you can use attribute access (d.key).

regex / re

Regular-expression module.

web3_

A configured Web3 instance for EVM chains.

TBC_Web3_

The web3lib library (same as libs.web3lib).

ReturnCommand (also returnCommand / returncommand)

Stop the current command and hand control to another command.

MembershipCheck

Check whether a user is a member of given channels/groups: MembershipCheck(channels, u).

isNumeric

Return whether a value is numeric.

jsondumps

Serialize a value to a JSON string.

encodeURIComponent / decodeURIComponent / rawurlencode

URL encoding/decoding helpers.

parse_qs

Parse a query string into a dict.

md5, hashlib, base64, binascii, time

Common hashing/encoding/time utilities.

For security, names like eval, exec, open, os, subprocess, sys, globals, and locals are disabled inside command code.


7.21 Resources

libs.Resources provides counters/balances you can attach to users or to your whole account:

  • userRes(name, user) — a per-user resource (points, credits, quota, …).

  • accountRes, globalRes, anotherRes, adminRes — account-wide / cross-scope resources.

Every resource object supports add, cut, set, reset, value, getAllData, and fetchAllResources:

The Libraries doc covers libs.Resources in depth.


Last updated