Bot Identity, Profile, Commands & Menu Button

Raw MD
Inspect bot metadata (getMe), configure profile descriptions, command scopes, and the persistent [Menu] button.

Bot Identity & Metadata (getMe)

Before executing bot actions, you can query Telegram's servers to retrieve your bot's official identification, capabilities, and system flags using getMe:

PHP — Query Bot Identity with getMe
<?php
// ── Botlify Cloud .env — auto-injected, never hardcode secrets ──
$BOT_TOKEN     = getenv('BOT_TOKEN');     // Telegram bot token from @BotFather
$ADMIN_CHAT_ID = getenv('ADMIN_CHAT_ID'); // Your numeric admin Telegram user ID
$BOT_USERNAME  = getenv('BOT_USERNAME');  // Bot username without @

declare(strict_types=1);

$botInfo = bot('getMe');
if ($botInfo['ok'] ?? false) {
    $me = $botInfo['result'];
    $botId       = $me['id'];                       // e.g. 7123456789
    $botName     = $me['first_name'];               // e.g. "Botlify Cloud Bot"
    $botUsername = $me['username'];                 // e.g. "MySuperBot" (without @)
    $canJoin     = $me['can_join_groups'];          // bool: true/false
    $readAll     = $me['can_read_all_group_messages']; // bool (Privacy Mode status)
    $inlineOk    = $me['supports_inline_queries'];  // bool
    
    error_log("Connected as @{$botUsername} (ID: {$botId})");
}
Auto-Injected Constant: BOT_USERNAME
On Botlify Cloud, you do not need to call getMe on every webhook to get your bot's handle. The platform automatically injects BOT_USERNAME directly into your .env file.

Customizing Bot Profile via API (Name, Bio & Description)

Telegram allows bots to programmatically configure their visible profile text without manually interacting with @BotFather:

Method Visibility in Telegram Max Length
setMyName Top header title of the bot in chat lists and profile headers. 64 characters
setMyDescription Shown in the center of the screen when a user opens an empty chat with the bot before tapping /start. 512 characters
setMyShortDescription Shown on the bot's profile page and in Telegram chat share cards. 120 characters
PHP — Programmatic Profile Branding Setup
<?php
// ── Botlify Cloud .env — auto-injected, never hardcode secrets ──
$BOT_TOKEN     = getenv('BOT_TOKEN');     // Telegram bot token from @BotFather
$ADMIN_CHAT_ID = getenv('ADMIN_CHAT_ID'); // Your numeric admin Telegram user ID
$BOT_USERNAME  = getenv('BOT_USERNAME');  // Bot username without @

declare(strict_types=1);

function sync_bot_profile(string $name, string $about, string $shortBio): void {
    // 1. Update Display Name
    bot('setMyName', ['name' => $name]);

    // 2. Update Welcome Splash Screen (/start screen)
    bot('setMyDescription', [
        'description'   => $about,
        'language_code' => '' // Empty string applies to all languages
    ]);

    // 3. Update Profile Card / Share Bio
    bot('setMyShortDescription', [
        'short_description' => $shortBio,
        'language_code'     => ''
    ]);
}

// Example Execution
sync_bot_profile(
    'Botlify Cloud Assistant ⚡',
    "Welcome to the official Botlify Cloud Assistant!\n\n🚀 Deploy Telegram Bots in seconds\n💾 Embedded SQLite 3 database\n🤖 Model Context Protocol (MCP) enabled\n\nTap /start to begin!",
    'Ultra-fast Telegram bot cloud hosting and SQLite 3 studio powered by Botlify Cloud.'
);

Registering Slash Commands with Granular Scopes

The setMyCommands method registers slash commands that autocomplete when users type /. Using Telegram's BotCommandScope, you can show different commands to normal users vs. chat administrators:

PHP — Multi-Scope Command Registration
<?php
// ── Botlify Cloud .env — auto-injected, never hardcode secrets ──
$BOT_TOKEN     = getenv('BOT_TOKEN');     // Telegram bot token from @BotFather
$ADMIN_CHAT_ID = getenv('ADMIN_CHAT_ID'); // Your numeric admin Telegram user ID
$BOT_USERNAME  = getenv('BOT_USERNAME');  // Bot username without @

declare(strict_types=1);

function register_bot_commands(): void {
    // 1. Default Commands for Normal Private Chat Users
    bot('setMyCommands', [
        'commands' => [
            ['command' => 'start',    'description' => '🚀 Launch bot dashboard'],
            ['command' => 'help',     'description' => '📖 How to use this bot'],
            ['command' => 'settings', 'description' => '⚙️ Manage preferences'],
            ['command' => 'support',  'description' => '💬 Contact helpdesk']
        ],
        'scope' => ['type' => 'all_private_chats']
    ]);

    // 2. Secret Commands Visible Only to Bot Administrator
    if (defined('ADMIN_CHAT_ID') && ADMIN_CHAT_ID !== '') {
        bot('setMyCommands', [
            ['command' => 'start',     'description' => '🚀 Launch bot dashboard'],
            ['command' => 'admin',     'description' => '👑 Open Admin Suite'],
            ['command' => 'broadcast', 'description' => '📢 Mass Message All Users'],
            ['command' => 'stats',     'description' => '📊 Server & DB Metrics'],
            ['command' => 'settings',  'description' => '⚙️ Bot Configuration']
        ],
        'scope' => [
            'type'    => 'chat',
            'chat_id' => (int)ADMIN_CHAT_ID
        ]);
    }

    // 3. Group Chat Administrator Commands
    bot('setMyCommands', [
        'commands' => [
            ['command' => 'ban',   'description' => '🔨 Ban a member'],
            ['command' => 'mute',  'description' => '🔇 Mute spammer for 1 hour'],
            ['command' => 'warn',  'description' => '⚠️ Issue a community warning'],
            ['command' => 'rules', 'description' => '📜 Display group guidelines']
        ],
        'scope' => ['type' => 'all_chat_administrators']
    ]);
}

Configuring the Persistent Bottom [Menu] Button

Telegram allows replacing the default paperclip or command menu button beside the chat input box with a direct Web App Mini App launcher using setChatMenuButton:

PHP — Configure Web App Menu Button
<?php
// ── Botlify Cloud .env — auto-injected, never hardcode secrets ──
$BOT_TOKEN     = getenv('BOT_TOKEN');     // Telegram bot token from @BotFather
$ADMIN_CHAT_ID = getenv('ADMIN_CHAT_ID'); // Your numeric admin Telegram user ID
$BOT_USERNAME  = getenv('BOT_USERNAME');  // Bot username without @

declare(strict_types=1);

// Configure bottom-left button to launch a Telegram Mini App
bot('setChatMenuButton', [
    'menu_button' => [
        'type'    => 'web_app',
        'text'    => 'Launch App 🚀',
        'web_app' => [
            'url' => 'https://botlify.cloud/demo-app'
        ]
    ]
]);

// To restore default slash commands popup:
// bot('setChatMenuButton', ['menu_button' => ['type' => 'commands']]);
Botlify Cloud Runtime
Credentials are auto-injected in .env — always load them with getenv(): BOT_TOKEN, ADMIN_CHAT_ID, BOT_USERNAME. Main database: database.db (SQLite, WAL mode). Runtime errors: error.log. Quick test: send to $ADMIN_CHAT_ID. Full details: Runtime Reference.