> ## Documentation Index
> Fetch the complete documentation index at: https://help.bots.lt/llms.txt
> Use this file to discover all available pages before exploring further.

# Advanced Methods

> Inline queries, WebApps, Payments, Managed Bots, and internal BLP engine methods.

***

## Inline Mode

Inline mode lets users interact with your bot from **any chat** by typing `@your_bot_name` followed by a query. Your bot receives an `inline_query` update and must respond with results.

### answerInlineQuery

Sends answer results back to an inline query. Must be called within 10 seconds of receiving the query.

| Parameter         | Type        | Required | Description                                                     |
| ----------------- | ----------- | -------- | --------------------------------------------------------------- |
| `inline_query_id` | String      | Yes      | Unique ID of the inline query. Use `raw_message.get("id")`.     |
| `results`         | JSON String | Yes      | JSON-encoded array of `InlineQueryResult` objects (max 50).     |
| `cache_time`      | Integer     | No       | Max seconds the result is cached on the client. Default: `300`. |
| `is_personal`     | Boolean     | No       | If `True`, results are only cached for the requesting user.     |
| `next_offset`     | String      | No       | Offset for pagination of results.                               |
| `button`          | Object      | No       | A button shown above the results (e.g., Switch to PM).          |

**Result types:** `article`, `photo`, `gif`, `mpeg4_gif`, `video`, `audio`, `voice`, `document`, `location`, `venue`, `contact`, `game`, and cached variants.

```python BLP Example theme={null}
results = [
    {
        "type": "article",
        "id": "1",
        "title": "Welcome to Bots.LT",
        "description": "Click to send a message",
        "input_message_content": {
            "message_text": "Hello from Bots.LT! 🚀"
        }
    },
    {
        "type": "article",
        "id": "2",
        "title": "Another Result",
        "input_message_content": {
            "message_text": "This is result #2"
        }
    }
]

Bot.answerInlineQuery(
    inline_query_id=raw_message.get("id"),
    results=jsondumps(results),
    cache_time=300,
    is_personal=True
)
```

***

### savePreparedInlineMessage

Saves a message to be sent to a user via an inline query.

| Parameter             | Type    | Required | Description                                                         |
| --------------------- | ------- | -------- | ------------------------------------------------------------------- |
| `user_id`             | Integer | Yes      | Unique identifier of the target user.                               |
| `result`              | Object  | Yes      | A JSON-serialized object describing the message to be sent.         |
| `allow_user_chats`    | Boolean | No       | Pass True if the message can be sent to private chats.              |
| `allow_bot_chats`     | Boolean | No       | Pass True if the message can be sent to private chats with bots.    |
| `allow_group_chats`   | Boolean | No       | Pass True if the message can be sent to group and supergroup chats. |
| `allow_channel_chats` | Boolean | No       | Pass True if the message can be sent to channel chats.              |

***

## Bot Configuration

### setMyCommands

Registers the bot's command list, visible in the Telegram `/` menu.

| Parameter       | Type        | Required | Description                                                                 |
| --------------- | ----------- | -------- | --------------------------------------------------------------------------- |
| `commands`      | JSON String | Yes      | JSON-encoded array of `{command, description}` objects. Up to 100 commands. |
| `scope`         | Object      | No       | Scope of commands (e.g., all users, specific chat, or chat admin).          |
| `language_code` | String      | No       | Two-letter IETF language code (e.g., `"en"`, `"bn"`).                       |

```python BLP Example theme={null}
commands = [
    {"command": "start", "description": "Start the bot"},
    {"command": "help", "description": "Get help"},
    {"command": "profile", "description": "View your profile"},
    {"command": "settings", "description": "Configure your settings"}
]

Bot.setMyCommands(commands=jsondumps(commands))
```

***

### deleteMyCommands

Deletes the bot's command list. After this, Telegram shows no menu commands.

| Parameter       | Type   | Required | Description                    |
| --------------- | ------ | -------- | ------------------------------ |
| `scope`         | Object | No       | Scope to delete commands from. |
| `language_code` | String | No       | Language code.                 |

```python BLP Example theme={null}
# Remove all commands globally
Bot.deleteMyCommands()
```

***

### getMyCommands

Gets the current list of registered commands.

| Parameter       | Type   | Required | Description                |
| --------------- | ------ | -------- | -------------------------- |
| `scope`         | Object | No       | Scope to get commands for. |
| `language_code` | String | No       | Language code.             |

```python BLP Example theme={null}
result = Bot.getMyCommands()
commands = result.result
for cmd in commands:
    Bot.sendMessage(chat_id=u, text=f"/{cmd.command} — {cmd.description}")
```

***

### setMyName

Sets the bot's display name.

| Parameter       | Type   | Required | Description                                      |
| --------------- | ------ | -------- | ------------------------------------------------ |
| `name`          | String | No       | New name (1–64 characters). Pass empty to reset. |
| `language_code` | String | No       | Language-specific name.                          |

```python BLP Example theme={null}
Bot.setMyName(name="My Awesome Bot")
```

***

### getMyName

Gets the bot's current display name.

| Parameter       | Type   | Required | Description                                            |
| --------------- | ------ | -------- | ------------------------------------------------------ |
| `language_code` | String | No       | Two-letter ISO 639-1 language code or an empty string. |

***

### setMyDescription

Sets the bot's "What can this bot do?" description shown on the start page.

| Parameter       | Type   | Required | Description                             |
| --------------- | ------ | -------- | --------------------------------------- |
| `description`   | String | No       | New description (up to 512 characters). |
| `language_code` | String | No       | Language-specific description.          |

```python BLP Example theme={null}
Bot.setMyDescription(description="I help you manage your tasks and reminders effortlessly!")
```

***

### getMyDescription

Gets the current bot description.

| Parameter       | Type   | Required | Description                                            |
| --------------- | ------ | -------- | ------------------------------------------------------ |
| `language_code` | String | No       | Two-letter ISO 639-1 language code or an empty string. |

***

### setMyShortDescription

Sets the short description shown in the bot's profile.

| Parameter           | Type   | Required | Description                                   |
| ------------------- | ------ | -------- | --------------------------------------------- |
| `short_description` | String | No       | New short description (up to 120 characters). |
| `language_code`     | String | No       | Language-specific short description.          |

```python BLP Example theme={null}
Bot.setMyShortDescription(short_description="Your personal task manager bot.")
```

***

### getMyShortDescription

Gets the current short description of the bot.

| Parameter       | Type   | Required | Description                                            |
| --------------- | ------ | -------- | ------------------------------------------------------ |
| `language_code` | String | No       | Two-letter ISO 639-1 language code or an empty string. |

***

### setMyProfilePhoto

Sets the profile photo of the bot.

| Parameter | Type   | Required | Description                                       |
| --------- | ------ | -------- | ------------------------------------------------- |
| `photo`   | String | Yes      | New profile photo (must be uploaded via file ID). |

***

### removeMyProfilePhoto

Removes the profile photo of the bot.

| Parameter  | Type   | Required | Description                                                                                  |
| ---------- | ------ | -------- | -------------------------------------------------------------------------------------------- |
| `photo_id` | String | No       | Optional. Specific profile photo to remove. If not specified, removes the most recent photo. |

***

### setChatMenuButton

Sets the menu button shown in private chats with the bot.

| Parameter     | Type        | Required | Description                                                    |
| ------------- | ----------- | -------- | -------------------------------------------------------------- |
| `chat_id`     | Integer     | No       | Specific private chat. If omitted, sets default for all chats. |
| `menu_button` | JSON String | Yes      | JSON object. Types: `default`, `commands`, or `web_app`.       |

```python BLP Example theme={null}
# Open a Web App from the menu button
menu_button = {
    "type": "web_app",
    "text": "Open App",
    "web_app": {"url": "https://bots.lt"}
}

Bot.setChatMenuButton(
    chat_id=u,
    menu_button=jsondumps(menu_button)
)

# Reset to default commands button
Bot.setChatMenuButton(
    chat_id=u,
    menu_button=jsondumps({"type": "commands"})
)
```

***

### getMe

Returns basic information about the bot.

| Parameter | Type | Required | Description             |
| --------- | ---- | -------- | ----------------------- |
| *(none)*  | —    | —        | No parameters required. |

**Returns** fields like `id`, `is_bot`, `first_name`, `username`, `can_join_groups`, `can_read_all_group_messages`, `supports_inline_queries`.

```python BLP Example theme={null}
result = Bot.getMe()
me = result.result
Bot.sendMessage(chat_id=u, text=f"Bot: @{me.username} (ID: {me.id})")
```

***

## Web Apps

### answerWebAppQuery

Sets the result of an interaction with a Web App and sends a corresponding message on behalf of the user to the chat from which the query originated.

| Parameter          | Type   | Required | Description                                                 |
| ------------------ | ------ | -------- | ----------------------------------------------------------- |
| `web_app_query_id` | String | Yes      | Unique identifier for the query to be answered.             |
| `result`           | Object | Yes      | A JSON-serialized object describing the message to be sent. |

***

### sendChatJoinRequestWebApp

Allows a Web App to create a request for a user to join a channel or a group.

| Parameter | Type              | Required | Description                           |
| --------- | ----------------- | -------- | ------------------------------------- |
| `chat_id` | Integer or String | Yes      | Target chat ID.                       |
| `user_id` | Integer           | Yes      | Unique identifier of the target user. |

***

## Payments and Deliveries

### answerPreCheckoutQuery

Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update. Use this method to respond to such pre-checkout queries.

| Parameter               | Type    | Required | Description                                                        |
| ----------------------- | ------- | -------- | ------------------------------------------------------------------ |
| `pre_checkout_query_id` | String  | Yes      | Unique identifier for the query to be answered.                    |
| `ok`                    | Boolean | Yes      | Specify True if everything is alright (goods are available, etc.). |
| `error_message`         | String  | No       | Required if ok is False.                                           |

***

### answerShippingQuery

If you sent an invoice requesting a shipping address and the parameter is\_flexible was specified, the Bot API will send an Update with a shipping\_query. Use this method to reply.

| Parameter           | Type            | Required | Description                                                                    |
| ------------------- | --------------- | -------- | ------------------------------------------------------------------------------ |
| `shipping_query_id` | String          | Yes      | Unique identifier for the query to be answered.                                |
| `ok`                | Boolean         | Yes      | Specify True if delivery to the specified address is possible.                 |
| `shipping_options`  | Array of Object | No       | Required if ok is True. A JSON-serialized array of available shipping options. |
| `error_message`     | String          | No       | Required if ok is False.                                                       |

***

## Stories

### editStory

Edits a story previously posted by the bot.

| Parameter    | Type              | Required | Description                                                    |
| ------------ | ----------------- | -------- | -------------------------------------------------------------- |
| `chat_id`    | Integer or String | Yes      | Unique identifier for the target chat.                         |
| `message_id` | Integer           | Yes      | Identifier of the story to edit.                               |
| `caption`    | String            | No       | New caption of the story.                                      |
| `media`      | Object            | No       | A JSON-serialized object for a new media content of the story. |

***

### deleteStory

Deletes a story posted by the bot.

| Parameter  | Type              | Required | Description                               |
| ---------- | ----------------- | -------- | ----------------------------------------- |
| `chat_id`  | Integer or String | Yes      | Target chat ID.                           |
| `story_id` | Integer           | Yes      | Unique identifier of the story to delete. |

***

## Prepared Keyboard Buttons

### savePreparedKeyboardButton

Saves a keyboard button that allows a user to perform an action on behalf of the bot.

| Parameter             | Type    | Required | Description                                                     |
| --------------------- | ------- | -------- | --------------------------------------------------------------- |
| `user_id`             | Integer | Yes      | Unique identifier of the target user.                           |
| `request`             | Object  | Yes      | A JSON-serialized object describing the button to be saved.     |
| `allow_user_chats`    | Boolean | No       | Pass True if the button can be used in private chats.           |
| `allow_bot_chats`     | Boolean | No       | Pass True if the button can be used in private chats with bots. |
| `allow_group_chats`   | Boolean | No       | Pass True if the button can be used in group chats.             |
| `allow_channel_chats` | Boolean | No       | Pass True if the button can be used in channel chats.           |

***

## Webhooks and System

### getUpdates

Receives incoming updates using long polling (receive events manually if not using webhooks).

*Note: BLP uses webhooks internally, so calling this directly may interfere with normal bot operation in some contexts.*

***

### setWebhook

Specifies a URL and receives incoming updates via an outgoing webhook. BLP automatically handles this, so this method is mostly for advanced custom integrations or migrating bots out of BLP.

| Parameter | Type   | Required | Description                   |
| --------- | ------ | -------- | ----------------------------- |
| `url`     | String | Yes      | HTTPS URL to send updates to. |

***

### getWebhookInfo

Gets current webhook status.

***

### deleteWebhook

Removes webhook integration.

***

### logOut

Logs out the bot from the cloud server. After this, you can invoke `close` and run the bot locally.

***

### close

Closes the bot instance on the cloud server before moving it to a local server.

***

## Managed Bots (Bots owned by other Bots)

### getManagedBotAccessSettings

Gets settings for a managed bot access.

***

### setManagedBotAccessSettings

Changes settings for a managed bot access.

| Parameter             | Type    | Required | Description                                         |
| --------------------- | ------- | -------- | --------------------------------------------------- |
| `allow_user_chats`    | Boolean | No       | Pass True if the bot can be added to private chats. |
| `allow_group_chats`   | Boolean | No       | Pass True if the bot can be added to group chats.   |
| `allow_channel_chats` | Boolean | No       | Pass True if the bot can be added to channel chats. |

***

### getManagedBotToken

Gets the token of a managed bot.

| Parameter | Type    | Required | Description            |
| --------- | ------- | -------- | ---------------------- |
| `bot_id`  | Integer | Yes      | Target bot identifier. |

***

### replaceManagedBotToken

Replaces the token of a managed bot.

| Parameter | Type    | Required | Description            |
| --------- | ------- | -------- | ---------------------- |
| `bot_id`  | Integer | Yes      | Target bot identifier. |

***

## Guest Queries & Suggested Posts

### answerGuestQuery

Answers a guest query for a Web App or game.

| Parameter        | Type   | Required | Description                                     |
| ---------------- | ------ | -------- | ----------------------------------------------- |
| `guest_query_id` | String | Yes      | Unique identifier for the query to be answered. |

***

### approveSuggestedPost

Approves a suggested post on a channel.

| Parameter    | Type              | Required | Description             |
| ------------ | ----------------- | -------- | ----------------------- |
| `chat_id`    | Integer or String | Yes      | Target channel ID.      |
| `message_id` | Integer           | Yes      | Target post message ID. |

***

### declineSuggestedPost

Declines a suggested post on a channel.

| Parameter    | Type              | Required | Description             |
| ------------ | ----------------- | -------- | ----------------------- |
| `chat_id`    | Integer or String | Yes      | Target channel ID.      |
| `message_id` | Integer           | Yes      | Target post message ID. |

***

## Bot Management (BLP Platform)

These are **Bots.LT-specific** methods, not part of the standard Telegram API.

### Bot.info

Returns detailed information about the current bot from the Bots.LT platform.

| Parameter | Type   | Required | Description                               |
| --------- | ------ | -------- | ----------------------------------------- |
| `bot_id`  | String | No       | Bot ID to query. Defaults to current bot. |

**Returns** a `DotDict` with fields: `token`, `bot_id`, `owner_email`, `status`, `username`, `first_name`, `userstat` (total users).

```python BLP Example theme={null}
info = Bot.info()
Bot.sendMessage(
    chat_id=u,
    text=f"Bot: {info.first_name}\nStatus: {info.status}\nTotal users: {info.userstat}"
)

# Or access via dynamic properties
Bot.sendMessage(chat_id=u, text=f"My username: @{Bot.username}")
Bot.sendMessage(chat_id=u, text=f"Owner: {Bot.owner_email}")
```

***

### Bot.Transfer

Programmatically transfers ownership of the bot to another Bots.LT user via their registered email or username.

| Parameter  | Type   | Required | Description                                                                      |
| ---------- | ------ | -------- | -------------------------------------------------------------------------------- |
| `email`    | String | No\*     | Registered email of the new owner.                                               |
| `username` | String | No\*     | Bots.LT username of the new owner.                                               |
| `bot_id`   | String | No       | Bot to transfer. Defaults to current bot. Can also transfer another bot you own. |

> **\*** Either `email` or `username` is required.

**Returns** `{"ok": True, "bot_id": "new_bot_id"}` on success.

```python BLP Example theme={null}
# Transfer current bot by username
Bot.Transfer(username="new_owner_username")

# Transfer current bot by email
Bot.Transfer(email="owner@example.com")

# Transfer a specific bot you own
Bot.Transfer(bot_id="other_bot_id", email="owner@example.com")
```

***

### Bot.Clone

Creates an exact copy of the bot (all commands and code). Optionally assigns a new Telegram token immediately.

| Parameter   | Type    | Required | Description                                                                                               |
| ----------- | ------- | -------- | --------------------------------------------------------------------------------------------------------- |
| `bot_token` | String  | No       | A new BotFather token to assign to the cloned bot. If not provided, the clone is created without a token. |
| `bot_id`    | String  | No       | Bot to clone. Defaults to current bot. Can also clone another bot you own.                                |
| `run_now`   | Boolean | No       | If `True`, starts the cloned bot immediately after creation. Default: `False`.                            |

**Returns** `{"ok": True, "bot_id": "new_bot_id"}` on success.

```python BLP Example theme={null}
# Clone current bot (no token yet)
Bot.Clone()

# Clone and assign a new BotFather token
Bot.Clone(bot_token="123456:ABC-DEF...")

# Clone and start immediately
Bot.Clone(bot_token="123456:ABC-DEF...", run_now=True)

# Clone a specific bot you own
Bot.Clone(bot_id="other_bot_id", bot_token="123456:ABC-DEF...")
```

***

## BLP Engine Methods

These methods control the **BLP execution engine** and are specific to Bots.LT.

### Bot.handleNextCommand

Sets up a **wait state** for the next user input. The next message from the user will trigger the specified command instead of matching normally.

| Parameter           | Type    | Required | Description                                                                                           |
| ------------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `command_name`      | String  | Yes      | The command to trigger on the next user message (e.g., `"/save_name"`).                               |
| `options`           | Dict    | No       | Data to forward to the next command (accessible via `params` or extra context).                       |
| `cancel_at_command` | Boolean | No       | If `True`, wait state is cancelled if user sends a new bot command (e.g., `/start`). Default: `True`. |

**Aliases:** `Bot.handleNextCommand`, `Bot.runCommandAfter` (see below)

```python BLP Example theme={null}
# In command /ask_name
Bot.sendMessage(chat_id=u, text="What is your name?")
Bot.handleNextCommand("/save_name", {"user_type": "premium"})

# In command /save_name
name = message.text
data = params  # Contains {"user_type": "premium"} passed from previous step
Bot.sendMessage(chat_id=u, text=f"Hello, {name}! You are a {data['user_type']} user.")
```

***

### Bot.runCommand

Programmatically triggers another command's code from within the current command.

| Parameter      | Type   | Required | Description                                     |
| -------------- | ------ | -------- | ----------------------------------------------- |
| `command_name` | String | Yes      | The command to run (e.g., `"/help"`).           |
| `options`      | Dict   | No       | Optional data to pass to the triggered command. |

```python BLP Example theme={null}
# Trigger the /welcome command from /start
Bot.runCommand("/welcome")

# Pass data to the triggered command
Bot.runCommand("/notify_admin", {"reason": "New user", "user_id": u})
```

***

### Bot.runCommandAfter

Schedules a command to run after a delay.

| Parameter      | Type    | Required | Description                               |
| -------------- | ------- | -------- | ----------------------------------------- |
| `seconds`      | Integer | Yes      | Delay in seconds before the command runs. |
| `command_name` | String  | Yes      | The command to run after the delay.       |
| `options`      | Dict    | No       | Optional data to pass to the command.     |

```python BLP Example theme={null}
Bot.sendMessage(chat_id=u, text="I'll remind you in 30 seconds!")
Bot.runCommandAfter(30, "/remind_user", {"message": "Time is up!"})
```

***

### Bot.broadcast

Sends a message or runs a command for multiple users at once.

| Parameter      | Type    | Required | Description                                                                |
| -------------- | ------- | -------- | -------------------------------------------------------------------------- |
| `code`         | String  | No       | BLP code to execute for each user.                                         |
| `command`      | String  | No       | Command name to run for each user.                                         |
| `mode`         | String  | No       | `"single"` (current bot users) or `"all"` (all bots). Default: `"single"`. |
| `speed`        | Integer | No       | Messages per second (1–50). Default: `8`.                                  |
| `bot_ids`      | List    | No       | Specific bot IDs to broadcast to (for multi-bot broadcasts).               |
| `callback_url` | String  | No       | Webhook URL to call when broadcast is complete.                            |

```python BLP Example theme={null}
# Broadcast a message to all bot users
Bot.broadcast(
    code='Bot.sendMessage(chat_id=u, text="Big announcement!")',
    speed=10
)

# Broadcast by running a command for each user
Bot.broadcast(
    command="/send_news",
    speed=5
)
```

***

### Bot.getBroadcastStatus

Gets the status of a running or completed broadcast.

| Parameter      | Type   | Required | Description                   |
| -------------- | ------ | -------- | ----------------------------- |
| `broadcast_id` | String | Yes      | ID of the broadcast to check. |

```python BLP Example theme={null}
status = Bot.getBroadcastStatus("broadcast_abc123")
Bot.sendMessage(
    chat_id=u,
    text=f"Status: {status.status}\nSent: {status.sent}\nFailed: {status.failed}"
)
```

***

### Bot.pauseBroadcast / Bot.resumeBroadcast / Bot.stopBroadcast

Controls a running broadcast.

| Method                                     | Parameter                        | Description                      |
| ------------------------------------------ | -------------------------------- | -------------------------------- |
| `Bot.pauseBroadcast(broadcast_id)`         | `broadcast_id`                   | Pauses a running broadcast.      |
| `Bot.resumeBroadcast(broadcast_id, speed)` | `broadcast_id`, optional `speed` | Resumes a paused broadcast.      |
| `Bot.stopBroadcast(broadcast_id)`          | `broadcast_id`                   | Permanently stops the broadcast. |

```python BLP Example theme={null}
Bot.pauseBroadcast("broadcast_abc123")
Bot.resumeBroadcast("broadcast_abc123", speed=20)
Bot.stopBroadcast("broadcast_abc123")
```
