Advanced Features
7. Advanced Features
In this section, we explore advanced functionalities of Telebot Creator, such as command chaining, custom API integrations, and multi-bot management. This section also introduces key methods like Bot.Transfer
for transferring bots and Bot.info()
for retrieving detailed bot information.
7.1 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
Start the Workflow:
Process Name:
Complete Registration:
7.2 Custom API Integrations
With libs.customHTTP
, bots can interact with external APIs, enabling dynamic data fetching or triggering external processes.
Example: Weather Bot:
7.3 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.4 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 ifrun_now
isTrue
.run_now
(optional): IfTrue
, 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.5 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 ifbot_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.6 Multi-Bot Management
For users managing multiple bots, Telebot Creator allows seamless integration between them.
Example: Interaction Between Two Bots
Bot A triggers Bot B via a webhook:
Bot B handles the webhook and sends a response:
7.7 Advanced Error Handling
Implement advanced error-handling techniques to ensure smooth workflows.
Example:
7.8 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.9 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
Bot Status Monitoring:
Periodically fetch and log bot statuses for analytics or troubleshooting.
Ownership Verification:
Verify bot ownership before performing sensitive operations.
Integration with Dashboards:
Fetch bot stats for visual dashboards.
7.10 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.11 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:
Bot A collects data and calls Bot B's webhook:
Bot B processes the webhook:
2. Delegating Tasks
Use a primary bot to assign tasks to secondary bots.
7.12 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.13 Combining Features for Real-World Applications
Use Case: Survey Bot with API Integration
Step 1: Collect User Input
Step 2: Process and Store Data
Step 3: Send Data to an API
Use Case: Reward Bot with Multi-Bot Management
Bot A verifies user actions and updates points.
Bot B notifies the user via a secondary bot:
Last updated